radioengine/utils/src/cradioaudiorouter.cpp
changeset 57 21be958eb3ce
parent 38 f8c3d4e6102c
equal deleted inserted replaced
56:04837bf3a628 57:21be958eb3ce
    20 #include "cradioaudiorouter.h"
    20 #include "cradioaudiorouter.h"
    21 #include "mradioaudioroutingobserver.h"
    21 #include "mradioaudioroutingobserver.h"
    22 #include "cradioroutableaudio.h"
    22 #include "cradioroutableaudio.h"
    23 #include "radioengineutils.h"
    23 #include "radioengineutils.h"
    24 
    24 
    25 
       
    26 const TInt KVisualRadioInitialRoutableAudioArraySize( 2 );
       
    27 
    25 
    28 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    29 //
    27 //
    30 // ---------------------------------------------------------------------------
    28 // ---------------------------------------------------------------------------
    31 //
    29 //
    54 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    55 //
    53 //
    56 EXPORT_C CRadioAudioRouter::~CRadioAudioRouter()
    54 EXPORT_C CRadioAudioRouter::~CRadioAudioRouter()
    57     {
    55     {
    58     LEVEL3( LOG_METHOD_AUTO );
    56     LEVEL3( LOG_METHOD_AUTO );
    59     iRoutableAudios.Close();
       
    60     RadioEngineUtils::Release();
    57     RadioEngineUtils::Release();
    61     }
    58     }
    62 
    59 
    63 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    64 //
    61 //
    66 //
    63 //
    67 void CRadioAudioRouter::ConstructL()
    64 void CRadioAudioRouter::ConstructL()
    68     {
    65     {
    69     RadioEngineUtils::InitializeL();
    66     RadioEngineUtils::InitializeL();
    70     LEVEL3( LOG_METHOD_AUTO );
    67     LEVEL3( LOG_METHOD_AUTO );
    71     iRoutableAudios = RArray<CRadioRoutableAudio*>( KVisualRadioInitialRoutableAudioArraySize );
       
    72     }
    68     }
    73 
    69 
    74 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    75 // Sets audio route
    71 // Sets audio route
    76 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    77 //
    73 //
    78 EXPORT_C void CRadioAudioRouter::SetAudioRouteL( RadioEngine::TRadioAudioRoute aAudioRoute )
    74 EXPORT_C void CRadioAudioRouter::SetAudioRouteL( RadioEngine::TRadioAudioRoute aAudioRoute )
    79     {
    75     {
    80     LEVEL3( LOG_METHOD_AUTO );
    76     LEVEL3( LOG_METHOD_AUTO );
    81 
    77     if ( NULL == iRoutableAudio )
    82     for ( TInt i = 0; i < iRoutableAudios.Count(); ++i )
       
    83         {
    78         {
    84         iRoutableAudios[i]->SetAudioRouteL( aAudioRoute );
    79         User::Leave( KErrNotFound );
    85         }
    80         }
       
    81     iRoutableAudio->SetAudioRouteL( aAudioRoute );
    86     iAudioRoutingObserver.AudioRouteChangedL( aAudioRoute );
    82     iAudioRoutingObserver.AudioRouteChangedL( aAudioRoute );
    87     }
    83     }
    88 
    84 
    89 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
    90 //
    86 //
    91 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
    92 //
    88 //
    93 EXPORT_C void CRadioAudioRouter::RegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio )
    89 EXPORT_C void CRadioAudioRouter::RegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio )
    94     {
    90     {
    95     LEVEL3( LOG_METHOD_AUTO );
    91     LEVEL3( LOG_METHOD_AUTO );
    96     iRoutableAudios.Append( aRoutableAudio );
    92     if (iRoutableAudio)
       
    93         {
       
    94         LOG_FORMAT( "Reregistration, only one instance expected! Ptr1 = %p, ptr2 = %p", iRoutableAudio, aRoutableAudio );
       
    95         __ASSERT_DEBUG( iRoutableAudio, User::Panic( _L("FMRadio" ), KErrAbort ) );
       
    96         }
       
    97     iRoutableAudio = aRoutableAudio;
    97     }
    98     }
    98 
    99 
    99 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   100 //
   101 //
   101 // ---------------------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
   102 //
   103 //
   103 EXPORT_C void CRadioAudioRouter::UnRegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio )
   104 EXPORT_C void CRadioAudioRouter::UnRegisterRoutableAudio( CRadioRoutableAudio* DEBUGVAR( aRoutableAudio ) )
   104     {
   105     {
   105     LEVEL3( LOG_METHOD_AUTO );
   106     LEVEL3( LOG_METHOD_AUTO );
       
   107     __ASSERT_DEBUG( aRoutableAudio == iRoutableAudio, User::Panic( _L("FMRadio" ), KErrAbort ) );
   106 
   108 
   107     TInt objectIndex = iRoutableAudios.Find( aRoutableAudio );
   109     iRoutableAudio = NULL;
   108 
       
   109     __ASSERT_DEBUG( objectIndex != KErrNotFound, User::Panic( _L("VisualRadio" ), KErrAbort ) );
       
   110 
       
   111     if ( objectIndex != KErrNotFound )
       
   112         {
       
   113         iRoutableAudios.Remove( objectIndex );
       
   114         }
       
   115     }
   110     }
   116 
   111