os/mm/devsound/devsoundrefplugin/src/server/Policy/MmfAudioPolicyProxy.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/devsoundrefplugin/src/server/Policy/MmfAudioPolicyProxy.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,211 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include <e32math.h>
    1.21 +#include "mmfAudioPolicyProxy.h"
    1.22 +#include "MmfAudioPolicyStart.h"
    1.23 +#include "MmfBase.hrh"
    1.24 +#include "MmfDevSoundInfo.h"
    1.25 +#include "MmfAudioPolicyServer.h"
    1.26 +
    1.27 +
    1.28 +
    1.29 +EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
    1.30 +	{
    1.31 +	ASSERT(aPolicyServerHandle.Handle());
    1.32 +	
    1.33 +	// Server is already running and attempt to create a session
    1.34 +	// 4 message slots
    1.35 +	TInt err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
    1.36 +													KMMFAudioPolicyMinorVersionNumber,
    1.37 +													KMMFAudioPolicyBuildVersionNumber));		
    1.38 +	return err;		
    1.39 +	}
    1.40 +
    1.41 +EXPORT_C TInt RMMFAudioPolicyProxy::CreateServer(RServer2& aPolicyServerHandle)
    1.42 +	{
    1.43 +	TServerStart start(aPolicyServerHandle);
    1.44 +	TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
    1.45 +	RThread server;
    1.46 +	TInt err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
    1.47 +							KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
    1.48 +							&start, EOwnerProcess);
    1.49 +	if(err != KErrNone)
    1.50 +		{
    1.51 +		return err;
    1.52 +		}		
    1.53 +		// Synchronise with the server
    1.54 +	TRequestStatus reqStatus;
    1.55 +	server.Rendezvous(reqStatus);
    1.56 +	if (reqStatus!=KRequestPending)
    1.57 +		{
    1.58 +		server.Kill(0);
    1.59 +		}
    1.60 +	else 
    1.61 +		{
    1.62 +		// Start the test harness
    1.63 +		server.Resume();
    1.64 +		// Server will call the reciprocal static synchronise call
    1.65 +		}
    1.66 +	User::WaitForRequest(reqStatus); // wait for start or death
    1.67 +	server.Close();
    1.68 +	if(reqStatus.Int() != KErrNone)
    1.69 +		{
    1.70 +		return reqStatus.Int();
    1.71 +		}
    1.72 +	return err;		
    1.73 +	}
    1.74 +
    1.75 +EXPORT_C TInt RMMFAudioPolicyProxy::SetDevSoundInfo(TMMFDevSoundInfo& aDevSoundInfo)
    1.76 +	{
    1.77 +	TMMFDevSoundInfoPckg psPckg(aDevSoundInfo);
    1.78 +	return SendReceive(EMMFPolicySetDevSoundInfo, psPckg);
    1.79 +	}
    1.80 +
    1.81 +EXPORT_C void RMMFAudioPolicyProxy::MakeRequest(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
    1.82 +	{
    1.83 +	iPsPckg().iState = aPrioritySettings.iState;
    1.84 +	iPsPckg().iPref = aPrioritySettings.iPref;
    1.85 +	iPsPckg().iPriority = aPrioritySettings.iPriority;
    1.86 +	iPsPckg().iCapabilities = aPrioritySettings.iCapabilities;
    1.87 +	SendReceive(EMMFPolicyMakeRequest, iPsPckg);
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C TInt RMMFAudioPolicyProxy::UpdateState(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
    1.91 +	{
    1.92 +	TMMFAudioPolicyPrioritySettingsPckg psPckg(aPrioritySettings);
    1.93 +	return SendReceive(EMMFPolicyUpdateState, psPckg);
    1.94 +	}
    1.95 +
    1.96 +EXPORT_C void RMMFAudioPolicyProxy::ReceiveEvents(TMMFAudioPolicyEventPckg& aEventPckg, TRequestStatus& aStatus)
    1.97 +	{
    1.98 +	SendReceiveResult(EMMFPolicyReceiveEvents, aEventPckg, aStatus);
    1.99 +	}
   1.100 +
   1.101 +EXPORT_C TInt RMMFAudioPolicyProxy::CancelReceiveEvents()
   1.102 +	{
   1.103 +	return SendReceive(EMMFPolicyCancelReceiveEvents);
   1.104 +	}
   1.105 +
   1.106 +EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aPlayFormatsSupported) 
   1.107 +	{
   1.108 +	RMdaDevSound::TSoundFormatsSupportedBuf playFormatsSupported;
   1.109 +	TInt err = SendReceiveResult(EMMFPolicyGetPlayFormatsSupported, playFormatsSupported);
   1.110 +	if (!err)
   1.111 +		aPlayFormatsSupported = playFormatsSupported;
   1.112 +	return  err;
   1.113 +	}
   1.114 +
   1.115 +EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aRecordFormatsSupported) 
   1.116 +	{
   1.117 +	RMdaDevSound::TSoundFormatsSupportedBuf recordFormatsSupported;
   1.118 +	TInt err = SendReceiveResult(EMMFPolicyGetRecordFormatsSupported, recordFormatsSupported);
   1.119 +	if (!err)
   1.120 +		aRecordFormatsSupported = recordFormatsSupported;
   1.121 +	return  err;
   1.122 +	}
   1.123 +
   1.124 +EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormat(RMdaDevSound::TCurrentSoundFormatBuf& aPlayFormat) 
   1.125 +	{
   1.126 +	RMdaDevSound::TCurrentSoundFormatBuf playFormat;
   1.127 +	TInt err = SendReceiveResult(EMMFPolicyGetPlayFormat, playFormat);
   1.128 +	if (!err)
   1.129 +		aPlayFormat = playFormat;
   1.130 +	return  err;
   1.131 +	}
   1.132 +
   1.133 +EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormat(RMdaDevSound::TCurrentSoundFormatBuf& aRecordFormat) 
   1.134 +	{
   1.135 +	RMdaDevSound::TCurrentSoundFormatBuf recordFormat;
   1.136 +	TInt err = SendReceiveResult(EMMFPolicyGetRecordFormat, recordFormat);
   1.137 +	if (!err)
   1.138 +		aRecordFormat = recordFormat;
   1.139 +	return  err;
   1.140 +	}
   1.141 +
   1.142 +EXPORT_C TInt RMMFAudioPolicyProxy::LaunchRequests()
   1.143 +	{
   1.144 +	return SendReceive(EMMFPolicyLaunchRequests);
   1.145 +	}
   1.146 +
   1.147 +EXPORT_C TInt RMMFAudioPolicyProxy::RequestResourceNotification(TUid aNotificationEventUid, const TDesC8& aNotificationDelay)
   1.148 +	{
   1.149 +	TUid eventType = KNullUid;
   1.150 +	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
   1.151 +	pckg().iNotificationUid = eventType;
   1.152 +	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
   1.153 +	eventType = pckg().iNotificationUid;
   1.154 +	if(!err)
   1.155 +		{
   1.156 +		if(eventType != aNotificationEventUid )
   1.157 +			{
   1.158 +			pckg().iNotificationUid = aNotificationEventUid;
   1.159 +			pckg().iNotificationDelay = aNotificationDelay;
   1.160 +			return SendReceive(EMMFPolicyRequestResourceNotification, pckg);		
   1.161 +			}
   1.162 +		else
   1.163 +			{
   1.164 +			return KErrAlreadyExists;
   1.165 +			}
   1.166 +		}
   1.167 +	return err;	
   1.168 +	}
   1.169 +	
   1.170 +EXPORT_C TInt RMMFAudioPolicyProxy::CancelRequestResourceNotification(TUid aNotificationEventUid)
   1.171 +	{
   1.172 +	TUid eventType = KNullUid;
   1.173 +	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
   1.174 +	pckg().iNotificationUid = eventType;
   1.175 +	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
   1.176 +	eventType = pckg().iNotificationUid;
   1.177 +	if(!err)
   1.178 +		{
   1.179 +		if(eventType == aNotificationEventUid )
   1.180 +			{
   1.181 +			pckg().iNotificationUid = aNotificationEventUid;
   1.182 +			return SendReceive(EMMFPolicyCancelRequestResourceNotification, pckg);	
   1.183 +			}
   1.184 +		else
   1.185 +			{
   1.186 +			return KErrCancel;
   1.187 +			}
   1.188 +		}
   1.189 +	return err;
   1.190 +	}
   1.191 +	
   1.192 +EXPORT_C TInt RMMFAudioPolicyProxy::StopNotification()
   1.193 +	{
   1.194 +	return SendReceive(EMMFPolicyStopNotification);
   1.195 +	}
   1.196 +
   1.197 +EXPORT_C TInt RMMFAudioPolicyProxy::IsRegisteredResourceNotification(TUid aEventType)
   1.198 +	{
   1.199 +	TUid eventType = KNullUid;
   1.200 +	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
   1.201 +	pckg().iNotificationUid = eventType;
   1.202 +	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
   1.203 +	if(err != KErrNone)
   1.204 +		{
   1.205 +		return err;
   1.206 +		}
   1.207 +	eventType = pckg().iNotificationUid;
   1.208 +	if(eventType == aEventType)
   1.209 +		{
   1.210 +		return KErrNone;
   1.211 +		}
   1.212 +	return KErrNotSupported;
   1.213 +	}
   1.214 +