os/mm/devsound/a3fdevsound/src/mmfaudioserver/mmfaudioserver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/a3fdevsound/src/mmfaudioserver/mmfaudioserver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,572 @@
     1.4 +//mmfaudioserver.cpp
     1.5 +
     1.6 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +// All rights reserved.
     1.8 +// This component and the accompanying materials are made available
     1.9 +// under the terms of "Eclipse Public License v1.0"
    1.10 +// which accompanies this distribution, and is available
    1.11 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12 +//
    1.13 +// Initial Contributors:
    1.14 +// Nokia Corporation - initial contribution.
    1.15 +//
    1.16 +// Contributors:
    1.17 +//
    1.18 +// Description:
    1.19 +// Portions Copyright Nokia-Symbian * Nokia Core OS *
    1.20 +// INCLUDE FILES
    1.21 +//
    1.22 +
    1.23 +#include <e32math.h>
    1.24 +#include <mmf/common/mmfbase.hrh>
    1.25 +
    1.26 +#include "mmfaudioserver.h"
    1.27 +#include "mmfaudioserverdecs.h"
    1.28 +#include "mmfdevsoundsession.h"
    1.29 +#include "mmfaudioserversession.h"
    1.30 +#include "mmfdevsoundserver.h"
    1.31 +#include "mmfdevsoundserverstart.h"
    1.32 +#include "mmfaudioserverfactory.h"
    1.33 +#include "devsoundsvrthreadpriorityconsts.h"
    1.34 +
    1.35 +#ifdef _DEBUG
    1.36 +#include "e32debug.h"
    1.37 +#define SYMBIAN_DEBPRN0(str)    RDebug::Print(str, this)
    1.38 +#else
    1.39 +#define SYMBIAN_DEBPRN0(str)
    1.40 +#endif //_DEBUG
    1.41 +
    1.42 +
    1.43 +// Time delay that the audio server wait before shutdown itself when is detected that the last DevSoundSession is closed
    1.44 +const TInt KAudioServerShutDownDelay = 50000000; //50 sec
    1.45 +
    1.46 +// ======== LOCAL FUNCTIONS ========
    1.47 +
    1.48 +void Panic(TInt aPanicCode)
    1.49 +	{
    1.50 +	_LIT(KAudioServerPanicCategory, "mmfaudioserver");
    1.51 +	User::Panic(KAudioServerPanicCategory, aPanicCode);
    1.52 +	}
    1.53 +
    1.54 +// ============================ MEMBER FUNCTIONS ===============================
    1.55 +
    1.56 +// -----------------------------------------------------------------------------
    1.57 +// CMMFAudioServer::NewL
    1.58 +// Two-phased constructor.
    1.59 +// -----------------------------------------------------------------------------
    1.60 +//
    1.61 +CMMFAudioServer* CMMFAudioServer::NewL()
    1.62 +	{
    1.63 +	CMMFAudioServer* self = new(ELeave) CMMFAudioServer();
    1.64 +	CleanupStack::PushL(self);
    1.65 +	self->ConstructL();
    1.66 +	CleanupStack::Pop(self);
    1.67 +	return self;
    1.68 +	}
    1.69 +
    1.70 +// -----------------------------------------------------------------------------
    1.71 +// CMMFAudioServer::CMMFAudioServer
    1.72 +// C++ default constructor can NOT contain any code, that
    1.73 +// might leave.
    1.74 +// -----------------------------------------------------------------------------
    1.75 +//
    1.76 +CMMFAudioServer::CMMFAudioServer()
    1.77 +	: CMmfIpcServer(EPriorityStandard)
    1.78 +	{
    1.79 +	}
    1.80 +
    1.81 +// -----------------------------------------------------------------------------
    1.82 +// CMMFAudioServer::ConstructL
    1.83 +// Symbian 2nd phase constructor can leave.
    1.84 +// -----------------------------------------------------------------------------
    1.85 +//
    1.86 +void CMMFAudioServer::ConstructL()
    1.87 +	{
    1.88 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::ConstructL - enter"));
    1.89 +
    1.90 +	SetPinClientDescriptors(ETrue);
    1.91 +	// Call base class to Start server
    1.92 +	StartL(KAudioServerName);
    1.93 +
    1.94 +	iFourCCConvertor = CFourCCConvertor::NewL();
    1.95 +	iDelayAudioServerShutDown = CDelayAudioServerShutDown::NewL();
    1.96 +
    1.97 +	iFactory = CMMFAudioServerFactory::NewL();
    1.98 +	iFactory->StartL(*this);	
    1.99 +
   1.100 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::ConstructL - exit"));
   1.101 +	}
   1.102 +
   1.103 +// -----------------------------------------------------------------------------
   1.104 +// CMMFAudioServer::~CMMFAudioServer
   1.105 +// Destructor
   1.106 +// -----------------------------------------------------------------------------
   1.107 +//
   1.108 +CMMFAudioServer::~CMMFAudioServer()
   1.109 +	{
   1.110 +	if (iDelayAudioServerShutDown)
   1.111 +		{
   1.112 +		iDelayAudioServerShutDown->Cancel();
   1.113 +		delete iDelayAudioServerShutDown;
   1.114 +		iDelayAudioServerShutDown = NULL;
   1.115 +		}
   1.116 +
   1.117 +	for(TInt i=(iDevSoundServList.Count()-1); i >=0 ; i--)
   1.118 +		{
   1.119 +		CStartAndMonitorDevSoundThread* devSoundMonitorThread = iDevSoundServList[i];
   1.120 +		iDevSoundServList.Remove(i);
   1.121 +		delete devSoundMonitorThread;
   1.122 +		}
   1.123 +	iDevSoundServList.Close();
   1.124 +	delete iFourCCConvertor;
   1.125 +	if (iFactory)
   1.126 +		{
   1.127 +		iFactory->Stop(*this);
   1.128 +		delete iFactory;
   1.129 +		}
   1.130 +	}
   1.131 +
   1.132 +// -----------------------------------------------------------------------------
   1.133 +// CMMFAudioServer::NewSessionL
   1.134 +// Creates a new session to handle requests by the client and returns it to the
   1.135 +// client server framework.
   1.136 +// -----------------------------------------------------------------------------
   1.137 +//
   1.138 +CMmfIpcSession* CMMFAudioServer::NewSessionL(const TVersion& aVersion) const
   1.139 +	{
   1.140 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::NewSessionL - enter"));
   1.141 +	
   1.142 +	TVersion v(KMMFAudioServerVersion,
   1.143 +			KMMFAudioServerMinorVersionNumber,
   1.144 +			KMMFAudioServerBuildVersionNumber);
   1.145 +	if(!User::QueryVersionSupported(v, aVersion))
   1.146 +		{
   1.147 +		User::Leave(KErrNotSupported);
   1.148 +		}
   1.149 +	
   1.150 +	for(TInt i=(iDevSoundServList.Count()-1); i >=0 ; i--)
   1.151 +		{
   1.152 +		CStartAndMonitorDevSoundThread* devSoundMonitorThread = iDevSoundServList[i];
   1.153 +
   1.154 +		if(!devSoundMonitorThread->IsActive())
   1.155 +			{
   1.156 +			iDevSoundServList.Remove(i);
   1.157 +			delete devSoundMonitorThread;
   1.158 +			}
   1.159 +		iDevSoundServList.Compress();
   1.160 +		}
   1.161 +
   1.162 +	RMMFDevSoundServerProxy devSoundSessionHandle;
   1.163 +	User::LeaveIfError(StartDevSoundServer(devSoundSessionHandle));
   1.164 +	CMMFAudioServerSession* audioServerSession = CMMFAudioServerSession::NewL(devSoundSessionHandle);
   1.165 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::NewSessionL - session created"));
   1.166 +	return audioServerSession;
   1.167 +	}
   1.168 +
   1.169 +// -----------------------------------------------------------------------------
   1.170 +// CMMFAudioServer::IncrementSessionId
   1.171 +// Increment the session Id.
   1.172 +// -----------------------------------------------------------------------------
   1.173 +//
   1.174 +void CMMFAudioServer::IncrementSessionId()
   1.175 +	{
   1.176 +	iAudioServerSessionId++;
   1.177 +	}
   1.178 +
   1.179 +// -----------------------------------------------------------------------------
   1.180 +// CMMFAudioServer::DecrementSessionId
   1.181 +// Decrement the session Id.
   1.182 +// -----------------------------------------------------------------------------
   1.183 +//
   1.184 +void CMMFAudioServer::DecrementSessionId()
   1.185 +	{
   1.186 +	iAudioServerSessionId--;
   1.187 +	}
   1.188 +
   1.189 +// -----------------------------------------------------------------------------
   1.190 +// CMMFAudioServer::IncrementDevSoundCount
   1.191 +// Increment the DevSound server counter. If there is atleast one DevSound
   1.192 +// server, it will cancel its shutdown timer.
   1.193 +// -----------------------------------------------------------------------------
   1.194 +//
   1.195 +void CMMFAudioServer::IncrementDevSoundCount()
   1.196 +	{
   1.197 +	iDevSoundCount++;
   1.198 +	//in the case we started the shutdown due to no more DevSound
   1.199 +	if(iDevSoundCount)
   1.200 +		{
   1.201 +		ASSERT(iDelayAudioServerShutDown);
   1.202 +		if (iDelayAudioServerShutDown)
   1.203 +			{
   1.204 +			iDelayAudioServerShutDown->Cancel();
   1.205 +			}
   1.206 +		}
   1.207 +	}
   1.208 +
   1.209 +// -----------------------------------------------------------------------------
   1.210 +// CMMFAudioServer::DecrementDevSoundCount
   1.211 +// Decrement the DevSound server counter. Once the number of DevSound server's
   1.212 +// instances becomes zero, Audio Server will start its shutdown routine.
   1.213 +// -----------------------------------------------------------------------------
   1.214 +//
   1.215 +void CMMFAudioServer::DecrementDevSoundCount()
   1.216 +	{
   1.217 +	iDevSoundCount--;
   1.218 +	if (iDevSoundCount == 0)
   1.219 +		{
   1.220 +		ASSERT(iDelayAudioServerShutDown);
   1.221 +		if (iDelayAudioServerShutDown)
   1.222 +			{
   1.223 +			iDelayAudioServerShutDown->SetDelay(TTimeIntervalMicroSeconds32(KAudioServerShutDownDelay));
   1.224 +			}
   1.225 +		}
   1.226 +	}
   1.227 +
   1.228 +// -----------------------------------------------------------------------------
   1.229 +// CMMFAudioServer::SendEventToClient
   1.230 +// Sends Event to DevSound client.
   1.231 +// -----------------------------------------------------------------------------
   1.232 +//
   1.233 +void CMMFAudioServer::SendEventToClient(TInt aSessionToAlert, TInt /*aSessionToBeLaunched*/)
   1.234 +	{
   1.235 +	// For the session requested, send event to client
   1.236 +	iSessionIter.SetToFirst();
   1.237 +	CMMFAudioServerSession* session = static_cast<CMMFAudioServerSession*>(iSessionIter++);
   1.238 +	while (session)
   1.239 +		{
   1.240 +		if (session->AudioServerSessionId() == aSessionToAlert)
   1.241 +			{
   1.242 +			break;  // Finished
   1.243 +			}
   1.244 +
   1.245 +		session = static_cast<CMMFAudioServerSession*>(iSessionIter++);
   1.246 +		}
   1.247 +	}
   1.248 +
   1.249 +// -----------------------------------------------------------------------------
   1.250 +// CMMFAudioServer::LaunchRequest
   1.251 +// Launches the DevSound servers waiting for Audio Policy.
   1.252 +// -----------------------------------------------------------------------------
   1.253 +//
   1.254 +void CMMFAudioServer::LaunchRequest(TInt aSessionId)
   1.255 +	{
   1.256 +	iSessionIter.SetToFirst();
   1.257 +	CMMFAudioServerSession* session = static_cast<CMMFAudioServerSession*>(iSessionIter++);
   1.258 +
   1.259 +	while (session)
   1.260 +		{
   1.261 +		if (session->AudioServerSessionId() == aSessionId)
   1.262 +			{
   1.263 +			break;  // Finished
   1.264 +			}
   1.265 +		session = static_cast<CMMFAudioServerSession*>(iSessionIter++);
   1.266 +		}
   1.267 +	}
   1.268 +
   1.269 +// -----------------------------------------------------------------------------
   1.270 +// CMMFAudioServer::StartDevSoundServer
   1.271 +// Starts a new DevSound server instance.
   1.272 +// -----------------------------------------------------------------------------
   1.273 +//
   1.274 +TInt CMMFAudioServer::StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const
   1.275 +	{
   1.276 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::StartDevSoundServer - enter"));
   1.277 +
   1.278 +	RMessage2 message(Message());
   1.279 +	CStartAndMonitorDevSoundThread* monitorDevSound = NULL;
   1.280 +
   1.281 +	TRAPD(err, monitorDevSound = CStartAndMonitorDevSoundThread::NewL(const_cast<CMMFAudioServer*>(this)));
   1.282 +	if(err != KErrNone)
   1.283 +		{
   1.284 +		delete monitorDevSound;
   1.285 +		return err;
   1.286 +		}
   1.287 +
   1.288 +	err = iDevSoundServList.Append(monitorDevSound);
   1.289 +	if(err != KErrNone)
   1.290 +		{
   1.291 +		delete monitorDevSound;
   1.292 +		return err;
   1.293 +		}
   1.294 +	
   1.295 +	SYMBIAN_DEBPRN0(_L("CMMFAudioServer[0x%x]::StartDevSoundServer - exit"));
   1.296 +	return monitorDevSound->StartDevSoundServer(message, aDevSoundSessionHandle);
   1.297 +
   1.298 +	}
   1.299 +
   1.300 +// -----------------------------------------------------------------------------
   1.301 +// CMMFAudioServer::CDelayAudioServerShutDown::NewL
   1.302 +// Two-phased constructor.
   1.303 +// -----------------------------------------------------------------------------
   1.304 +//
   1.305 +CMMFAudioServer::CDelayAudioServerShutDown*
   1.306 +CMMFAudioServer::CDelayAudioServerShutDown::NewL()
   1.307 +	{
   1.308 +	CDelayAudioServerShutDown* self = new(ELeave) CDelayAudioServerShutDown;
   1.309 +	CleanupStack::PushL(self);
   1.310 +	self->ConstructL();
   1.311 +	CleanupStack::Pop(self);
   1.312 +	return self;
   1.313 +	}
   1.314 +
   1.315 +// -----------------------------------------------------------------------------
   1.316 +// Constructor.
   1.317 +// -----------------------------------------------------------------------------
   1.318 +//
   1.319 +CMMFAudioServer::CDelayAudioServerShutDown::CDelayAudioServerShutDown()
   1.320 +	: CActive(0)
   1.321 +	{
   1.322 +	}
   1.323 +
   1.324 +// -----------------------------------------------------------------------------
   1.325 +// CMMFAudioServer::CDelayAudioServerShutDown::ConstructL
   1.326 +// -----------------------------------------------------------------------------
   1.327 +//
   1.328 +void CMMFAudioServer::CDelayAudioServerShutDown::ConstructL()
   1.329 +	{
   1.330 +	User::LeaveIfError(iShutDownTimer.CreateLocal());
   1.331 +	CActiveScheduler::Add(this);
   1.332 +	}
   1.333 +
   1.334 +// -----------------------------------------------------------------------------
   1.335 +// CMMFAudioServer::CDelayAudioServerShutDown::~CDelayAudioServerShutDown
   1.336 +// -----------------------------------------------------------------------------
   1.337 +//
   1.338 +CMMFAudioServer::CDelayAudioServerShutDown::~CDelayAudioServerShutDown()
   1.339 +	{
   1.340 +	Cancel();
   1.341 +	iShutDownTimer.Close();
   1.342 +	}
   1.343 +
   1.344 +// -----------------------------------------------------------------------------
   1.345 +// CMMFAudioServer::CDelayAudioServerShutDown::SetDelay
   1.346 +// Request a timeout after aDelay
   1.347 +// -----------------------------------------------------------------------------
   1.348 +//
   1.349 +void CMMFAudioServer::CDelayAudioServerShutDown::SetDelay(
   1.350 +	TTimeIntervalMicroSeconds32 aDelay)
   1.351 +	{
   1.352 +	__ASSERT_ALWAYS(!IsActive(), Panic(EMMFAudioServerIsActive));
   1.353 +	iShutDownTimer.After(iStatus, aDelay);
   1.354 +	SetActive();
   1.355 +	}
   1.356 +
   1.357 +// -----------------------------------------------------------------------------
   1.358 +// CMMFAudioServer::CDelayAudioServerShutDown::RunL
   1.359 +// Called by Active object framework when timer times out.
   1.360 +// -----------------------------------------------------------------------------
   1.361 +//
   1.362 +void CMMFAudioServer::CDelayAudioServerShutDown::RunL()
   1.363 +	{
   1.364 +	CActiveScheduler::Stop();
   1.365 +	}
   1.366 +
   1.367 +// -----------------------------------------------------------------------------
   1.368 +// CMMFAudioServer::CDelayAudioServerShutDown::DoCancel
   1.369 +// Called by the Active object framework when user cancels active object.
   1.370 +// -----------------------------------------------------------------------------
   1.371 +//
   1.372 +void CMMFAudioServer::CDelayAudioServerShutDown::DoCancel()
   1.373 +	{
   1.374 +	iShutDownTimer.Cancel();
   1.375 +	}
   1.376 +
   1.377 +// -----------------------------------------------------------------------------
   1.378 +// CStartAndMonitorDevSoundThread::NewL
   1.379 +// -----------------------------------------------------------------------------
   1.380 +//
   1.381 +CStartAndMonitorDevSoundThread* CStartAndMonitorDevSoundThread::NewL(
   1.382 +	CMMFAudioServer* aAudioServer)
   1.383 +	{
   1.384 +	CStartAndMonitorDevSoundThread* self = new(ELeave) CStartAndMonitorDevSoundThread(aAudioServer);
   1.385 +	CleanupStack::PushL(self);
   1.386 +	self->ConstructL();
   1.387 +	CleanupStack::Pop(self);
   1.388 +	return self;
   1.389 +	}
   1.390 +
   1.391 +// -----------------------------------------------------------------------------
   1.392 +// CStartAndMonitorDevSoundThread::ConstructL
   1.393 +// -----------------------------------------------------------------------------
   1.394 +//
   1.395 +void CStartAndMonitorDevSoundThread::ConstructL()
   1.396 +	{
   1.397 +	CActiveScheduler::Add(this);
   1.398 +	}
   1.399 +
   1.400 +// -----------------------------------------------------------------------------
   1.401 +// CStartAndMonitorDevSoundThread::StartDevSoundServer
   1.402 +// Starts a new DevSound server.
   1.403 +// -----------------------------------------------------------------------------
   1.404 +//
   1.405 +TInt CStartAndMonitorDevSoundThread::StartDevSoundServer(
   1.406 +	RMessage2& aMessage,
   1.407 +	RMMFDevSoundServerProxy& aDevSoundSessionHandle)
   1.408 +	{
   1.409 +	SYMBIAN_DEBPRN0(_L("CStartAndMonitorDevSoundThread[0x%x]::StartDevSoundServer - enter"));
   1.410 +	
   1.411 +	RThread clientThread;
   1.412 +	TInt err(KErrNone);
   1.413 +	
   1.414 +	// Open handle to client thread
   1.415 +	err = aMessage.Client(clientThread);
   1.416 +	if (err != KErrNone)
   1.417 +		{
   1.418 +		clientThread.Close();
   1.419 +		return err;
   1.420 +		}
   1.421 +	// Open a process-relative handle to the process which owns clientThread.
   1.422 +	RProcess clientProcess;
   1.423 +	err = clientThread.Process(clientProcess);
   1.424 +	
   1.425 +	if (err != KErrNone)
   1.426 +		{
   1.427 +		// Close client thread handle and return error
   1.428 +		clientThread.Close();
   1.429 +		return err;
   1.430 +		}
   1.431 +	
   1.432 +	// Get the client process id
   1.433 +	TProcessId clientProcessId(clientProcess.Id());
   1.434 +	
   1.435 +	// Close client thread and client process handles
   1.436 +	clientThread.Close();
   1.437 +	clientProcess.Close();
   1.438 +	
   1.439 +	RServer2 devSoundServerHandle;
   1.440 +	devSoundServerHandle.SetReturnedHandle(0);
   1.441 +	
   1.442 +	//Pass to DevSoundServer the clien't process ID
   1.443 +	TDevSoundServerStart start(iAudioServer,
   1.444 +								clientProcessId,
   1.445 +								devSoundServerHandle);
   1.446 +	
   1.447 +	TThreadFunction serverFunc=CMMFDevSoundServer::StartThread;
   1.448 +	
   1.449 +	// To deal with the unique thread (+semaphore!) naming in EPOC,
   1.450 +	// and that we may be trying to restart a server that has just
   1.451 +	// exited we attempt to create a unique thread name for the server.
   1.452 +#ifdef SYMBIAN_USE_SEPARATE_HEAPS
   1.453 +	err = iServer.Create(KNullDesC,serverFunc,KDevSoundServerStackSize*2,
   1.454 +						KDevSoundServerInitHeapSize,
   1.455 +						KDevSoundServerMaxHeapSize,
   1.456 +						&start,
   1.457 +						EOwnerProcess);
   1.458 +#else
   1.459 +	err = iServer.Create(KNullDesC,
   1.460 +						serverFunc,
   1.461 +						(KDevSoundServerStackSize*2),
   1.462 +						NULL,
   1.463 +						&start,
   1.464 +						EOwnerProcess);
   1.465 +#endif // SYMBIAN_USE_SEPARATE_HEAPS
   1.466 +	if(err != KErrNone)
   1.467 +		{
   1.468 +		return err;
   1.469 +		}
   1.470 +	iServer.SetPriority(KDevsoundSvrPriority);
   1.471 +
   1.472 +	// Synchronise with the server
   1.473 +	TRequestStatus reqStatus;
   1.474 +	iServer.Rendezvous(reqStatus);
   1.475 +
   1.476 +	if (reqStatus!=KRequestPending)
   1.477 +		{
   1.478 +		iServer.Kill(0);
   1.479 +		}
   1.480 +	else
   1.481 +		{
   1.482 +		// Start the test harness
   1.483 +		iServer.Resume();
   1.484 +		// Server will call the reciprocal static synchronise call
   1.485 +		}
   1.486 +
   1.487 +	// note devSoundServerHandle really "owned" by client thread - just copied here
   1.488 +
   1.489 +	User::WaitForRequest(reqStatus); // wait for start or death
   1.490 +	if(reqStatus.Int() != KErrNone)
   1.491 +		{
   1.492 +		// close our handle to the thread. If we reach here, the thread should have
   1.493 +		// closed anyway as continue Rendezvous is always KErrNone() 
   1.494 +		iServer.Close();
   1.495 +		return reqStatus.Int();
   1.496 +		}
   1.497 +
   1.498 +	err = aDevSoundSessionHandle.Open(devSoundServerHandle);
   1.499 +
   1.500 +	if(err != KErrNone)
   1.501 +		{
   1.502 +		// close our handle to the thread. If we reach here, this means that NewSessionL() failed
   1.503 +		// on server, and that action itself will asynchronously stop the thread
   1.504 +		iServer.Close();
   1.505 +		return err;
   1.506 +		}
   1.507 +
   1.508 +	aDevSoundSessionHandle.ShareProtected();
   1.509 +	iServer.Logon(iStatus);
   1.510 +	SetActive();
   1.511 +
   1.512 +	iAudioServer->IncrementDevSoundCount();
   1.513 +
   1.514 +	SYMBIAN_DEBPRN0(_L("CStartAndMonitorDevSoundThread[0x%x]::StartDevSoundServer - exit"));
   1.515 +	return KErrNone;
   1.516 +	}
   1.517 +
   1.518 +// -----------------------------------------------------------------------------
   1.519 +// CStartAndMonitorDevSoundThread::CStartAndMonitorDevSoundThread
   1.520 +// Constructor
   1.521 +// -----------------------------------------------------------------------------
   1.522 +//
   1.523 +CStartAndMonitorDevSoundThread::CStartAndMonitorDevSoundThread(
   1.524 +	CMMFAudioServer* aAudioServer)
   1.525 +	: CActive(EPriorityStandard),iAudioServer(aAudioServer)
   1.526 +	{
   1.527 +
   1.528 +	}
   1.529 +
   1.530 +// Desctructor
   1.531 +CStartAndMonitorDevSoundThread::~CStartAndMonitorDevSoundThread()
   1.532 +	{
   1.533 +	Cancel();
   1.534 +	}
   1.535 +
   1.536 +// -----------------------------------------------------------------------------
   1.537 +// CStartAndMonitorDevSoundThread::RunL
   1.538 +// Called by Active Object framework when DevSound server is destroyed.
   1.539 +// -----------------------------------------------------------------------------
   1.540 +//
   1.541 +void CStartAndMonitorDevSoundThread::RunL()
   1.542 +	{
   1.543 +	iServer.Close();
   1.544 +	iAudioServer->DecrementDevSoundCount();
   1.545 +	}
   1.546 +
   1.547 +// -----------------------------------------------------------------------------
   1.548 +// CStartAndMonitorDevSoundThread::DoCancel
   1.549 +// Called by Active Object framework when client cancels active object.
   1.550 +// -----------------------------------------------------------------------------
   1.551 +//
   1.552 +void CStartAndMonitorDevSoundThread::DoCancel()
   1.553 +	{
   1.554 +	iServer.LogonCancel(iStatus);
   1.555 +	}
   1.556 +
   1.557 +
   1.558 +// -----------------------------------------------------------------------------
   1.559 +// RMMFDevSoundServerProxy::Open
   1.560 +// Creates new audio server session for the devsound server.
   1.561 +// -----------------------------------------------------------------------------
   1.562 +//
   1.563 +TInt RMMFDevSoundServerProxy::Open(RServer2& aDevSoundServerHandle)
   1.564 +	{
   1.565 +	SYMBIAN_DEBPRN0(_L("RMMFDevSoundServerProxy[0x%x]::Open - enter"));
   1.566 +	TInt err = CreateSession(aDevSoundServerHandle, TVersion(KMMFDevSoundServerVersion,
   1.567 +							KMMFDevSoundServerMinorVersionNumber,
   1.568 +							KMMFDevSoundServerBuildVersionNumber),
   1.569 +							-1, EIpcSession_GlobalSharable);
   1.570 +
   1.571 +	SYMBIAN_DEBPRN0(_L("RMMFDevSoundServerProxy[0x%x]::Open - exit"));
   1.572 +	return err;
   1.573 +	}
   1.574 +
   1.575 +//  End of File