os/mm/devsound/devsoundrefplugin/src/platsec/server/AudioServer/MmfAudioServerSession.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "MmfAudioServerSession.h"
    17 #include "MmfAudioClientServer.h"
    18 #include "MmfAudioServer.h"
    19 #include <s32mem.h>
    20 #include <e32math.h>
    21 
    22 
    23 /*
    24  This call takes ownership of aDevSoundSessionHandle. We need to ensure that it is closed
    25  in case of failure, but want to avoid double close situations. We emporarily push the argument
    26  onto cleanup stack and pass it into the CMMFAudioServerSession once we know that the assignment
    27  can't fail. The latter object itself takes ownership.
    28  */
    29 CMMFAudioServerSession* CMMFAudioServerSession::NewL(RHandleBase& aDevSoundSessionHandle)
    30 	{
    31 	CleanupClosePushL(aDevSoundSessionHandle);
    32 	CMMFAudioServerSession* self = new(ELeave) CMMFAudioServerSession();
    33 	CleanupStack::Pop(&aDevSoundSessionHandle);
    34 	self->SetDevSoundSessionHandle(aDevSoundSessionHandle);
    35 	CleanupStack::PushL(self);
    36 	self->ConstructL();
    37 	CleanupStack::Pop(self);
    38 	return self;
    39 	}
    40 
    41 void CMMFAudioServerSession::ConstructL()
    42 	{
    43 	}
    44 
    45 CMMFAudioServerSession::CMMFAudioServerSession()// : iEventsQue(_FOFF(TMMFAudioPolicyEventHolder,iLink))
    46 	{
    47 	}
    48 
    49 void CMMFAudioServerSession::CreateL(const CMmfIpcServer& aServer)
    50 	{
    51 	CMmfIpcSession::CreateL(aServer);
    52 	CMMFAudioServer* server = static_cast<CMMFAudioServer*>(CONST_CAST(CMmfIpcServer*, &aServer));
    53 	server->IncrementSessionId();
    54 	iAudioServerSessionId = server->AudioServerSessionId();
    55 	}
    56 
    57 CMMFAudioServerSession::~CMMFAudioServerSession()
    58 	{
    59 	CMMFAudioServer* server = 
    60 		const_cast<CMMFAudioServer*>(static_cast<const CMMFAudioServer*>(Server()));
    61 	if (server)
    62 		{
    63 		server->DecrementSessionId();		
    64 		}
    65 	iDevSoundSessionHandle.Close();
    66 	}
    67 
    68 void CMMFAudioServerSession::ServiceL(const RMmfIpcMessage& aMessage)
    69 	{
    70 	switch(aMessage.Function())
    71 		{
    72 	case EMMFDevSoundSessionHandle:
    73 		aMessage.Complete(iDevSoundSessionHandle);
    74 		break;
    75 	default:
    76 		User::Leave(KErrNotSupported);
    77 		break;
    78 		}
    79 	}
    80 
    81 void CMMFAudioServerSession::SendEventToClient(/*TMMFAudioPolicyEvent& aEvent*/)
    82 	{
    83 	}
    84 
    85 void CMMFAudioServerSession::SetDevSoundSessionHandle(RHandleBase& aDevSoundSessionHandle)
    86 	{
    87 	iDevSoundSessionHandle = aDevSoundSessionHandle;
    88 	}