radioengine/utils/src/cradioaudiorouter.cpp
branchRCL_3
changeset 19 cce62ebc198e
equal deleted inserted replaced
18:1a6714c53019 19:cce62ebc198e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // User includes
       
    19 #include "cradioenginelogger.h"
       
    20 #include "cradioaudiorouter.h"
       
    21 #include "mradioaudioroutingobserver.h"
       
    22 #include "cradioroutableaudio.h"
       
    23 #include "radioengineutils.h"
       
    24 
       
    25 
       
    26 const TInt KVisualRadioInitialRoutableAudioArraySize( 2 );
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CRadioAudioRouter::CRadioAudioRouter( MRadioAudioRoutingObserver& aAudioRoutingObserver )
       
    33     : iAudioRoutingObserver( aAudioRoutingObserver )
       
    34     {
       
    35     LEVEL3( LOG_METHOD_AUTO );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CRadioAudioRouter* CRadioAudioRouter::NewL( MRadioAudioRoutingObserver& aAudioRoutingObserver )
       
    43     {
       
    44     LEVEL3( LOG_METHOD_AUTO );
       
    45     CRadioAudioRouter* self = new( ELeave ) CRadioAudioRouter( aAudioRoutingObserver );
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CRadioAudioRouter::~CRadioAudioRouter()
       
    57     {
       
    58     LEVEL3( LOG_METHOD_AUTO );
       
    59     iRoutableAudios.Close();
       
    60     RadioEngineUtils::Release();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CRadioAudioRouter::ConstructL()
       
    68     {
       
    69     RadioEngineUtils::InitializeL();
       
    70     LEVEL3( LOG_METHOD_AUTO );
       
    71     iRoutableAudios = RArray<CRadioRoutableAudio*>( KVisualRadioInitialRoutableAudioArraySize );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Sets audio route
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C void CRadioAudioRouter::SetAudioRouteL( RadioEngine::TRadioAudioRoute aAudioRoute )
       
    79     {
       
    80     LEVEL3( LOG_METHOD_AUTO );
       
    81 
       
    82     for ( TInt i = 0; i < iRoutableAudios.Count(); ++i )
       
    83         {
       
    84         iRoutableAudios[i]->SetAudioRouteL( aAudioRoute );
       
    85         }
       
    86     iAudioRoutingObserver.AudioRouteChangedL( aAudioRoute );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C void CRadioAudioRouter::RegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio )
       
    94     {
       
    95     LEVEL3( LOG_METHOD_AUTO );
       
    96     iRoutableAudios.Append( aRoutableAudio );
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C void CRadioAudioRouter::UnRegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio )
       
   104     {
       
   105     LEVEL3( LOG_METHOD_AUTO );
       
   106 
       
   107     TInt objectIndex = iRoutableAudios.Find( aRoutableAudio );
       
   108 
       
   109     __ASSERT_DEBUG( objectIndex != KErrNotFound, User::Panic( _L("VisualRadio" ), KErrAbort ) );
       
   110 
       
   111     if ( objectIndex != KErrNotFound )
       
   112         {
       
   113         iRoutableAudios.Remove( objectIndex );
       
   114         }
       
   115     }
       
   116