devsoundextensions/audiorouting/Output/AudioOutputProxy/src/AudioOutputProxyAO.cpp
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:   AudioOutput Proxy Active Object
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "AudioOutput.h"
       
    20 #include "AudioOutputMessageTypes.h"
       
    21 #include <e32svr.h>
       
    22 #include "AudioOutputProxyAO.h"
       
    23 #include <CustomCommandUtility.h>
       
    24 #include <MAudioOutputObserver.h>
       
    25 
       
    26 
       
    27 // Two-phased constructor.
       
    28 CAudioOutputProxyAO* CAudioOutputProxyAO::NewL(CAudioOutput *aOutputProxy,MAudioOutputObserver& aObserver,MCustomCommand* aUtility)
       
    29 	{
       
    30 	CAudioOutputProxyAO* self = new(ELeave) CAudioOutputProxyAO(aOutputProxy,aObserver,aUtility);
       
    31     CleanupStack::PushL(self);
       
    32     self->ConstructL();
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35 	}
       
    36 
       
    37 // Destructor
       
    38 CAudioOutputProxyAO::~CAudioOutputProxyAO()
       
    39 	{
       
    40 	Cancel();
       
    41 	}
       
    42 
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 //
       
    46 CAudioOutputProxyAO::CAudioOutputProxyAO(CAudioOutput *aOutputProxy,MAudioOutputObserver& aObserver,MCustomCommand* aUtility):
       
    47 	CActive(CActive::EPriorityStandard),
       
    48 		iAudioOutputProxy(aOutputProxy),
       
    49 		iCustomCommandUtility(aUtility),
       
    50 		iObserver(&aObserver)
       
    51 	{
       
    52 	}
       
    53 
       
    54 void CAudioOutputProxyAO::ConstructL()
       
    55 	{
       
    56 	CActiveScheduler::Add(this);
       
    57 	}
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CAudioOutputProxyAO::RunL
       
    61 // ?implementation_description
       
    62 // (other items were commented in a header).
       
    63 // ---------------------------------------------------------
       
    64 //
       
    65 void CAudioOutputProxyAO::RunL()
       
    66 	{
       
    67 #ifdef _DEBUG
       
    68 	RDebug::Print(_L("CAudioOutputProxyAO::RunL"));
       
    69 #endif
       
    70 	if ( iRegistered != EFalse )
       
    71 		{
       
    72 		iCustomCommandUtility->CustomCommandAsync( *iDestination,iFunction,KNullDesC8,KNullDesC8,iCallbackData,iStatus );
       
    73 		SetActive();
       
    74 		iObserver->DefaultAudioOutputChanged(*iAudioOutputProxy,iCallbackData());
       
    75 		}
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CAudioOutputProxyAO::DoCancel
       
    80 // ?implementation_description
       
    81 // (other items were commented in a header).
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CAudioOutputProxyAO::DoCancel()
       
    85 	{
       
    86        if ( iRegistered != EFalse )
       
    87        	{
       
    88        	iCustomCommandUtility->CustomCommandSync( *iDestination, EAofUnregisterObserver, KNullDesC8, KNullDesC8);
       
    89        	}
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CAudioOutputProxyAO::SendAsyncMessage
       
    94 // ?implementation_description
       
    95 // (other items were commented in a header).
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CAudioOutputProxyAO::SendAsyncMessage(const TMMFMessageDestinationPckg& aDestination,
       
    99 	                                      TInt aFunction)
       
   100 	{
       
   101 	iDestination = &aDestination;
       
   102 	iFunction = aFunction;
       
   103 	iCustomCommandUtility->CustomCommandAsync( aDestination,aFunction,KNullDesC8,KNullDesC8,iCallbackData,iStatus );
       
   104 	SetActive();
       
   105 	}
       
   106 
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CAudioOutputProxyAO::SetRegisterFlag
       
   110 // ?implementation_description
       
   111 // (other items were commented in a header).
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 void CAudioOutputProxyAO::SetRegisterFlag(TBool aFlag)
       
   115 	{
       
   116 	iRegistered = aFlag;
       
   117 	}
       
   118 // ---------------------------------------------------------
       
   119 // CAudioOutputProxyAO::SetObserver
       
   120 // ?implementation_description
       
   121 // (other items were commented in a header).
       
   122 // ---------------------------------------------------------
       
   123 //
       
   124 void CAudioOutputProxyAO::SetObserver(MAudioOutputObserver& aObserver)
       
   125     {
       
   126     iObserver = &aObserver;
       
   127     }