os/mm/devsound/devsoundrefplugin/src/server/Policy/MmfAudioPolicyProxy.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <f32file.h>
sl@0
    17
#include <e32math.h>
sl@0
    18
#include "mmfAudioPolicyProxy.h"
sl@0
    19
#include "MmfAudioPolicyStart.h"
sl@0
    20
#include "MmfBase.hrh"
sl@0
    21
#include "MmfDevSoundInfo.h"
sl@0
    22
#include "MmfAudioPolicyServer.h"
sl@0
    23
sl@0
    24
sl@0
    25
sl@0
    26
EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
sl@0
    27
	{
sl@0
    28
	ASSERT(aPolicyServerHandle.Handle());
sl@0
    29
	
sl@0
    30
	// Server is already running and attempt to create a session
sl@0
    31
	// 4 message slots
sl@0
    32
	TInt err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
sl@0
    33
													KMMFAudioPolicyMinorVersionNumber,
sl@0
    34
													KMMFAudioPolicyBuildVersionNumber));		
sl@0
    35
	return err;		
sl@0
    36
	}
sl@0
    37
sl@0
    38
EXPORT_C TInt RMMFAudioPolicyProxy::CreateServer(RServer2& aPolicyServerHandle)
sl@0
    39
	{
sl@0
    40
	TServerStart start(aPolicyServerHandle);
sl@0
    41
	TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
sl@0
    42
	RThread server;
sl@0
    43
	TInt err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
sl@0
    44
							KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
sl@0
    45
							&start, EOwnerProcess);
sl@0
    46
	if(err != KErrNone)
sl@0
    47
		{
sl@0
    48
		return err;
sl@0
    49
		}		
sl@0
    50
		// Synchronise with the server
sl@0
    51
	TRequestStatus reqStatus;
sl@0
    52
	server.Rendezvous(reqStatus);
sl@0
    53
	if (reqStatus!=KRequestPending)
sl@0
    54
		{
sl@0
    55
		server.Kill(0);
sl@0
    56
		}
sl@0
    57
	else 
sl@0
    58
		{
sl@0
    59
		// Start the test harness
sl@0
    60
		server.Resume();
sl@0
    61
		// Server will call the reciprocal static synchronise call
sl@0
    62
		}
sl@0
    63
	User::WaitForRequest(reqStatus); // wait for start or death
sl@0
    64
	server.Close();
sl@0
    65
	if(reqStatus.Int() != KErrNone)
sl@0
    66
		{
sl@0
    67
		return reqStatus.Int();
sl@0
    68
		}
sl@0
    69
	return err;		
sl@0
    70
	}
sl@0
    71
sl@0
    72
EXPORT_C TInt RMMFAudioPolicyProxy::SetDevSoundInfo(TMMFDevSoundInfo& aDevSoundInfo)
sl@0
    73
	{
sl@0
    74
	TMMFDevSoundInfoPckg psPckg(aDevSoundInfo);
sl@0
    75
	return SendReceive(EMMFPolicySetDevSoundInfo, psPckg);
sl@0
    76
	}
sl@0
    77
sl@0
    78
EXPORT_C void RMMFAudioPolicyProxy::MakeRequest(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
sl@0
    79
	{
sl@0
    80
	iPsPckg().iState = aPrioritySettings.iState;
sl@0
    81
	iPsPckg().iPref = aPrioritySettings.iPref;
sl@0
    82
	iPsPckg().iPriority = aPrioritySettings.iPriority;
sl@0
    83
	iPsPckg().iCapabilities = aPrioritySettings.iCapabilities;
sl@0
    84
	SendReceive(EMMFPolicyMakeRequest, iPsPckg);
sl@0
    85
	}
sl@0
    86
sl@0
    87
EXPORT_C TInt RMMFAudioPolicyProxy::UpdateState(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
sl@0
    88
	{
sl@0
    89
	TMMFAudioPolicyPrioritySettingsPckg psPckg(aPrioritySettings);
sl@0
    90
	return SendReceive(EMMFPolicyUpdateState, psPckg);
sl@0
    91
	}
sl@0
    92
sl@0
    93
EXPORT_C void RMMFAudioPolicyProxy::ReceiveEvents(TMMFAudioPolicyEventPckg& aEventPckg, TRequestStatus& aStatus)
sl@0
    94
	{
sl@0
    95
	SendReceiveResult(EMMFPolicyReceiveEvents, aEventPckg, aStatus);
sl@0
    96
	}
sl@0
    97
sl@0
    98
EXPORT_C TInt RMMFAudioPolicyProxy::CancelReceiveEvents()
sl@0
    99
	{
sl@0
   100
	return SendReceive(EMMFPolicyCancelReceiveEvents);
sl@0
   101
	}
sl@0
   102
sl@0
   103
EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aPlayFormatsSupported) 
sl@0
   104
	{
sl@0
   105
	RMdaDevSound::TSoundFormatsSupportedBuf playFormatsSupported;
sl@0
   106
	TInt err = SendReceiveResult(EMMFPolicyGetPlayFormatsSupported, playFormatsSupported);
sl@0
   107
	if (!err)
sl@0
   108
		aPlayFormatsSupported = playFormatsSupported;
sl@0
   109
	return  err;
sl@0
   110
	}
sl@0
   111
sl@0
   112
EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aRecordFormatsSupported) 
sl@0
   113
	{
sl@0
   114
	RMdaDevSound::TSoundFormatsSupportedBuf recordFormatsSupported;
sl@0
   115
	TInt err = SendReceiveResult(EMMFPolicyGetRecordFormatsSupported, recordFormatsSupported);
sl@0
   116
	if (!err)
sl@0
   117
		aRecordFormatsSupported = recordFormatsSupported;
sl@0
   118
	return  err;
sl@0
   119
	}
