LCOV - code coverage report
Current view: top level - avmedia/source/framework - soundhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 55 141 39.0 %
Date: 2012-08-25 Functions: 13 22 59.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 35 244 14.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "soundhandler.hxx"
      30                 :            : 
      31                 :            : #include <comphelper/mediadescriptor.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/io/XInputStream.hpp>
      34                 :            : #include <com/sun/star/frame/DispatchResultState.hpp>
      35                 :            : 
      36                 :            : #include <comphelper/sequenceashashmap.hxx>
      37                 :            : #include <rtl/ustrbuf.hxx>
      38                 :            : 
      39                 :            : #include <cppuhelper/typeprovider.hxx>
      40                 :            : #include <cppuhelper/factory.hxx>
      41                 :            : 
      42                 :            : namespace avmedia{
      43                 :            : 
      44                 :            : //*****************************************************************************************************************
      45                 :            : //  XInterface, XTypeProvider, XServiceInfo
      46                 :            : //*****************************************************************************************************************
      47                 :            : 
      48                 :         56 : void SAL_CALL SoundHandler::acquire() throw()
      49                 :            : {
      50                 :            :        /* Don't use mutex in methods of XInterface! */
      51                 :         56 :        OWeakObject::acquire();
      52                 :         56 : }
      53                 :            : 
      54                 :         56 : void SAL_CALL SoundHandler::release() throw()
      55                 :            : {
      56                 :            :        /* Don't use mutex in methods of XInterface! */
      57                 :         56 :        OWeakObject::release();
      58                 :         56 : }
      59                 :            : 
      60                 :         26 : css::uno::Any SAL_CALL SoundHandler::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException )
      61                 :            : {
      62                 :            :        /* Attention: Don't use mutex or guard in this method!!! Is a method of XInterface.     */
      63                 :            :         /* Ask for my own supported interfaces ...*/
      64                 :            :        css::uno::Any aReturn( ::cppu::queryInterface( aType,
      65                 :            :                static_cast< css::lang::XTypeProvider* >(this),
      66                 :            :                static_cast< css::lang::XServiceInfo* >(this),
      67                 :            :                static_cast< css::frame::XNotifyingDispatch* >(this),
      68                 :            :                static_cast< css::frame::XDispatch* >(this),
      69                 :         26 :                static_cast< css::document::XExtendedFilterDetection* >(this)));
      70                 :            :        /* If searched interface not supported by this class ... */
      71         [ +  + ]:         26 :        if ( aReturn.hasValue() == sal_False )
      72                 :            :        {
      73                 :            :                /* ... ask baseclass for interfaces! */
      74         [ +  - ]:         16 :                aReturn = OWeakObject::queryInterface( aType );
      75                 :            :        }
      76                 :            :         /* Return result of this search. */
      77                 :         26 :        return aReturn;
      78                 :            : }
      79                 :            : 
      80                 :          0 : css::uno::Sequence< sal_Int8 > SAL_CALL SoundHandler::getImplementationId() throw( css::uno::RuntimeException )
      81                 :            : {
      82                 :            :     /* Create one Id for all instances of this class.                                               */
      83                 :            :     /* Use ethernet address to do this! (sal_True)                                                  */
      84                 :            :     /* Optimize this method                                                                         */
      85                 :            :     /* We initialize a static variable only one time. And we don't must use a mutex at every call!  */
      86                 :            :     /* For the first call; pID is NULL - for the second call pID is different from NULL!            */
      87                 :            :     static ::cppu::OImplementationId* pID = NULL ;
      88         [ #  # ]:          0 :     if ( pID == NULL )
      89                 :            :     {
      90                 :            :         /* Ready for multithreading; get global mutex for first call of this method only! see before   */
      91 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      92                 :            :         /* Control these pointer again ... it can be, that another instance will be faster then these! */
      93         [ #  # ]:          0 :         if ( pID == NULL )
      94                 :            :         {
      95                 :            :             /* Create a new static ID ... */
      96 [ #  # ][ #  # ]:          0 :             static ::cppu::OImplementationId aID( sal_False );
      97                 :            :             /* ... and set his address to static pointer! */
      98                 :          0 :             pID = &aID ;
      99         [ #  # ]:          0 :         }
     100                 :            :     }
     101                 :          0 :     return pID->getImplementationId();
     102                 :            : }
     103                 :            : 
     104                 :          0 : css::uno::Sequence< css::uno::Type > SAL_CALL SoundHandler::getTypes() throw( css::uno::RuntimeException )
     105                 :            : {
     106                 :            :     /* Optimize this method !                                       */
     107                 :            :     /* We initialize a static variable only one time.               */
     108                 :            :     /* And we don't must use a mutex at every call!                 */
     109                 :            :     /* For the first call; pTypeCollection is NULL -                */
     110                 :            :     /* for the second call pTypeCollection is different from NULL!  */
     111                 :            :     static ::cppu::OTypeCollection* pTypeCollection = NULL ;
     112         [ #  # ]:          0 :     if ( pTypeCollection == NULL )
     113                 :            :     {
     114                 :            :         /* Ready for multithreading; get global mutex for first call of this method only! see before   */
     115 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     116                 :            :         /* Control these pointer again ... it can be, that another instance will be faster then these! */
     117         [ #  # ]:          0 :         if ( pTypeCollection == NULL )
     118                 :            :         {
     119                 :            :             /* Create a static typecollection ...           */
     120                 :            :             static ::cppu::OTypeCollection aTypeCollection
     121                 :            :                 (
     122         [ #  # ]:          0 :                     ::getCppuType(( const ::com::sun::star::uno::Reference< css::lang::XTypeProvider >*)NULL ),
     123         [ #  # ]:          0 :                     ::getCppuType(( const ::com::sun::star::uno::Reference< css::lang::XServiceInfo >*)NULL ),
     124         [ #  # ]:          0 :                     ::getCppuType(( const ::com::sun::star::uno::Reference< css::frame::XNotifyingDispatch >*)NULL ),
     125         [ #  # ]:          0 :                     ::getCppuType(( const ::com::sun::star::uno::Reference< css::frame::XDispatch >*)NULL ),
     126         [ #  # ]:          0 :                     ::getCppuType(( const ::com::sun::star::uno::Reference< css::document::XExtendedFilterDetection >*)NULL )
     127 [ #  # ][ #  # ]:          0 :                 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     128                 :            :             /* ... and set his address to static pointer! */
     129                 :          0 :             pTypeCollection = &aTypeCollection ;
     130         [ #  # ]:          0 :         }
     131                 :            :     }
     132                 :          0 :     return pTypeCollection->getTypes();
     133                 :            : }
     134                 :            : 
     135                 :            : #define DECLARE_ASCII( SASCIIVALUE ) \
     136                 :            :         ::rtl::OUString( SASCIIVALUE  )
     137                 :            : 
     138                 :            : #define IMPLEMENTATIONNAME_SOUNDHANDLER DECLARE_ASCII("com.sun.star.comp.framework.SoundHandler")
     139                 :            : #define SERVICENAME_CONTENTHANDLER DECLARE_ASCII("com.sun.star.frame.ContentHandler")
     140                 :            : 
     141                 :            : /*===========================================================================================================*/
     142                 :            : /* XServiceInfo */
     143                 :            : /*===========================================================================================================*/
     144                 :          0 : ::rtl::OUString SAL_CALL SoundHandler::getImplementationName() throw( css::uno::RuntimeException )
     145                 :            : {
     146                 :          0 :     return impl_getStaticImplementationName();
     147                 :            : }
     148                 :            : 
     149                 :            : /*===========================================================================================================*/
     150                 :            : /* XServiceInfo */
     151                 :            : /*===========================================================================================================*/
     152                 :          0 : sal_Bool SAL_CALL SoundHandler::supportsService( const ::rtl::OUString& sServiceName ) throw( css::uno::RuntimeException )
     153                 :            : {
     154                 :            :     /* Set default return value. */
     155                 :          0 :     sal_Bool bReturn = sal_False ;
     156                 :            :     /* Get names of all supported servicenames. */
     157         [ #  # ]:          0 :     css::uno::Sequence< ::rtl::OUString >  seqServiceNames =   getSupportedServiceNames();
     158                 :          0 :     const ::rtl::OUString*                 pArray          =   seqServiceNames.getConstArray();
     159                 :          0 :     sal_Int32                              nCounter        =   0;
     160                 :          0 :     sal_Int32                              nLength         =   seqServiceNames.getLength();
     161                 :            :     /* Search for right name in list. */
     162 [ #  # ][ #  # ]:          0 :     while   (
                 [ #  # ]
     163                 :            :               ( nCounter      <       nLength         )       &&
     164                 :            :               ( bReturn       ==      sal_False       )
     165                 :            :             )
     166                 :            :     {
     167                 :            :         /* Is name was found, say "YES, SERVICE IS SUPPORTED." and break loop. */
     168         [ #  # ]:          0 :         if ( pArray[nCounter] == sServiceName )
     169                 :            :         {
     170                 :          0 :             bReturn = sal_True ;
     171                 :            :         }
     172                 :            :         /* Else step to next element in list. */
     173                 :          0 :         ++nCounter;
     174                 :            :     }
     175                 :            :     /* Return state of search. */
     176         [ #  # ]:          0 :     return bReturn;
     177                 :            : }
     178                 :            : 
     179                 :            : /*===========================================================================================================*/
     180                 :            : /* XServiceInfo */
     181                 :            : /*===========================================================================================================*/
     182                 :          0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL SoundHandler::getSupportedServiceNames() throw( css::uno::RuntimeException )
     183                 :            : {
     184                 :          0 :     return impl_getStaticSupportedServiceNames();
     185                 :            : }
     186                 :            : 
     187                 :            : /*===========================================================================================================*/
     188                 :            : /* Helper for XServiceInfo                                                                                   */
     189                 :            : /*===========================================================================================================*/
     190                 :          8 : css::uno::Sequence< ::rtl::OUString > SoundHandler::impl_getStaticSupportedServiceNames()
     191                 :            : {
     192                 :          8 :     css::uno::Sequence< ::rtl::OUString > seqServiceNames( 1 );
     193         [ +  - ]:          8 :     seqServiceNames.getArray() [0] = SERVICENAME_CONTENTHANDLER;
     194                 :          8 :     return seqServiceNames;
     195                 :            : }
     196                 :            : 
     197                 :            : /*===========================================================================================================*/
     198                 :            : /* Helper for XServiceInfo */
     199                 :            : /*===========================================================================================================*/
     200                 :         16 : ::rtl::OUString SoundHandler::impl_getStaticImplementationName()
     201                 :            : {
     202                 :         16 :     return IMPLEMENTATIONNAME_SOUNDHANDLER;
     203                 :            : }
     204                 :            : 
     205                 :         12 : css::uno::Reference< css::uno::XInterface > SAL_CALL SoundHandler::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception )
     206                 :            : {
     207                 :            :     /* create new instance of service */
     208         [ +  - ]:         12 :     SoundHandler* pClass = new SoundHandler( xServiceManager );
     209                 :            :     /* hold it alive by increasing his ref count!!! */
     210         [ +  - ]:         12 :     css::uno::Reference< css::uno::XInterface > xService( static_cast< ::cppu::OWeakObject* >(pClass), css::uno::UNO_QUERY );
     211                 :            :     /* initialize new service instance ... he can use his own refcount ... we hold it! */
     212         [ +  - ]:         12 :     pClass->impl_initService();
     213                 :            :     /* return new created service as reference */
     214                 :         12 :     return xService;
     215                 :            : }
     216                 :            : 
     217                 :          8 : css::uno::Reference< css::lang::XSingleServiceFactory > SoundHandler::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
     218                 :            : {
     219                 :            :     css::uno::Reference< css::lang::XSingleServiceFactory > xReturn ( cppu::createSingleFactory (
     220                 :            :        xServiceManager,
     221                 :            :         SoundHandler::impl_getStaticImplementationName(),
     222                 :            :         SoundHandler::impl_createInstance,
     223                 :            :         SoundHandler::impl_getStaticSupportedServiceNames()
     224                 :            :         )
     225 [ +  - ][ +  - ]:          8 :     );
                 [ +  - ]
     226                 :          8 :     return xReturn;
     227                 :            : }
     228                 :            : 
     229                 :         12 : void SAL_CALL SoundHandler::impl_initService()
     230                 :            : {
     231                 :         12 : }
     232                 :            : 
     233                 :            : /*-************************************************************************************************************//**
     234                 :            :     @short      standard ctor
     235                 :            :     @descr      These initialize a new instance of this class with needed informations for work.
     236                 :            : 
     237                 :            :     @seealso    using at owner
     238                 :            : 
     239                 :            :     @param      "xFactory", reference to service manager for creation of new services
     240                 :            :     @return     -
     241                 :            : 
     242                 :            :     @onerror    Show an assertion and do nothing else.
     243                 :            :     @threadsafe yes
     244                 :            : *//*-*************************************************************************************************************/
     245                 :         12 : SoundHandler::SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory )
     246                 :            :         //  Init baseclasses first
     247                 :            :         :   ThreadHelpBase      (          )
     248                 :            :         ,   ::cppu::OWeakObject (          )
     249                 :            :         // Init member
     250                 :            :     ,   m_bError        ( false    )
     251 [ +  - ][ +  - ]:         12 :         ,   m_xFactory          ( xFactory )
     252                 :            : {
     253         [ +  - ]:         12 :     m_aUpdateTimer.SetTimeoutHdl(LINK(this, SoundHandler, implts_PlayerNotify));
     254                 :         12 : }
     255                 :            : 
     256                 :            : /*-************************************************************************************************************//**
     257                 :            :     @short      standard dtor
     258                 :            :     @descr      -
     259                 :            : 
     260                 :            :     @seealso    -
     261                 :            : 
     262                 :            :     @param      -
     263                 :            :     @return     -
     264                 :            : 
     265                 :            :     @onerror    -
     266                 :            :     @threadsafe -
     267                 :            : *//*-*************************************************************************************************************/
     268 [ +  - ][ +  - ]:         12 : SoundHandler::~SoundHandler()
                 [ +  - ]
     269                 :            : {
     270         [ -  + ]:         12 :     if (m_xListener.is())
     271                 :            :     {
     272         [ #  # ]:          0 :         css::frame::DispatchResultEvent aEvent;
     273                 :          0 :         aEvent.State = css::frame::DispatchResultState::FAILURE;
     274 [ #  # ][ #  # ]:          0 :         m_xListener->dispatchFinished(aEvent);
     275 [ #  # ][ #  # ]:          0 :         m_xListener = css::uno::Reference< css::frame::XDispatchResultListener >();
     276                 :            :     }
     277         [ -  + ]:         24 : }
     278                 :            : 
     279                 :            : /*-************************************************************************************************************//**
     280                 :            :     @interface  ::com::sun::star::frame::XDispatch
     281                 :            : 
     282                 :            :     @short      try to load audio file
     283                 :            :     @descr      This method try to load given audio file by URL and play it. We use vcl/Sound class to do that.
     284                 :            :                 Playing of sound is asynchron everytime.
     285                 :            : 
     286                 :            :     @attention  We must hold us alive by ourself ... because we use async. vcl sound player ... but playing is started
     287                 :            :                 in async interface call "dispatch()" too. And caller forget us imediatly. But then our uno ref count
     288                 :            :                 will decreased to 0 and will die. The only solution is to use own reference to our implementation.
     289                 :            :                 But we do it for realy started jobs only and release it during call back of vcl.
     290                 :            : 
     291                 :            :     @seealso    class vcl/Sound
     292                 :            :     @seealso    method implts_PlayerNotify()
     293                 :            : 
     294                 :            :     @param      "aURL"      , URL to dispatch.
     295                 :            :     @param      "lArguments", list of optional arguments.
     296                 :            :     @return     -
     297                 :            : 
     298                 :            :     @onerror    We do nothing.
     299                 :            :     @threadsafe yes
     300                 :            : *//*-*************************************************************************************************************/
     301                 :          0 : void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL&                                             aURL      ,
     302                 :            :                                                      const css::uno::Sequence< css::beans::PropertyValue >&            lDescriptor,
     303                 :            :                                                      const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException)
     304                 :            : {
     305                 :            :     // SAFE {
     306         [ #  # ]:          0 :     const ::osl::MutexGuard aLock( m_aLock );
     307                 :            : 
     308                 :            :     {
     309                 :            :     //close streams otherwise on windows we can't reopen the file in the
     310                 :            :     //media player when we pass the url to directx as it'll already be open
     311         [ #  # ]:          0 :         ::comphelper::MediaDescriptor aDescriptor(lDescriptor);
     312                 :            : 
     313                 :            :     css::uno::Reference< css::io::XInputStream > xInputStream =
     314         [ #  # ]:          0 :         aDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_INPUTSTREAM(),
     315         [ #  # ]:          0 :         css::uno::Reference< css::io::XInputStream >());
     316 [ #  # ][ #  # ]:          0 :     if (xInputStream.is()) xInputStream->closeInput();
         [ #  # ][ #  # ]
     317                 :            :     }
     318                 :            : 
     319                 :            :     // If player currently used for other dispatch() requests ...
     320                 :            :     // cancel it by calling stop()!
     321         [ #  # ]:          0 :     m_aUpdateTimer.Stop();
     322         [ #  # ]:          0 :     if (m_xPlayer.is())
     323                 :            :     {
     324 [ #  # ][ #  # ]:          0 :         if (m_xPlayer->isPlaying())
                 [ #  # ]
     325 [ #  # ][ #  # ]:          0 :             m_xPlayer->stop();
     326                 :          0 :         m_xPlayer.clear();
     327                 :            :     }
     328                 :            : 
     329                 :            :     // Try to initialize player.
     330         [ #  # ]:          0 :     m_xListener = xListener;
     331                 :            :     try
     332                 :            :     {
     333                 :          0 :         m_bError = false;
     334 [ #  # ][ #  # ]:          0 :         m_xPlayer.set( avmedia::MediaWindow::createPlayer( aURL.Complete ), css::uno::UNO_QUERY_THROW );
     335                 :            :         // OK- we can start async playing ...
     336                 :            :         // Count this request and initialize self-holder against dieing by uno ref count ...
     337 [ #  # ][ #  # ]:          0 :         m_xSelfHold = css::uno::Reference< css::uno::XInterface >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY);
                 [ #  # ]
     338 [ #  # ][ #  # ]:          0 :         m_xPlayer->start();
     339         [ #  # ]:          0 :         m_aUpdateTimer.SetTimeout( 200 );
     340         [ #  # ]:          0 :         m_aUpdateTimer.Start();
     341                 :            :     }
     342         [ #  # ]:          0 :     catch( css::uno::Exception& e )
     343                 :            :     {
     344                 :          0 :         m_bError = true;
     345                 :            :         (void)e;
     346                 :          0 :         m_xPlayer.clear();
     347         [ #  # ]:          0 :     }
     348                 :            : 
     349                 :            :     // } SAFE
     350                 :          0 : }
     351                 :            : 
     352                 :          0 : void SAL_CALL SoundHandler::dispatch( const css::util::URL&                                  aURL       ,
     353                 :            :                                       const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException )
     354                 :            : {
     355         [ #  # ]:          0 :     dispatchWithNotification(aURL, lArguments, css::uno::Reference< css::frame::XDispatchResultListener >());
     356                 :          0 : }
     357                 :            : 
     358                 :            : /*-************************************************************************************************************//**
     359                 :            :     @interface  ::com::sun::star::document::XExtendedFilterDetection
     360                 :            : 
     361                 :            :     @short      try to detect file (given as argument included in "lDescriptor")
     362                 :            :     @descr      We try to detect, if given file could be handled by this class and is a well known one.
     363                 :            :                 If it is - we return right internal type name - otherwise we return nothing!
     364                 :            :                 So call can search for another detect service and ask him too.
     365                 :            : 
     366                 :            :     @attention  a) We don't need any mutex here ... because we don't use any member!
     367                 :            :                 b) Dont' use internal player instance "m_pPlayer" to detect given sound file!
     368                 :            :                    It's not neccessary to do that ... and we can use temp. variable to do the same.
     369                 :            :                    This way is easy - we don't must synchronize it with currently played sounds!
     370                 :            :                    Another reason to do so ... We are a listener on our internal ma_Player object.
     371                 :            :                    If you would call "IsSoundFile()" on this instance, he would call us back and
     372                 :            :                    we make some uneccssary things ...
     373                 :            : 
     374                 :            :     @seealso    -
     375                 :            : 
     376                 :            :     @param      "lDescriptor", description of file to detect
     377                 :            :     @return     Internal type name which match this file ... or nothing if it is unknown.
     378                 :            : 
     379                 :            :     @onerror    We return nothing.
     380                 :            :     @threadsafe yes
     381                 :            : *//*-*************************************************************************************************************/
     382                 :         10 : ::rtl::OUString SAL_CALL SoundHandler::detect( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException )
     383                 :            : {
     384                 :            :     // Our default is "nothing". So we can return it, if detection failed or fily type is realy unknown.
     385                 :         10 :     ::rtl::OUString sTypeName;
     386                 :            : 
     387                 :            :     // Analyze given descriptor to find filename or input stream or ...
     388         [ +  - ]:         10 :     ::comphelper::MediaDescriptor aDescriptor(lDescriptor);
     389 [ +  - ][ +  - ]:         10 :     ::rtl::OUString               sURL       = aDescriptor.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_URL(), ::rtl::OUString());
     390                 :            : 
     391 [ -  + ][ -  + ]:         20 :     if (
                 [ +  - ]
     392                 :         10 :         (sURL.getLength()           ) &&
     393         [ +  - ]:         10 :         (avmedia::MediaWindow::isMediaURL(sURL))
     394                 :            :        )
     395                 :            :     {
     396                 :            :         // If the file type is supported depends on the OS, so...
     397                 :            :         // I think we can the following ones:
     398                 :            :         //  a) look for given extension of url to map our type decision HARD CODED!!!
     399                 :            :         //  b) return preferred type every time... it's easy :-)
     400                 :          0 :         sTypeName = ::rtl::OUString("wav_Wave_Audio_File");
     401 [ #  # ][ #  # ]:          0 :         aDescriptor[::comphelper::MediaDescriptor::PROP_TYPENAME()] <<= sTypeName;
                 [ #  # ]
     402         [ #  # ]:          0 :         aDescriptor >> lDescriptor;
     403                 :            :     }
     404                 :            : 
     405                 :            :     // Return our decision.
     406         [ +  - ]:         10 :     return sTypeName;
     407                 :            : }
     408                 :            : 
     409                 :            : /*-************************************************************************************************************//**
     410                 :            :     @short      call back of sound player
     411                 :            :     @descr      Our player call us back to give us some informations.
     412                 :            :                 We use this informations to callback our might existing listener.
     413                 :            : 
     414                 :            :     @seealso    method dispatchWithNotification()
     415                 :            : 
     416                 :            :     @param      -
     417                 :            :     @return     0 everytime ... it doesnt matter for us.
     418                 :            : 
     419                 :            :     @onerror    -
     420                 :            :     @threadsafe yes
     421                 :            : *//*-*************************************************************************************************************/
     422                 :          0 : IMPL_LINK_NOARG(SoundHandler, implts_PlayerNotify)
     423                 :            : {
     424                 :            :     // SAFE {
     425         [ #  # ]:          0 :     ::osl::ClearableMutexGuard aLock( m_aLock );
     426                 :            : 
     427 [ #  # ][ #  # ]:          0 :     if (m_xPlayer.is() && m_xPlayer->isPlaying() && m_xPlayer->getMediaTime() < m_xPlayer->getDuration())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     428                 :            :     {
     429         [ #  # ]:          0 :         m_aUpdateTimer.Start();
     430                 :          0 :         return 0L;
     431                 :            :     }
     432                 :          0 :     m_xPlayer.clear();
     433                 :            : 
     434                 :            :     // We use m_xSelfHold to let us die ... but we must live till real finishing of this method too!!!
     435                 :            :     // So we SHOULD use another "self-holder" temp. to provide that ...
     436                 :          0 :     css::uno::Reference< css::uno::XInterface > xOperationHold = m_xSelfHold;
     437         [ #  # ]:          0 :     m_xSelfHold = css::uno::Reference< css::uno::XInterface >();
     438                 :            : 
     439                 :            :     // notify might existing listener
     440                 :            :     // And forget this listener!
     441                 :            :     // Because the corresponding dispatch was finished.
     442         [ #  # ]:          0 :     if (m_xListener.is())
     443                 :            :     {
     444         [ #  # ]:          0 :         css::frame::DispatchResultEvent aEvent;
     445         [ #  # ]:          0 :         if (!m_bError)
     446                 :          0 :             aEvent.State = css::frame::DispatchResultState::SUCCESS;
     447                 :            :         else
     448                 :          0 :             aEvent.State = css::frame::DispatchResultState::FAILURE;
     449 [ #  # ][ #  # ]:          0 :         m_xListener->dispatchFinished(aEvent);
     450 [ #  # ][ #  # ]:          0 :         m_xListener = css::uno::Reference< css::frame::XDispatchResultListener >();
     451                 :            :     }
     452                 :            : 
     453                 :            :     // } SAFE
     454                 :            :     //release aLock before end of method at which point xOperationHold goes out of scope and pThis dies
     455         [ #  # ]:          0 :     aLock.clear();
     456         [ #  # ]:          0 :     return 0;
     457                 :            : }
     458                 :            : 
     459                 :            : } // namespace framework
     460                 :            : 
     461                 :          8 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplementationName, void* pServiceManager, void* /*pRegistryKey*/ )
     462                 :            : {
     463                 :          8 :     void* pReturn = NULL;
     464         [ +  - ]:          8 :     if  (pServiceManager !=  NULL )
     465                 :            :     {
     466                 :            :         /* Define variables which are used in following macros. */
     467                 :          8 :         css::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
     468                 :          8 :         css::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
     469         [ +  - ]:          8 :             xServiceManager = reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager )  ;
     470                 :            : 
     471 [ +  - ][ +  - ]:          8 :         if ( avmedia::SoundHandler::impl_getStaticImplementationName().equals( ::rtl::OUString::createFromAscii( pImplementationName ) ) )
     472 [ +  - ][ +  - ]:          8 :             xFactory = avmedia::SoundHandler::impl_createFactory( xServiceManager );
     473                 :            : 
     474         [ +  - ]:          8 :         if ( xFactory.is() == sal_True )
     475                 :            :         {
     476         [ +  - ]:          8 :             xFactory->acquire();
     477         [ +  - ]:          8 :             pReturn = xFactory.get();
     478                 :          8 :         }
     479                 :            :     }
     480                 :            :     /* Return with result of this operation. */
     481                 :          8 :     return pReturn;
     482                 :            : }
     483                 :            : 
     484                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10