devsoundextensions/audiorouting/Output/AudioOutputMessageHandler/src/AudioOutputMessageHandler.cpp
author hgs
Wed, 13 Oct 2010 12:45:32 +0100
changeset 2 5c1df44f2eed
parent 0 b8ed18f6c07b
permissions -rw-r--r--
2010wk42_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     1
/*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     3
* All rights reserved.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     8
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     9
* Initial Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    11
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    12
* Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    13
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    14
* Description: Audio output msg handler implementation
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    15
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    16
*/
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    17
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    18
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    19
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    20
// INCLUDE FILES
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    21
#include    "AudioOutput.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    22
#include    "AudioOutputMessageHandler.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    23
#include    "AudioOutputMessageTypes.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    24
#include	"MAudioOutputObserver.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    25
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    26
//reason for defining this secure id here but not using from the mmfbase.hrh is that 
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    27
//lot of macros in mmfbase.hrh collide with base.hrh
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    28
#define KUidMmfDrmPluginServerDefine            0x10283439
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    29
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    30
// ================= MEMBER FUNCTIONS =======================
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    31
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    32
// C++ default constructor can NOT contain any code, that
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    33
// might leave.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    34
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    35
CAudioOutputMessageHandler::CAudioOutputMessageHandler(CAudioOutput*        aAudioOutput,
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    36
                                                       CMMFObjectContainer& aContainer) :
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    37
	CMMFObject(KUidAudioOutput),
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    38
	iContainer(aContainer)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    39
    {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    40
    iAudioOutput = aAudioOutput;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    41
    }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    42
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    43
// Two-phased constructor.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    44
EXPORT_C CAudioOutputMessageHandler* CAudioOutputMessageHandler::NewL(TAny*                aCustomInterface,
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    45
                                                             CMMFObjectContainer& aContainer)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    46
    {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    47
    CAudioOutput* audioOutput = (CAudioOutput*)aCustomInterface;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    48
    CAudioOutputMessageHandler* self = new (ELeave) CAudioOutputMessageHandler(audioOutput,
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    49
                                                                               aContainer);
2
5c1df44f2eed 2010wk42_01
hgs
parents: 0
diff changeset
    50
    CleanupStack::PushL(self);
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    51
	self->ConstructL();
2
5c1df44f2eed 2010wk42_01
hgs
parents: 0
diff changeset
    52
	CleanupStack::Pop(self);
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    53
    return self;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    54
    }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    55
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    56
    
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    57
// Destructor
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    58
CAudioOutputMessageHandler::~CAudioOutputMessageHandler()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    59
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    60
	delete iAudioOutput;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    61
	delete iCallbackMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    62
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    63
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    64
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    65
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    66
// CAudioOutputMessageHandler::AudioOutputL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    67
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    68
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    69
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    70
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    71
EXPORT_C TUid CAudioOutputMessageHandler::Uid()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    72
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    73
	return KUidAudioOutput;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    74
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    75
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    76
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    77
// CAudioOutputMessageHandler::SetAudioOutputL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    78
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    79
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    80
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    81
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    82
void CAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    83
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    84
	ASSERT(aMessage.Destination().InterfaceId() == KUidAudioOutput);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    85
	TRAPD(error,DoHandleRequestL(aMessage));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    86
	if(error)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    87
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    88
		aMessage.Complete(error);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    89
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    90
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    91
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    92
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    93
// CAudioOutputMessageHandler::DoHandleRequestL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    94
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    95
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    96
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    97
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    98
void CAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    99
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   100
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   101
	switch(aMessage.Function())
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   102
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   103
		case EAofDelete:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   104
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   105
			DoDeleteL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   106
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   107
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   108
		case EAofRegisterObserver:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   109
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   110
			iCallbackMessage = new (ELeave) TMMFMessage( aMessage );
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   111
			DoRegisterObserverL();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   112
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   113
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   114
		case EAofSetAudioOutput:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   115
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   116
			DoSetAudioOutputL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   117
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   118
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   119
		case EAofGetAudioOutput:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   120
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   121
			DoGetAudioOutputL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   122
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   123
			}			
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   124
		case EAofSetSecureOutput:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   125
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   126
			DoSetSecureOutputL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   127
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   128
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   129
		case EAofUnregisterObserver:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   130
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   131
			DoUnregisterObserverL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   132
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   133
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   134
		default:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   135
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   136
			aMessage.Complete(KErrNotSupported);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   137
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   138
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   139
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   140
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   141
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   142
// CAudioOutputMessageHandler::DoDeleteL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   143
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   144
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   145
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   146
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   147
void CAudioOutputMessageHandler::DoDeleteL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   148
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   149
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   150
	iContainer.RemoveAndDestroyMMFObject(*this);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   151
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   152
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   153
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   154
// CAudioOutputMessageHandler::DoRegisterObserverL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   155
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   156
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   157
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   158
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   159
void CAudioOutputMessageHandler::DoRegisterObserverL()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   160
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   161
	iAudioOutput->RegisterObserverL(*this);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   162
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   163
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   164
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   165
// CAudioOutputMessageHandler::DoSetAudioOutputL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   166
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   167
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   168
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   169
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   170
void CAudioOutputMessageHandler::DoSetAudioOutputL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   171
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   172
	TPckgBuf<CAudioOutput::TAudioOutputPreference> outputPckg;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   173
	aMessage.ReadData1FromClient(outputPckg);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   174
	CAudioOutput::TAudioOutputPreference output = outputPckg();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   175
	iAudioOutput->SetAudioOutputL(output);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   176
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   177
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   178
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   179
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   180
// CAudioOutputMessageHandler::DoSetSecureOutputL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   181
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   182
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   183
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   184
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   185
void CAudioOutputMessageHandler::DoSetSecureOutputL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   186
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   187
	//Since we allow the creation of CAudioOutput from Custom interface builder. 
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   188
	//We have to make sure that this message is blocked in case we are running in Secure DRM process
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   189
	const TSecureId KSecureDRMSID(KUidMmfDrmPluginServerDefine);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   190
	RThread currentThread;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   191
	RProcess currentProcess;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   192
	CleanupClosePushL(currentThread);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   193
    CleanupClosePushL(currentProcess);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   194
	User::LeaveIfError(currentThread.Process(currentProcess));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   195
	TSecureId curProcessSID = currentProcess.SecureId();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   196
	CleanupStack::PopAndDestroy();//calls currentThread.Close()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   197
	CleanupStack::PopAndDestroy();//calls currentProcess.Close()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   198
	if (curProcessSID == KSecureDRMSID)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   199
	    {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   200
	    //since we are in secure DRM process, completing request with KErrPermissionDenied.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   201
	    aMessage.Complete(KErrPermissionDenied);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   202
	    return;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   203
	    }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   204
	TPckgBuf<TBool> secureOutputPckg;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   205
	aMessage.ReadData1FromClient(secureOutputPckg);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   206
	TBool secureOutput = secureOutputPckg();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   207
	iAudioOutput->SetSecureOutputL(secureOutput);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   208
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   209
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   210
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   211
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   212
// CAudioOutputMessageHandler::DoUnregisterObserverL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   213
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   214
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   215
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   216
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   217
void CAudioOutputMessageHandler::DoUnregisterObserverL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   218
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   219
	iAudioOutput->UnregisterObserver(*this);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   220
	if ( iCallbackMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   221
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   222
		if ( !iCallbackMessage->IsCompleted() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   223
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   224
			iCallbackMessage->Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   225
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   226
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   227
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   228
	delete iCallbackMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   229
	iCallbackMessage = NULL;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   230
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   231
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   232
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   233
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   234
// CAudioOutputMessageHandler::DefaultAudioOutputChanged
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   235
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   236
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   237
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   238
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   239
void CAudioOutputMessageHandler::DefaultAudioOutputChanged( CAudioOutput& /*aAudioOutput*/,
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   240
		                                CAudioOutput::TAudioOutputPreference aNewDefault )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   241
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   242
	TPckgBuf<CAudioOutput::TAudioOutputPreference> outputPckg(aNewDefault);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   243
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   244
	if ( iCallbackMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   245
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   246
		if ( !iCallbackMessage->IsCompleted() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   247
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   248
			iCallbackMessage->WriteDataToClient( outputPckg );
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   249
			iCallbackMessage->Complete( KErrNone );
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   250
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   251
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   252
	delete iCallbackMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   253
	iCallbackMessage = NULL;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   254
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   255
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   256
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   257
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   258
// CAudioOutputMessageHandler::ConstructL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   259
// Symbian 2nd phase constructor can leave.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   260
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   261
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   262
void CAudioOutputMessageHandler::ConstructL()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   263
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   264
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   265
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   266
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   267
// CAudioOutputMessageHandler::DoSetAudioOutputL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   268
// ?implementation_description
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   269
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   270
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   271
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   272
void CAudioOutputMessageHandler::DoGetAudioOutputL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   273
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   274
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   275
    RDebug::Print(_L("CAudioOutputMessageHandler::DoGetAudioOutputL"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   276
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   277
	CAudioOutput::TAudioOutputPreference outPut = iAudioOutput->AudioOutput();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   278
	TPckgBuf<CAudioOutput::TAudioOutputPreference> outPutPckg(outPut);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   279
	aMessage.WriteDataToClient(outPutPckg);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   280
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   281
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   282
// ========================== OTHER EXPORTED FUNCTIONS =========================
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   283
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   284
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   285
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   286
// End of File