sl@0
   120
sl@0
   121
EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormat(RMdaDevSound::TCurrentSoundFormatBuf& aPlayFormat) 
sl@0
   122
	{
sl@0
   123
	RMdaDevSound::TCurrentSoundFormatBuf playFormat;
sl@0
   124
	TInt err = SendReceiveResult(EMMFPolicyGetPlayFormat, playFormat);
sl@0
   125
	if (!err)
sl@0
   126
		aPlayFormat = playFormat;
sl@0
   127
	return  err;
sl@0
   128
	}
sl@0
   129
sl@0
   130
EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormat(RMdaDevSound::TCurrentSoundFormatBuf& aRecordFormat) 
sl@0
   131
	{
sl@0
   132
	RMdaDevSound::TCurrentSoundFormatBuf recordFormat;
sl@0
   133
	TInt err = SendReceiveResult(EMMFPolicyGetRecordFormat, recordFormat);
sl@0
   134
	if (!err)
sl@0
   135
		aRecordFormat = recordFormat;
sl@0
   136
	return  err;
sl@0
   137
	}
sl@0
   138
sl@0
   139
EXPORT_C TInt RMMFAudioPolicyProxy::LaunchRequests()
sl@0
   140
	{
sl@0
   141
	return SendReceive(EMMFPolicyLaunchRequests);
sl@0
   142
	}
sl@0
   143
sl@0
   144
EXPORT_C TInt RMMFAudioPolicyProxy::RequestResourceNotification(TUid aNotificationEventUid, const TDesC8& aNotificationDelay)
sl@0
   145
	{
sl@0
   146
	TUid eventType = KNullUid;
sl@0
   147
	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
sl@0
   148
	pckg().iNotificationUid = eventType;
sl@0
   149
	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
sl@0
   150
	eventType = pckg().iNotificationUid;
sl@0
   151
	if(!err)
sl@0
   152
		{
sl@0
   153
		if(eventType != aNotificationEventUid )
sl@0
   154
			{
sl@0
   155
			pckg().iNotificationUid = aNotificationEventUid;
sl@0
   156
			pckg().iNotificationDelay = aNotificationDelay;
sl@0
   157
			return SendReceive(EMMFPolicyRequestResourceNotification, pckg);		
sl@0
   158
			}
sl@0
   159
		else
sl@0
   160
			{
sl@0
   161
			return KErrAlreadyExists;
sl@0
   162
			}
sl@0
   163
		}
sl@0
   164
	return err;	
sl@0
   165
	}
sl@0
   166
	
sl@0
   167
EXPORT_C TInt RMMFAudioPolicyProxy::CancelRequestResourceNotification(TUid aNotificationEventUid)
sl@0
   168
	{
sl@0
   169
	TUid eventType = KNullUid;
sl@0
   170
	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
sl@0
   171
	pckg().iNotificationUid = eventType;
sl@0
   172
	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
sl@0
   173
	eventType = pckg().iNotificationUid;
sl@0
   174
	if(!err)
sl@0
   175
		{
sl@0
   176
		if(eventType == aNotificationEventUid )
sl@0
   177
			{
sl@0
   178
			pckg().iNotificationUid = aNotificationEventUid;
sl@0
   179
			return SendReceive(EMMFPolicyCancelRequestResourceNotification, pckg);	
sl@0
   180
			}
sl@0
   181
		else
sl@0
   182
			{
sl@0
   183
			return KErrCancel;
sl@0
   184
			}
sl@0
   185
		}
sl@0
   186
	return err;
sl@0
   187
	}
sl@0
   188
	
sl@0
   189
EXPORT_C TInt RMMFAudioPolicyProxy::StopNotification()
sl@0
   190
	{
sl@0
   191
	return SendReceive(EMMFPolicyStopNotification);
sl@0
   192
	}
sl@0
   193
sl@0
   194
EXPORT_C TInt RMMFAudioPolicyProxy::IsRegisteredResourceNotification(TUid aEventType)
sl@0
   195
	{
sl@0
   196
	TUid eventType = KNullUid;
sl@0
   197
	TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
sl@0
   198
	pckg().iNotificationUid = eventType;
sl@0
   199
	TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
sl@0
   200
	if(err != KErrNone)
sl@0
   201
		{
sl@0
   202
		return err;
sl@0
   203
		}
sl@0
   204
	eventType = pckg().iNotificationUid;
sl@0
   205
	if(eventType == aEventType)
sl@0
   206
		{
sl@0
   207
		return KErrNone;
sl@0
   208
		}
sl@0
   209
	return KErrNotSupported;
sl@0
   210
	}
sl@0
   211