1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/a3fdevsound/src/mmfdevsoundproxy/mmfdevsoundproxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1618 @@
1.4 +// Copyright (c) 2006-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 +
1.20 +
1.21 +// INCLUDE FILES
1.22 +#include "mmfdevsoundproxy.h"
1.23 +#ifdef _DEBUG
1.24 +#include <e32debug.h>
1.25 +
1.26 +#define SYMBIAN_DEBPRN0(str) RDebug::Print(str, this)
1.27 +#define SYMBIAN_DEBPRN1(str, val1) RDebug::Print(str, this, val1)
1.28 +#define SYMBIAN_DEBPRN2(str, val1, val2) RDebug::Print(str, this, val1, val2)
1.29 +#else
1.30 +#define SYMBIAN_DEBPRN0(str)
1.31 +#define SYMBIAN_DEBPRN1(str, val1)
1.32 +#define SYMBIAN_DEBPRN2(str, val1, val2)
1.33 +#endif //_DEBUG
1.34 +
1.35 +// SYMBIAN_CHECK used to add extra asserts when MACRO is added - helps debugging overall A3F
1.36 +
1.37 +#ifdef SYMBIAN_FULL_STATE_CHECK
1.38 + #define SYMBIAN_CHECK(c,p) __ASSERT_ALWAYS(c,p)
1.39 +#else
1.40 + #define SYMBIAN_CHECK(c,p)
1.41 +#endif
1.42 +
1.43 +const TInt KMaxMessageQueueItems = 8;
1.44 +
1.45 +const TMMFCapabilities KZeroCapabilities =
1.46 + {
1.47 + 0,0,0,0 // all zero's
1.48 + };
1.49 +
1.50 +// ============================ LOCAL FUNCTIONS ================================
1.51 +
1.52 +// -----------------------------------------------------------------------------
1.53 +// This function raises a panic
1.54 +//
1.55 +// @param aError
1.56 +// one of the several panic codes that may be raised by this dll
1.57 +//
1.58 +// @panic EMMFDevSoundProxyPlayDataWithoutInitialize is raised when playdata
1.59 +// is called without initialization
1.60 +// @panic EMMFDevSoundProxyRecordDataWithoutInitialize is raised when
1.61 +// recorddata is called without initialization
1.62 +//
1.63 +GLDEF_C void Panic(TMMFDevSoundProxyPanicCodes aPanicCode)
1.64 + {
1.65 + User::Panic(KMMFDevSoundProxyPanicCategory, aPanicCode);
1.66 + }
1.67 +
1.68 +// ============================ MEMBER FUNCTIONS ===============================
1.69 +
1.70 +// -----------------------------------------------------------------------------
1.71 +// RMMFDevsoundProxy::RMMFDevsoundProxy
1.72 +// C++ default constructor can NOT contain any code, that
1.73 +// might leave.
1.74 +// -----------------------------------------------------------------------------
1.75 +//
1.76 +EXPORT_C RMMFDevSoundProxy::RMMFDevSoundProxy() :
1.77 + iBuffer(NULL),
1.78 + iSeqName(NULL),
1.79 + iDestinationPckg(TMMFMessageDestination(KUidInterfaceMMFDevSound,
1.80 + KMMFObjectHandleDevSound)),
1.81 + iState(EIdle),
1.82 + iAudioServerProxy(NULL),
1.83 + iDevSoundObserver(NULL),
1.84 + iMsgQueueHandler(NULL),
1.85 + iCustIntPckg()
1.86 + {
1.87 + }
1.88 +
1.89 +// -----------------------------------------------------------------------------
1.90 +// RMMFDevSoundProxy::Close
1.91 +// Close the server session
1.92 +// (other items were commented in a header).
1.93 +// -----------------------------------------------------------------------------
1.94 +//
1.95 +EXPORT_C void RMMFDevSoundProxy::Close()
1.96 + {
1.97 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Close - Enter"));
1.98 + if (iAudioServerProxy)
1.99 + {
1.100 + if (iAudioServerProxy->Handle() != NULL)
1.101 + {
1.102 + TMMFDevSoundProxySettings set;
1.103 + TMMFDevSoundProxySettingsPckg pckg(set);
1.104 + TInt err = SendReceive(EMMFDevSoundProxyClose,
1.105 + iDestinationPckg,
1.106 + pckg);
1.107 + }
1.108 + iAudioServerProxy->Close();
1.109 + delete iAudioServerProxy;
1.110 + iAudioServerProxy = NULL;
1.111 + }
1.112 + RMmfSessionBase::Close();
1.113 + iState = EIdle;
1.114 + if (iMsgQueueHandler)
1.115 + {
1.116 + iMsgQueueHandler->Cancel();
1.117 + delete iMsgQueueHandler;
1.118 + iMsgQueueHandler = NULL;
1.119 + }
1.120 + iMsgQueue.Close();
1.121 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Close - Exit"));
1.122 + }
1.123 +
1.124 +// -----------------------------------------------------------------------------
1.125 +// RMMFDevSoundProxy::Open
1.126 +// Open a DevSound server session
1.127 +// (other items were commented in a header).
1.128 +// -----------------------------------------------------------------------------
1.129 +//
1.130 +EXPORT_C TInt RMMFDevSoundProxy::Open()
1.131 + {
1.132 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Open - Enter"));
1.133 + TInt err = iMsgQueue.CreateGlobal(KNullDesC, KMaxMessageQueueItems, EOwnerThread);
1.134 + // global, accessible to all that have its handle
1.135 +
1.136 + if (err == KErrNone)
1.137 + {
1.138 + iAudioServerProxy = NULL;
1.139 + iMsgQueueHandler = NULL;
1.140 + iBuffer = NULL;
1.141 + iAudioServerProxy = new RMMFAudioServerProxy();
1.142 + if (iAudioServerProxy == NULL)
1.143 + {
1.144 + err = KErrNoMemory;
1.145 + }
1.146 + }
1.147 + if (err == KErrNone)
1.148 + {
1.149 + err = iAudioServerProxy->Open();
1.150 + }
1.151 + if (err == KErrNone)
1.152 + {
1.153 + err = SetReturnedHandle(iAudioServerProxy->GetDevSoundSessionHandle());
1.154 + }
1.155 + if (err)
1.156 + {
1.157 + Close();
1.158 + }
1.159 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Open - Exit [%d]"), err);
1.160 + return err;
1.161 + }
1.162 +
1.163 +// -----------------------------------------------------------------------------
1.164 +// RMMFDevSoundProxy::PostOpen
1.165 +// Finish opening process
1.166 +// -----------------------------------------------------------------------------
1.167 +//
1.168 +EXPORT_C TInt RMMFDevSoundProxy::PostOpen()
1.169 + {
1.170 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PostOpen - Enter"));
1.171 + TInt err = SendReceive(EMMFDevSoundProxyPostOpen, iDestinationPckg);
1.172 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::PostOpen - Exit [%d]"), err);
1.173 + return err;
1.174 + }
1.175 +
1.176 +
1.177 +// -----------------------------------------------------------------------------
1.178 +// RMMFDevSoundProxy::SetDevSoundInfo
1.179 +// Launch DevSound that might have been waiting for audio policy.
1.180 +// (other items were commented in a header).
1.181 +// -----------------------------------------------------------------------------
1.182 +//
1.183 +EXPORT_C TInt RMMFDevSoundProxy::SetDevSoundInfo()
1.184 + {
1.185 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDevSoundInfo - Enter"));
1.186 + TInt err = SendReceive(EMMFAudioLaunchRequests);
1.187 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetDevSoundInfo - Exit [%d]"), err);
1.188 + return err;
1.189 + }
1.190 +
1.191 +// -----------------------------------------------------------------------------
1.192 +// RMMFDevSoundProxy::InitializeL
1.193 +// Initialize DevSound for a specific mode.
1.194 +// (other items were commented in a header).
1.195 +// -----------------------------------------------------------------------------
1.196 +//
1.197 +EXPORT_C void RMMFDevSoundProxy::InitializeL(
1.198 + MDevSoundObserver& aDevSoundObserver,
1.199 + TMMFState aMode,
1.200 + MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
1.201 + {
1.202 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Enter"));
1.203 + TInt err = KErrNone;
1.204 + iDevSoundObserver = &aDevSoundObserver;
1.205 +
1.206 + if (!(iState==EIdle || iState==EInitialized))
1.207 + {
1.208 + err = KErrNotReady;
1.209 + }
1.210 + else
1.211 + {
1.212 + TMMFDevSoundProxySettings set;
1.213 + set.iMode = aMode;
1.214 + TMMFDevSoundProxySettingsPckg pckg(set);
1.215 + TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue);
1.216 + err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize1, args);
1.217 + if (err == KErrNone)
1.218 + {
1.219 + StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver);
1.220 + iState = EInitializing;
1.221 + }
1.222 + }
1.223 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Exit [%d]"), err);
1.224 + User::LeaveIfError(err);
1.225 + }
1.226 +
1.227 +// -----------------------------------------------------------------------------
1.228 +// RMMFDevSoundProxy::InitializeL
1.229 +// Initialize DevSound with specific HwDevice id and mode.
1.230 +// (other items were commented in a header).
1.231 +// -----------------------------------------------------------------------------
1.232 +//
1.233 +EXPORT_C void RMMFDevSoundProxy::InitializeL(
1.234 + MDevSoundObserver& /*aDevSoundObserver*/,
1.235 + TUid /*aHWDev*/,
1.236 + TMMFState /*aMode*/,
1.237 + MMMFDevSoundCustomInterfaceObserver& /*aDevSoundCIObserver*/)
1.238 + {
1.239 + TInt err = KErrNotSupported;
1.240 + User::LeaveIfError(err);
1.241 + }
1.242 +
1.243 +// -----------------------------------------------------------------------------
1.244 +// RMMFDevSoundProxy::InitializeL
1.245 +// Initialize DevSound for the specific FourCC and mode.
1.246 +// (other items were commented in a header).
1.247 +// -----------------------------------------------------------------------------
1.248 +//
1.249 +EXPORT_C void RMMFDevSoundProxy::InitializeL(
1.250 + MDevSoundObserver& aDevSoundObserver,
1.251 + TFourCC aDesiredFourCC,
1.252 + TMMFState aMode,
1.253 + MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
1.254 + {
1.255 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Enter"));
1.256 + TInt err = KErrNone;
1.257 + if(aMode == EMMFStateTonePlaying)
1.258 + {
1.259 + User::Leave(KErrNotSupported);
1.260 + }
1.261 + iDevSoundObserver = &aDevSoundObserver;
1.262 + if (!(iState==EIdle || iState==EInitialized))
1.263 + {
1.264 + err = KErrNotReady;
1.265 + }
1.266 + else
1.267 + {
1.268 + TMMFDevSoundProxySettings set;
1.269 + set.iDesiredFourCC = aDesiredFourCC;
1.270 + set.iMode = aMode;
1.271 + TMMFDevSoundProxySettingsPckg pckg(set);
1.272 + TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue);
1.273 + err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize4, args);
1.274 + if (err == KErrNone)
1.275 + {
1.276 + StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver);
1.277 + iState = EInitializing;
1.278 + }
1.279 + }
1.280 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Exit [%d]"), err);
1.281 + User::LeaveIfError(err);
1.282 + }
1.283 +
1.284 +// -----------------------------------------------------------------------------
1.285 +// RMMFDevSoundProxy::Capabilities
1.286 +// Returns the capabilities of the DevSound server.
1.287 +// (other items were commented in a header).
1.288 +// -----------------------------------------------------------------------------
1.289 +//
1.290 +EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Capabilities()
1.291 + {
1.292 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Enter"));
1.293 + // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyCapabilitiesInWrongState));
1.294 + if (iState < EInitialized)
1.295 + {
1.296 + // call has been made before we are initialized. Not much we can do, so return
1.297 + // dummy values but hit debugger on the emulator
1.298 + __DEBUGGER()
1.299 + RDebug::Print(_L("BRDBG:CapabilitiesCalledWhenNotInitialised")); // TODO Remove or redo as trace
1.300 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit"));
1.301 + return KZeroCapabilities;
1.302 + }
1.303 + TMMFDevSoundProxySettings set;
1.304 + TMMFDevSoundProxySettingsPckg pckg(set);
1.305 + TInt err = SendReceiveResult(EMMFDevSoundProxyCapabilities,
1.306 + iDestinationPckg,
1.307 + KNullDesC8,
1.308 + pckg);
1.309 + if (err == KErrNone)
1.310 + {
1.311 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit"));
1.312 + return pckg().iCaps;
1.313 + }
1.314 + else
1.315 + {
1.316 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit [%d]"), err);
1.317 + return KZeroCapabilities;
1.318 + }
1.319 + }
1.320 +
1.321 +// -----------------------------------------------------------------------------
1.322 +// TMMFCapabilities RMMFDevSoundProxy::Config
1.323 +// Returns the current configuration of the DevSound.
1.324 +// (other items were commented in a header).
1.325 +// -----------------------------------------------------------------------------
1.326 +//
1.327 +EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Config()
1.328 + {
1.329 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Enter"));
1.330 + // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyConfigInWrongState));
1.331 + if (iState < EInitialized)
1.332 + {
1.333 + // call has been made before we are initialized. Not much we can do, so return
1.334 + // dummy values but hit debugger on the emulator
1.335 + __DEBUGGER()
1.336 + RDebug::Print(_L("BRDBG:ConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace
1.337 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Exit"));
1.338 + return KZeroCapabilities;
1.339 + }
1.340 + TMMFDevSoundProxySettings set;
1.341 + TMMFDevSoundProxySettingsPckg pckg(set);
1.342 + SendReceiveResult(EMMFDevSoundProxyConfig,
1.343 + iDestinationPckg,
1.344 + KNullDesC8,
1.345 + pckg);
1.346 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Exit"));
1.347 + return pckg().iConfig;
1.348 + }
1.349 +
1.350 +// -----------------------------------------------------------------------------
1.351 +// RMMFDevSoundProxy::SetConfigL
1.352 +// Configures the DevSound server.
1.353 +// (other items were commented in a header).
1.354 +// -----------------------------------------------------------------------------
1.355 +//
1.356 +EXPORT_C void RMMFDevSoundProxy::SetConfigL(
1.357 + const TMMFCapabilities& aConfig )
1.358 + {
1.359 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetConfigL - Enter"));
1.360 + TInt err = KErrNone;
1.361 +
1.362 + if (iState==EInitialized)
1.363 + {
1.364 + TMMFDevSoundProxySettings set;
1.365 + set.iConfig = aConfig;
1.366 + TMMFDevSoundProxySettingsPckg pckg(set);
1.367 + err = SendReceive(EMMFDevSoundProxySetConfig,
1.368 + iDestinationPckg,
1.369 + pckg);
1.370 + }
1.371 + else
1.372 + {
1.373 + RDebug::Print(_L("BRDBG:SetConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace
1.374 + err = KErrNotReady;
1.375 + }
1.376 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetConfigL - Exit [%d]"), err);
1.377 + User::LeaveIfError(err);
1.378 + }
1.379 +
1.380 +// -----------------------------------------------------------------------------
1.381 +// RMMFDevSoundProxy::MaxVolume
1.382 +// Returns the maximum volume supported by DevSound server for playing back..
1.383 +// (other items were commented in a header).
1.384 +// -----------------------------------------------------------------------------
1.385 +//
1.386 +EXPORT_C TInt RMMFDevSoundProxy::MaxVolume()
1.387 + {
1.388 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxVolume - Enter"));
1.389 + TMMFDevSoundProxySettings set;
1.390 + TMMFDevSoundProxySettingsPckg pckg(set);
1.391 + SendReceiveResult(EMMFDevSoundProxyMaxVolume,
1.392 + iDestinationPckg,
1.393 + KNullDesC8,
1.394 + pckg);
1.395 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxVolume - Exit"));
1.396 + return pckg().iMaxVolume;
1.397 + }
1.398 +
1.399 +// -----------------------------------------------------------------------------
1.400 +// RMMFDevSoundProxy::Volume
1.401 +// Returns the current volume.
1.402 +// (other items were commented in a header).
1.403 +// -----------------------------------------------------------------------------
1.404 +//
1.405 +EXPORT_C TInt RMMFDevSoundProxy::Volume()
1.406 + {
1.407 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Volume - Enter"));
1.408 + TMMFDevSoundProxySettings set;
1.409 + TMMFDevSoundProxySettingsPckg pckg(set);
1.410 + SendReceiveResult(EMMFDevSoundProxyVolume,
1.411 + iDestinationPckg,
1.412 + KNullDesC8,
1.413 + pckg);
1.414 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Volume - Exit"));
1.415 + return pckg().iVolume;
1.416 + }
1.417 +
1.418 +// -----------------------------------------------------------------------------
1.419 +// RMMFDevSoundProxy::SetVolume
1.420 +// Sets the current volume.
1.421 +// (other items were commented in a header).
1.422 +// -----------------------------------------------------------------------------
1.423 +//
1.424 +EXPORT_C TInt RMMFDevSoundProxy::SetVolume(TInt aVolume )
1.425 + {
1.426 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolume - Enter"));
1.427 + TMMFDevSoundProxySettings set;
1.428 + set.iVolume = aVolume;
1.429 + TMMFDevSoundProxySettingsPckg pckg(set);
1.430 + TInt err = SendReceive(EMMFDevSoundProxySetVolume,
1.431 + iDestinationPckg,
1.432 + pckg);
1.433 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetVolume - Exit [%d]"), err);
1.434 + return err;
1.435 + }
1.436 +
1.437 +// -----------------------------------------------------------------------------
1.438 +// RMMFDevSoundProxy::MaxGain
1.439 +// Returns maximum gain supported by DevSound server for recording.
1.440 +// (other items were commented in a header).
1.441 +// -----------------------------------------------------------------------------
1.442 +//
1.443 +EXPORT_C TInt RMMFDevSoundProxy::MaxGain()
1.444 + {
1.445 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxGain - Enter"));
1.446 + TMMFDevSoundProxySettings set;
1.447 + TMMFDevSoundProxySettingsPckg pckg(set);
1.448 + SendReceiveResult(EMMFDevSoundProxyMaxGain,
1.449 + iDestinationPckg,
1.450 + KNullDesC8,
1.451 + pckg);
1.452 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxGain - Exit"));
1.453 + return pckg().iMaxGain;
1.454 + }
1.455 +
1.456 +// -----------------------------------------------------------------------------
1.457 +// RMMFDevSoundProxy::Gain
1.458 +// Returns the current gain.
1.459 +// (other items were commented in a header).
1.460 +// -----------------------------------------------------------------------------
1.461 +//
1.462 +EXPORT_C TInt RMMFDevSoundProxy::Gain()
1.463 + {
1.464 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Gain - Enter"));
1.465 + TMMFDevSoundProxySettings set;
1.466 + TMMFDevSoundProxySettingsPckg pckg(set);
1.467 + SendReceiveResult(EMMFDevSoundProxyGain,
1.468 + iDestinationPckg,
1.469 + KNullDesC8,
1.470 + pckg);
1.471 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Gain - Exit"));
1.472 + return pckg().iGain;
1.473 + }
1.474 +
1.475 +// -----------------------------------------------------------------------------
1.476 +// RMMFDevSoundProxy::SetGain
1.477 +// Sets the current gain.
1.478 +// (other items were commented in a header).
1.479 +// -----------------------------------------------------------------------------
1.480 +//
1.481 +EXPORT_C TInt RMMFDevSoundProxy::SetGain(
1.482 + TInt aGain )
1.483 + {
1.484 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetGain - Enter"));
1.485 + TMMFDevSoundProxySettings set;
1.486 + set.iGain = aGain;
1.487 + TMMFDevSoundProxySettingsPckg pckg(set);
1.488 +
1.489 + TInt err = SendReceive(EMMFDevSoundProxySetGain,
1.490 + iDestinationPckg,
1.491 + pckg);
1.492 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetGain - Exit [%d]"), err);
1.493 + return err;
1.494 + }
1.495 +
1.496 +// -----------------------------------------------------------------------------
1.497 +// RMMFDevSoundProxy::GetPlayBalanceL
1.498 +// Returns play balance.
1.499 +// (other items were commented in a header).
1.500 +// -----------------------------------------------------------------------------
1.501 +//
1.502 +EXPORT_C void RMMFDevSoundProxy::GetPlayBalanceL(
1.503 + TInt& aLeftPercentage,
1.504 + TInt& aRightPercentage )
1.505 + {
1.506 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetPlayBalanceL - Enter"));
1.507 + TMMFDevSoundProxySettings set;
1.508 + TMMFDevSoundProxySettingsPckg pckg(set);
1.509 + User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayBalance,
1.510 + iDestinationPckg,
1.511 + KNullDesC8,
1.512 + pckg));
1.513 + aLeftPercentage = pckg().iLeftPercentage;
1.514 + aRightPercentage = pckg().iRightPercentage;
1.515 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetPlayBalanceL - Exit"));
1.516 + }
1.517 +
1.518 +// -----------------------------------------------------------------------------
1.519 +// RMMFDevSoundProxy::SetPlayBalanceL
1.520 +// Sets playbalance.
1.521 +// (other items were commented in a header).
1.522 +// -----------------------------------------------------------------------------
1.523 +//
1.524 +EXPORT_C void RMMFDevSoundProxy::SetPlayBalanceL(
1.525 + TInt aLeftPercentage,
1.526 + TInt aRightPercentage )
1.527 + {
1.528 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPlayBalanceL - Enter"));
1.529 + TMMFDevSoundProxySettings set;
1.530 + set.iLeftPercentage = aLeftPercentage;
1.531 + set.iRightPercentage = aRightPercentage;
1.532 + TMMFDevSoundProxySettingsPckg pckg(set);
1.533 + User::LeaveIfError(SendReceive(EMMFDevSoundProxySetPlayBalance,
1.534 + iDestinationPckg,
1.535 + pckg));
1.536 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPlayBalanceL - Exit"));
1.537 + }
1.538 +
1.539 +// -----------------------------------------------------------------------------
1.540 +// RMMFDevSoundProxy::GetRecordBalanceL
1.541 +// Returns record balance.
1.542 +// (other items were commented in a header).
1.543 +// -----------------------------------------------------------------------------
1.544 +//
1.545 +EXPORT_C void RMMFDevSoundProxy::GetRecordBalanceL(
1.546 + TInt& aLeftPercentage,
1.547 + TInt& aRightPercentage )
1.548 + {
1.549 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetRecordBalanceL - Enter"));
1.550 + TMMFDevSoundProxySettings set;
1.551 + TMMFDevSoundProxySettingsPckg pckg(set);
1.552 + User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyRecordBalance,
1.553 + iDestinationPckg,
1.554 + KNullDesC8,
1.555 + pckg));
1.556 + aLeftPercentage = pckg().iLeftPercentage;
1.557 + aRightPercentage = pckg().iRightPercentage;
1.558 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetRecordBalanceL - Exit"));
1.559 + }
1.560 +
1.561 +// -----------------------------------------------------------------------------
1.562 +// RMMFDevSoundProxy::SetRecordBalanceL
1.563 +// Sets record balance.
1.564 +// (other items were commented in a header).
1.565 +// -----------------------------------------------------------------------------
1.566 +//
1.567 +EXPORT_C void RMMFDevSoundProxy::SetRecordBalanceL(
1.568 + TInt aLeftPercentage,
1.569 + TInt aRightPercentage )
1.570 + {
1.571 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetRecordBalanceL - Enter"));
1.572 + TMMFDevSoundProxySettings set;
1.573 + set.iLeftPercentage = aLeftPercentage;
1.574 + set.iRightPercentage = aRightPercentage;
1.575 + TMMFDevSoundProxySettingsPckg pckg(set);
1.576 + User::LeaveIfError(SendReceive(EMMFDevSoundProxySetRecordBalance,
1.577 + iDestinationPckg,
1.578 + pckg));
1.579 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetRecordBalanceL - Exit"));
1.580 + }
1.581 +
1.582 +// -----------------------------------------------------------------------------
1.583 +// RMMFDevSoundProxy::PlayInitL
1.584 +// Initilaizes DevSound to play digital audio and starts the play process.
1.585 +// (other items were commented in a header).
1.586 +// -----------------------------------------------------------------------------
1.587 +//
1.588 +EXPORT_C void RMMFDevSoundProxy::PlayInitL()
1.589 + {
1.590 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Enter"));
1.591 + if (!iDevSoundObserver || iState!=EInitialized)
1.592 + {
1.593 + if (iState == EPlaying || iState == EPlayingBufferWait)
1.594 + {
1.595 + // treat PlayInitL() during play as Resume()
1.596 + User::LeaveIfError(Resume());
1.597 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Exit"));
1.598 + return;
1.599 + }
1.600 + User::Leave(KErrNotReady);
1.601 + }
1.602 +
1.603 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayInit,
1.604 + iDestinationPckg));
1.605 + iState = EPlaying;
1.606 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Exit"));
1.607 + }
1.608 +
1.609 +// -----------------------------------------------------------------------------
1.610 +// RMMFDevSoundProxy::RecordInitL
1.611 +// Initilaizes DevSound to record digital audio and starts the record process.
1.612 +// (other items were commented in a header).
1.613 +// -----------------------------------------------------------------------------
1.614 +//
1.615 +EXPORT_C void RMMFDevSoundProxy::RecordInitL()
1.616 + {
1.617 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Enter"));
1.618 + if (!iDevSoundObserver || iState!=EInitialized)
1.619 + {
1.620 + if(iState == ERecording || iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle
1.621 + || iState == ERecordingResumingInLastBufferCycle)
1.622 + {
1.623 + // treat RecordInitL() during record as Resume()
1.624 + User::LeaveIfError(Resume());
1.625 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Exit"));
1.626 + return;
1.627 + }
1.628 + User::Leave(KErrNotReady);
1.629 + }
1.630 +
1.631 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyRecordInit,
1.632 + iDestinationPckg));
1.633 + iState = ERecording;
1.634 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Exit"));
1.635 + }
1.636 +
1.637 +// -----------------------------------------------------------------------------
1.638 +// RMMFDevSoundProxy::PlayData
1.639 +// Plays the data in the buffer at the current volume.
1.640 +// (other items were commented in a header).
1.641 +// -----------------------------------------------------------------------------
1.642 +//
1.643 +EXPORT_C void RMMFDevSoundProxy::PlayData()
1.644 + {
1.645 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayData - Enter")); //Uncommenting this will produce a lot of logging!
1.646 + __ASSERT_ALWAYS(iState == EPlaying || iState == EPlayingBufferWait,
1.647 + Panic(EMMFDevSoundProxyPlayDataWithoutInitialize));
1.648 + ASSERT(iDevSoundObserver);
1.649 + SYMBIAN_CHECK( iState == EPlayingBufferWait,
1.650 + Panic(EMMFDevSoundProxyPlayDataInWrongState));
1.651 + TMMFDevSoundProxyHwBuf set;
1.652 + set.iLastBuffer = iBuffer->LastBuffer();
1.653 + set.iBufferSize = iBuffer->Data().Size();
1.654 + TMMFDevSoundProxyHwBufPckg pckg(set);
1.655 +
1.656 + SendReceive(EMMFDevSoundProxyPlayData, iDestinationPckg, pckg);
1.657 + iState = EPlaying;
1.658 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayData - Exit")); //Uncommenting this will produce a lot of logging!
1.659 + }
1.660 +
1.661 +// -----------------------------------------------------------------------------
1.662 +// RMMFDevSoundProxy::RecordData
1.663 +// Signals the device to continue recording.
1.664 +// (other items were commented in a header).
1.665 +// -----------------------------------------------------------------------------
1.666 +//
1.667 +EXPORT_C void RMMFDevSoundProxy::RecordData()
1.668 + {
1.669 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordData - Enter")); //Uncommenting this will produce a lot of logging!
1.670 + __ASSERT_ALWAYS(iState == ERecording || iState == ERecordingBufferWait ||
1.671 + iState == ERecordingInLastBufferCycle || iState == ERecordingResumingInLastBufferCycle,
1.672 + Panic(EMMFDevSoundProxyRecordDataWithoutInitialize));
1.673 + ASSERT(iDevSoundObserver);
1.674 + SYMBIAN_CHECK(iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle ||
1.675 + iState == ERecordingResumingInLastBufferCycle,
1.676 + Panic(EMMFDevSoundProxyPlayDataInWrongState));
1.677 + switch (iState)
1.678 + {
1.679 + case ERecordingBufferWait:
1.680 + // standard case
1.681 + SendReceive(EMMFDevSoundProxyRecordData, iDestinationPckg);
1.682 + iState = ERecording;
1.683 + break;
1.684 + case ERecordingInLastBufferCycle:
1.685 + // ack of the last buffer. Just swallow - the server should not be sent an ack
1.686 + iState = ERecording;
1.687 + break;
1.688 + case ERecordingResumingInLastBufferCycle:
1.689 + // this is a RecordData() following a Resume() in the last cycle. This is where we do the resume!
1.690 + SendReceive(EMMFDevSoundProxyResume, iDestinationPckg); // note ignore any error
1.691 + iState = ERecording;
1.692 + break;
1.693 + }
1.694 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordData - Exit")); //Uncommenting this will produce a lot of logging!
1.695 + }
1.696 +
1.697 +// -----------------------------------------------------------------------------
1.698 +// RMMFDevSoundProxy::Stop
1.699 +// Stops the ongoing opeartion.
1.700 +// (other items were commented in a header).
1.701 +// -----------------------------------------------------------------------------
1.702 +//
1.703 +EXPORT_C void RMMFDevSoundProxy::Stop()
1.704 + {
1.705 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Stop - Enter"));
1.706 + if (iState > EInitialized)
1.707 + {
1.708 + SendReceive(EMMFDevSoundProxyStop, iDestinationPckg);
1.709 + iState = EInitialized;
1.710 + iMsgQueueHandler->Finish(); // will delete the buffer
1.711 + }
1.712 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Stop - Exit"));
1.713 + }
1.714 +
1.715 +// -----------------------------------------------------------------------------
1.716 +// RMMFDevSoundProxy::Pause
1.717 +// Temporarily stops the ongoing operation.
1.718 +// (other items were commented in a header).
1.719 +// -----------------------------------------------------------------------------
1.720 +//
1.721 +EXPORT_C void RMMFDevSoundProxy::Pause()
1.722 + {
1.723 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Pause - Enter"));
1.724 + if(iState > EInitialized)
1.725 + {
1.726 + SendReceive(EMMFDevSoundProxyPause, iDestinationPckg);
1.727 + }
1.728 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Pause - Exit"));
1.729 + }
1.730 +
1.731 +// -----------------------------------------------------------------------------
1.732 +// RMMFDevSoundProxy::PlayToneL
1.733 +// Plays the simple tone.
1.734 +// (other items were commented in a header).
1.735 +// -----------------------------------------------------------------------------
1.736 +//
1.737 +EXPORT_C void RMMFDevSoundProxy::PlayToneL(
1.738 + TInt aFrequency,
1.739 + const TTimeIntervalMicroSeconds& aDuration)
1.740 + {
1.741 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Enter"));
1.742 + if(iState==ETonePlaying)
1.743 + {
1.744 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Exit"));
1.745 + return;
1.746 + }
1.747 +
1.748 + if (!iDevSoundObserver || iState!=EInitialized)
1.749 + {
1.750 + User::Leave(KErrNotReady);
1.751 + }
1.752 +
1.753 + TMMFDevSoundProxySettings set;
1.754 + set.iFrequencyOne = aFrequency;
1.755 + set.iDuration = aDuration;
1.756 + TMMFDevSoundProxySettingsPckg pckg(set);
1.757 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayTone,
1.758 + iDestinationPckg,
1.759 + pckg));
1.760 + iState = ETonePlaying;
1.761 + iToneMode = ESimple;
1.762 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Exit"));
1.763 + }
1.764 +
1.765 +// -----------------------------------------------------------------------------
1.766 +// RMMFDevSoundProxy::PlayDualToneL
1.767 +// Plays the dual tone.
1.768 +// (other items were commented in a header).
1.769 +// -----------------------------------------------------------------------------
1.770 +//
1.771 +EXPORT_C void RMMFDevSoundProxy::PlayDualToneL(
1.772 + TInt aFrequencyOne,
1.773 + TInt aFrequencyTwo,
1.774 + const TTimeIntervalMicroSeconds& aDuration)
1.775 + {
1.776 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Enter"));
1.777 + if(iState==ETonePlaying)
1.778 + {
1.779 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Exit"));
1.780 + return;
1.781 + }
1.782 +
1.783 + if (!iDevSoundObserver || iState!=EInitialized)
1.784 + {
1.785 + User::Leave(KErrNotReady);
1.786 + }
1.787 +
1.788 + TMMFDevSoundProxySettings set;
1.789 + set.iFrequencyOne = aFrequencyOne;
1.790 + set.iFrequencyTwo = aFrequencyTwo;
1.791 + set.iDuration = aDuration;
1.792 + TMMFDevSoundProxySettingsPckg pckg(set);
1.793 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayDualTone, iDestinationPckg, pckg));
1.794 + iState = ETonePlaying;
1.795 + iToneMode = EDual;
1.796 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Exit"));
1.797 + }
1.798 +
1.799 +// -----------------------------------------------------------------------------
1.800 +// RMMFDevSoundProxy::PlayDTMFStringL
1.801 +// Plays the DTMF string.
1.802 +// (other items were commented in a header).
1.803 +// -----------------------------------------------------------------------------
1.804 +//
1.805 +EXPORT_C void RMMFDevSoundProxy::PlayDTMFStringL(const TDesC& aDTMFString)
1.806 + {
1.807 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Enter"));
1.808 + if(iState==ETonePlaying)
1.809 + {
1.810 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Exit"));
1.811 + return;
1.812 + }
1.813 +
1.814 + if (!iDevSoundObserver || iState!=EInitialized)
1.815 + {
1.816 + User::Leave(KErrNotReady);
1.817 + }
1.818 +
1.819 + TPtr tempPtr(0,0);
1.820 + tempPtr.Set(CONST_CAST(TUint16*, aDTMFString.Ptr()),
1.821 + aDTMFString.Length(),
1.822 + aDTMFString.Length());
1.823 +
1.824 + User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayDTMFString,
1.825 + iDestinationPckg,
1.826 + KNullDesC8,
1.827 + tempPtr));
1.828 + iState = ETonePlaying;
1.829 + iToneMode = EDTMFString;
1.830 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Exit"));
1.831 + }
1.832 +
1.833 +// -----------------------------------------------------------------------------
1.834 +// RMMFDevSoundProxy::PlayToneSequenceL
1.835 +// Plays the tone sequence. (NRT/RNG)
1.836 +// (other items were commented in a header).
1.837 +// -----------------------------------------------------------------------------
1.838 +//
1.839 +EXPORT_C void RMMFDevSoundProxy::PlayToneSequenceL(const TDesC8& aData )
1.840 + {
1.841 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Enter"));
1.842 + if(iState==ETonePlaying)
1.843 + {
1.844 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Exit"));
1.845 + return;
1.846 + }
1.847 +
1.848 + if (!iDevSoundObserver || iState!=EInitialized)
1.849 + {
1.850 + User::Leave(KErrNotReady);
1.851 + }
1.852 +
1.853 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayToneSequence,
1.854 + iDestinationPckg,
1.855 + aData));
1.856 + iState = ETonePlaying;
1.857 + iToneMode = ESequence;
1.858 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Exit"));
1.859 + }
1.860 +
1.861 +// -----------------------------------------------------------------------------
1.862 +// RMMFDevSoundProxy::PlayFixedSequenceL
1.863 +// Plays the fixed sequence.
1.864 +// (other items were commented in a header).
1.865 +// -----------------------------------------------------------------------------
1.866 +//
1.867 +EXPORT_C void RMMFDevSoundProxy::PlayFixedSequenceL(TInt aSequenceNumber)
1.868 + {
1.869 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Enter"));
1.870 + if(iState==ETonePlaying)
1.871 + {
1.872 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Exit"));
1.873 + return;
1.874 + }
1.875 +
1.876 + if (!iDevSoundObserver || iState!=EInitialized)
1.877 + {
1.878 + User::Leave(KErrNotReady);
1.879 + }
1.880 +
1.881 + TPckgBuf<TInt> seqNum(aSequenceNumber);
1.882 + User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayFixedSequence, iDestinationPckg, seqNum));
1.883 + iState = ETonePlaying;
1.884 + iToneMode = EFixedSequence;
1.885 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Exit"));
1.886 + }
1.887 +
1.888 +// -----------------------------------------------------------------------------
1.889 +// RMMFDevSoundProxy::SetDTMFLengths
1.890 +// Set attributes for playing DTMF String.
1.891 +// (other items were commented in a header).
1.892 +// -----------------------------------------------------------------------------
1.893 +//
1.894 +EXPORT_C void RMMFDevSoundProxy::SetDTMFLengths(
1.895 + TTimeIntervalMicroSeconds32& aToneOnLength,
1.896 + TTimeIntervalMicroSeconds32& aToneOffLength,
1.897 + TTimeIntervalMicroSeconds32& aPauseLength )
1.898 + {
1.899 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDTMFLengths - Enter"));
1.900 + TMMFDevSoundProxySettings set;
1.901 + set.iToneOnLength = aToneOnLength;
1.902 + set.iToneOffLength = aToneOffLength;
1.903 + set.iPauseLength = aPauseLength;
1.904 + TMMFDevSoundProxySettingsPckg pckg(set);
1.905 + SendReceive(EMMFDevSoundProxySetDTMFLengths, iDestinationPckg, pckg);
1.906 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDTMFLengths - Exit"));
1.907 + }
1.908 +
1.909 +// -----------------------------------------------------------------------------
1.910 +// RMMFDevSoundProxy::SetVolumeRamp
1.911 +// Sets the volume ramp duration.
1.912 +// (other items were commented in a header).
1.913 +// -----------------------------------------------------------------------------
1.914 +//
1.915 +EXPORT_C void RMMFDevSoundProxy::SetVolumeRamp(
1.916 + const TTimeIntervalMicroSeconds& aRampDuration)
1.917 + {
1.918 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolumeRamp - Enter"));
1.919 + TMMFDevSoundProxySettings set;
1.920 + set.iDuration = aRampDuration;
1.921 + TMMFDevSoundProxySettingsPckg pckg(set);
1.922 + SendReceive(EMMFDevSoundProxySetVolumeRamp, iDestinationPckg, pckg);
1.923 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolumeRamp - Exit"));
1.924 + }
1.925 +
1.926 +// -----------------------------------------------------------------------------
1.927 +// RMMFDevSoundProxy::GetSupportedInputDataTypesL
1.928 +// Returns supported datatypes for playing audio.
1.929 +// (other items were commented in a header).
1.930 +// -----------------------------------------------------------------------------
1.931 +//
1.932 +EXPORT_C void RMMFDevSoundProxy::GetSupportedInputDataTypesL(
1.933 + RArray<TFourCC>& aSupportedDataTypes,
1.934 + const TMMFPrioritySettings& aPrioritySettings)
1.935 + {
1.936 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Enter"));
1.937 + aSupportedDataTypes.Reset();
1.938 +
1.939 + TMMFPrioritySettings prioritySet = aPrioritySettings;
1.940 + TMMFPrioritySettingsPckg pckg(prioritySet);
1.941 +
1.942 + TPckgBuf<TInt> numberOfElementsPckg;
1.943 + User::LeaveIfError(SendReceiveResult(
1.944 + EMMFDevSoundProxyGetSupportedInputDataTypes,
1.945 + iDestinationPckg,
1.946 + pckg,
1.947 + numberOfElementsPckg));
1.948 +
1.949 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Exit 1"));
1.950 +
1.951 + HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC));
1.952 + TPtr8 ptr = buf->Des();
1.953 +
1.954 +
1.955 + User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData,
1.956 + iDestinationPckg,
1.957 + KNullDesC8,
1.958 + ptr));
1.959 +
1.960 + RDesReadStream stream(ptr);
1.961 + CleanupClosePushL(stream);
1.962 +
1.963 +
1.964 + TInt count = numberOfElementsPckg();
1.965 + for (TInt i = 0; i < count; i++)
1.966 + {
1.967 + TInt err = aSupportedDataTypes.Append(stream.ReadInt32L());
1.968 + if (err)
1.969 + {//note we don't destroy array because we don't own it
1.970 + //but we do reset it as it is incomplete
1.971 + aSupportedDataTypes.Reset();
1.972 + User::Leave(err);
1.973 + }
1.974 + }
1.975 + CleanupStack::PopAndDestroy(&stream);
1.976 + CleanupStack::PopAndDestroy(buf);
1.977 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Exit 2"));
1.978 + }
1.979 +
1.980 +// -----------------------------------------------------------------------------
1.981 +// RMMFDevSoundProxy::GetSupportedOutputDataTypesL
1.982 +// Returns supported datatypes for recording audio.
1.983 +// (other items were commented in a header).
1.984 +// -----------------------------------------------------------------------------
1.985 +//
1.986 +EXPORT_C void RMMFDevSoundProxy::GetSupportedOutputDataTypesL(
1.987 + RArray<TFourCC>& aSupportedDataTypes,
1.988 + const TMMFPrioritySettings& aPrioritySettings)
1.989 + {
1.990 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Enter"));
1.991 + aSupportedDataTypes.Reset();
1.992 +
1.993 + TMMFPrioritySettings prioritySet = aPrioritySettings;
1.994 + TMMFPrioritySettingsPckg pckg(prioritySet);
1.995 +
1.996 + TPckgBuf<TInt> numberOfElementsPckg;
1.997 + User::LeaveIfError(SendReceiveResult(
1.998 + EMMFDevSoundProxyGetSupportedOutputDataTypes,
1.999 + iDestinationPckg,
1.1000 + pckg,
1.1001 + numberOfElementsPckg));
1.1002 +
1.1003 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Exit 1"));
1.1004 +
1.1005 + HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC));
1.1006 + TPtr8 ptr = buf->Des();
1.1007 +
1.1008 +
1.1009 + User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData,
1.1010 + iDestinationPckg,
1.1011 + KNullDesC8,
1.1012 + ptr));
1.1013 + RDesReadStream stream(ptr);
1.1014 + CleanupClosePushL(stream);
1.1015 +
1.1016 +
1.1017 + TInt count = numberOfElementsPckg();
1.1018 + for (TInt i = 0; i < count; i++)
1.1019 + {
1.1020 + TInt err = aSupportedDataTypes.Append(stream.ReadInt32L());
1.1021 + if (err)
1.1022 + {//note we don't destroy array because we don't own it
1.1023 + //but we do reset it as it is incomplete
1.1024 + aSupportedDataTypes.Reset();
1.1025 + User::Leave(err);
1.1026 + }
1.1027 + }
1.1028 + CleanupStack::PopAndDestroy(&stream);
1.1029 + CleanupStack::PopAndDestroy(buf);
1.1030 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Exit 2"));
1.1031 + }
1.1032 +
1.1033 +// -----------------------------------------------------------------------------
1.1034 +// RMMFDevSoundProxy::SamplesRecorded
1.1035 +// Returns samples recorded so far.
1.1036 +// (other items were commented in a header).
1.1037 +// -----------------------------------------------------------------------------
1.1038 +//
1.1039 +EXPORT_C TInt RMMFDevSoundProxy::SamplesRecorded()
1.1040 + {
1.1041 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesRecorded - Enter"));
1.1042 + TPckgBuf<TInt> numSamples;
1.1043 + SendReceiveResult(EMMFDevSoundProxySamplesRecorded,
1.1044 + iDestinationPckg,
1.1045 + KNullDesC8,
1.1046 + numSamples);
1.1047 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesRecorded - Exit"));
1.1048 + return numSamples();
1.1049 + }
1.1050 +
1.1051 +// -----------------------------------------------------------------------------
1.1052 +// RMMFDevSoundProxy::SamplesPlayed
1.1053 +// Returns samples played so far.
1.1054 +// (other items were commented in a header).
1.1055 +// -----------------------------------------------------------------------------
1.1056 +//
1.1057 +EXPORT_C TInt RMMFDevSoundProxy::SamplesPlayed()
1.1058 + {
1.1059 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesPlayed - Enter"));
1.1060 + TPckgBuf<TInt> numSamples;
1.1061 + SendReceiveResult(EMMFDevSoundProxySamplesPlayed,
1.1062 + iDestinationPckg,
1.1063 + KNullDesC8,
1.1064 + numSamples);
1.1065 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesPlayed - Exit"));
1.1066 + return numSamples();
1.1067 + }
1.1068 +
1.1069 +// -----------------------------------------------------------------------------
1.1070 +// RMMFDevSoundProxy::SetToneRepeats
1.1071 +// Sets tone repeats
1.1072 +// (other items were commented in a header).
1.1073 +// -----------------------------------------------------------------------------
1.1074 +//
1.1075 +EXPORT_C void RMMFDevSoundProxy::SetToneRepeats(
1.1076 + TInt aRepeatCount,
1.1077 + const TTimeIntervalMicroSeconds&
1.1078 + aRepeatTrailingSilence)
1.1079 + {
1.1080 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetToneRepeats - Enter"));
1.1081 + TPckgBuf<TInt> countRepeat(aRepeatCount);
1.1082 + TPckgBuf<TTimeIntervalMicroSeconds> repeatTS(aRepeatTrailingSilence);
1.1083 + SendReceive(EMMFDevSoundProxySetToneRepeats,
1.1084 + iDestinationPckg,
1.1085 + countRepeat,
1.1086 + repeatTS);
1.1087 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetToneRepeats - Exit"));
1.1088 + }
1.1089 +
1.1090 +// -----------------------------------------------------------------------------
1.1091 +// RMMFDevSoundProxy::SetPrioritySettings
1.1092 +// Sets priority settings
1.1093 +// (other items were commented in a header).
1.1094 +// -----------------------------------------------------------------------------
1.1095 +//
1.1096 +EXPORT_C void RMMFDevSoundProxy::SetPrioritySettings(
1.1097 + const TMMFPrioritySettings& aPrioritySettings)
1.1098 + {
1.1099 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPrioritySettings - Enter"));
1.1100 + TPckgBuf<TMMFPrioritySettings> prioritySet(aPrioritySettings);
1.1101 + SendReceive(EMMFDevSoundProxySetPrioritySettings,
1.1102 + iDestinationPckg,
1.1103 + prioritySet);
1.1104 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPrioritySettings - Exit"));
1.1105 + }
1.1106 +
1.1107 +// -----------------------------------------------------------------------------
1.1108 +// RMMFDevSoundProxy::FixedSequenceName
1.1109 +// Returns the name of fixed sequence for a given sequence number.
1.1110 +// (other items were commented in a header).
1.1111 +// -----------------------------------------------------------------------------
1.1112 +//
1.1113 +EXPORT_C const TDesC& RMMFDevSoundProxy::FixedSequenceName(TInt /*aSequenceNumber*/)
1.1114 + {
1.1115 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceName - Enter"));
1.1116 + _LIT(KNullDesC, "");
1.1117 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceName - Exit"));
1.1118 + return KNullDesC;
1.1119 + }
1.1120 +
1.1121 +// -----------------------------------------------------------------------------
1.1122 +// RMMFDevSoundProxy::CustomInterface
1.1123 +// Returns a pointer to CustomInterface object.
1.1124 +// (other items were commented in a header).
1.1125 +// -----------------------------------------------------------------------------
1.1126 +//
1.1127 +EXPORT_C TAny* RMMFDevSoundProxy::CustomInterface(TUid aInterfaceId)
1.1128 + {
1.1129 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Enter"));
1.1130 + TMMFDevSoundProxySettings set;
1.1131 + set.iInterface = aInterfaceId;
1.1132 + // Added for ask for custom interface
1.1133 + TAny* customInterface = NULL;
1.1134 + if (aInterfaceId == KMmfUidDevSoundCancelInitializeCustomInterface)
1.1135 + {
1.1136 + MMMFDevSoundCancelInitialize* result = this;
1.1137 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Exit"));
1.1138 + return result;
1.1139 + }
1.1140 + TPckgBuf<TAny*> pckg2(customInterface);
1.1141 +
1.1142 + TMMFDevSoundProxySettingsPckg pckg(set);
1.1143 + SendReceiveResult(EMMFDevSoundProxyCustomInterface,
1.1144 + iDestinationPckg,
1.1145 + pckg, pckg2);
1.1146 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Exit"));
1.1147 + return reinterpret_cast<TAny*> (customInterface);
1.1148 + }
1.1149 +
1.1150 +// -----------------------------------------------------------------------------
1.1151 +// RMMFDevSoundProxy::FixedSequenceCount
1.1152 +// Returns the number of fixed sequences supported by DevSound.
1.1153 +// (other items were commented in a header).
1.1154 +// -----------------------------------------------------------------------------
1.1155 +//
1.1156 +EXPORT_C TInt RMMFDevSoundProxy::FixedSequenceCount()
1.1157 + {
1.1158 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceCount - Enter"));
1.1159 + TPckgBuf<TInt> fixSeqCountPckg;
1.1160 + SendReceiveResult(EMMFDevSoundProxyFixedSequenceCount,
1.1161 + iDestinationPckg,
1.1162 + KNullDesC8,
1.1163 + fixSeqCountPckg);
1.1164 +
1.1165 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceCount - Exit"));
1.1166 + return fixSeqCountPckg();
1.1167 + }
1.1168 +
1.1169 +// -----------------------------------------------------------------------------
1.1170 +// RMMFDevSoundProxy::BufferToBeFilledData
1.1171 +// Returns data buffer for playback.
1.1172 +// -----------------------------------------------------------------------------
1.1173 +//
1.1174 +EXPORT_C TInt RMMFDevSoundProxy::BufferToBeFilledData(
1.1175 + TBool aRequestChunk, TMMFDevSoundProxyHwBufPckg& aSetPckg)
1.1176 + {
1.1177 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeFilledData - Enter")); //Uncommenting this will produce a lot of logging!
1.1178 + // Note that there will only ever be one of these requests outstanding
1.1179 + // per session
1.1180 + TPckgBuf<TInt> requestChunkBuf (aRequestChunk);
1.1181 + TInt err = SendReceiveResult(EMMFDevSoundProxyBTBFData,
1.1182 + iDestinationPckg,
1.1183 + requestChunkBuf,
1.1184 + aSetPckg);
1.1185 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeFilledData - Exit [%d]"), err); //Uncommenting this will produce a lot of logging!
1.1186 + return err;
1.1187 + }
1.1188 +
1.1189 +// -----------------------------------------------------------------------------
1.1190 +// RMMFDevSoundProxy::BufferToBeEmptiedData
1.1191 +// Returns data buffer for recording.
1.1192 +// -----------------------------------------------------------------------------
1.1193 +//
1.1194 +EXPORT_C TInt RMMFDevSoundProxy::BufferToBeEmptiedData(
1.1195 + TMMFDevSoundProxyHwBufPckg& aSetPckg)
1.1196 + {
1.1197 + //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeEmptiedData - Enter")); //Uncommenting this will produce a lot of logging!
1.1198 + // Note that there will only ever be one of these requests outstanding
1.1199 + // per session
1.1200 + TInt err = SendReceiveResult(EMMFDevSoundProxyBTBEData,
1.1201 + iDestinationPckg,
1.1202 + KNullDesC8,
1.1203 + aSetPckg);
1.1204 + //SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::BufferToBeEmptiedData - Exit [%d]"), err); //Uncommenting this will produce a lot of logging!
1.1205 + return err;
1.1206 + }
1.1207 +
1.1208 +// -----------------------------------------------------------------------------
1.1209 +// RMMFDevSoundProxy::RegisterAsClient
1.1210 +// Registers the client for notification of resource avalibility.
1.1211 +// -----------------------------------------------------------------------------
1.1212 +//
1.1213 +EXPORT_C TInt RMMFDevSoundProxy::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData)
1.1214 + {
1.1215 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RegisterAsClient - Enter"));
1.1216 + TMMFDevSoundProxySettings set;
1.1217 + set.iNotificationEventUid = aEventType;
1.1218 + TMMFDevSoundProxySettingsPckg pckg(set);
1.1219 + TInt err = SendReceive(EMMFDevSoundProxyRequestResourceNotification, iDestinationPckg, pckg, aNotificationRegistrationData);
1.1220 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::RegisterAsClient - Exit [%d]"), err);
1.1221 + return err;
1.1222 + }
1.1223 +
1.1224 +// -----------------------------------------------------------------------------
1.1225 +// RMMFDevSoundProxy::CancelRegisterAsClient
1.1226 +// Cancels the Registered Notification.
1.1227 +// -----------------------------------------------------------------------------
1.1228 +//
1.1229 +EXPORT_C TInt RMMFDevSoundProxy::CancelRegisterAsClient(TUid aEventType)
1.1230 + {
1.1231 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CancelRegisterAsClient - Enter"));
1.1232 + TMMFDevSoundProxySettings set;
1.1233 + set.iNotificationEventUid = aEventType;
1.1234 + TMMFDevSoundProxySettingsPckg pckg(set);
1.1235 + TInt err = SendReceiveResult(EMMFDevSoundProxyCancelRequestResourceNotification, iDestinationPckg, KNullDesC8, pckg);
1.1236 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CancelRegisterAsClient - Exit [%d]"), err);
1.1237 + return err;
1.1238 + }
1.1239 +
1.1240 +// -----------------------------------------------------------------------------
1.1241 +// RMMFDevSoundProxy::GetResourceNotificationData
1.1242 +// Returns the Notification data which the client needs to resume playing.
1.1243 +// -----------------------------------------------------------------------------
1.1244 +//
1.1245 +EXPORT_C TInt RMMFDevSoundProxy::GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData)
1.1246 + {
1.1247 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetResourceNotificationData - Enter"));
1.1248 + TMMFDevSoundProxySettings set;
1.1249 + set.iNotificationEventUid = aEventType;
1.1250 + TMMFDevSoundProxySettingsPckg pckg(set);
1.1251 + TInt err = SendReceiveResult(EMMFDevSoundProxyGetResourceNotificationData, iDestinationPckg, pckg, aNotificationData);
1.1252 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::GetResourceNotificationData - Exit [%d]"), err);
1.1253 + return err;
1.1254 + }
1.1255 +
1.1256 +// -----------------------------------------------------------------------------
1.1257 +// RMMFDevSoundProxy::WillResumePlay
1.1258 +// Wait for the clients to resume play back even after the default timeout
1.1259 +// expires. Unless the client cancels the notification request or completes
1.1260 +// no other client gets notification.
1.1261 +// -----------------------------------------------------------------------------
1.1262 +//
1.1263 +EXPORT_C TInt RMMFDevSoundProxy::WillResumePlay()
1.1264 + {
1.1265 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::WillResumePlay - Enter"));
1.1266 + TInt err = SendReceive(EMMFDevSoundProxyWillResumePlay, iDestinationPckg);
1.1267 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::WillResumePlay - Exit [%d]"), err);
1.1268 + return err;
1.1269 + }
1.1270 +
1.1271 +// -----------------------------------------------------------------------------
1.1272 +// RMMFDevSoundProxy::EmptyBuffers
1.1273 +// Empties the play buffers below DevSound without causing the codec
1.1274 +// to be deleted.
1.1275 +// -----------------------------------------------------------------------------
1.1276 +//
1.1277 +
1.1278 +EXPORT_C TInt RMMFDevSoundProxy::EmptyBuffers()
1.1279 + {
1.1280 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::EmptyBuffers - Enter"));
1.1281 + TInt error = SendReceive(EMMFDevSoundProxyEmptyBuffers, iDestinationPckg);
1.1282 +
1.1283 + if(error==KErrNone)
1.1284 + {
1.1285 + if (iState==EPlayingBufferWait)
1.1286 + {
1.1287 + // Empty buffers terminates the buffer cycle
1.1288 + iState = EPlaying;
1.1289 + }
1.1290 + }
1.1291 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::EmptyBuffers - Exit [%d]"), error);
1.1292 + return error;
1.1293 + }
1.1294 +
1.1295 +// -----------------------------------------------------------------------------
1.1296 +// RMMFDevSoundProxy::CancelInitialize
1.1297 +// Cancels the initialization process
1.1298 +// -----------------------------------------------------------------------------
1.1299 +//
1.1300 +EXPORT_C TInt RMMFDevSoundProxy::CancelInitialize()
1.1301 + {
1.1302 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CancelInitialize - Enter"));
1.1303 + TInt err=KErrNone;
1.1304 +
1.1305 + if (iState==EInitializing)
1.1306 + {
1.1307 + err = SendReceive(EMMFDevSoundProxyCancelInitialize, iDestinationPckg);
1.1308 + iState = EIdle;
1.1309 + }
1.1310 + else
1.1311 + {
1.1312 + err = KErrNotReady;
1.1313 + }
1.1314 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CancelInitialize - Exit [%d]"), err);
1.1315 + return err;
1.1316 + }
1.1317 +
1.1318 +
1.1319 +// -----------------------------------------------------------------------------
1.1320 +// RMMFDevSoundProxy::SetClientThreadInfo
1.1321 +//
1.1322 +// -----------------------------------------------------------------------------
1.1323 +//
1.1324 +EXPORT_C TInt RMMFDevSoundProxy::SetClientThreadInfo(TThreadId& aTid)
1.1325 + {
1.1326 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetClientThreadInfo - Enter"));
1.1327 + TPckgBuf<TThreadId> threadId(aTid);
1.1328 + TInt err = SendReceive(EMMFDevSoundProxySetClientThreadInfo, iDestinationPckg, threadId);
1.1329 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetClientThreadInfo - Exit [%d]"), err);
1.1330 + return err;
1.1331 + }
1.1332 +
1.1333 +
1.1334 +// -----------------------------------------------------------------------------
1.1335 +// RMMFDevSoundProxy::CustomCommandSync()
1.1336 +// Send Message synchronously to DevSound server and return the result to client
1.1337 +// -----------------------------------------------------------------------------
1.1338 +//
1.1339 +EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync(
1.1340 + const TMMFMessageDestinationPckg& aDestination,
1.1341 + TInt aFunction,
1.1342 + const TDesC8& aDataTo1,
1.1343 + const TDesC8& aDataTo2,
1.1344 + TDes8& aDataFrom)
1.1345 + {
1.1346 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Enter"));
1.1347 + TInt err = SendReceiveResult(aFunction,
1.1348 + aDestination,
1.1349 + aDataTo1,
1.1350 + aDataTo2,
1.1351 + aDataFrom);
1.1352 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Exit [%d]"), err);
1.1353 + return err;
1.1354 + }
1.1355 +
1.1356 +// -----------------------------------------------------------------------------
1.1357 +// RMMFDevSoundProxy::RMMFDevSoundProxy()
1.1358 +// Send Message synchronously to DevSound server and return the result to client
1.1359 +// -----------------------------------------------------------------------------
1.1360 +//
1.1361 +EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync(
1.1362 + const TMMFMessageDestinationPckg& aDestination,
1.1363 + TInt aFunction,
1.1364 + const TDesC8& aDataTo1,
1.1365 + const TDesC8& aDataTo2)
1.1366 + {
1.1367 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Enter"));
1.1368 + TInt err = SendReceive(aFunction, aDestination, aDataTo1, aDataTo2);
1.1369 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Exit [%d]"), err);
1.1370 + return err;
1.1371 + }
1.1372 +
1.1373 +// -----------------------------------------------------------------------------
1.1374 +// RMMFDevSoundProxy::RMMFDevSoundProxy()
1.1375 +// Send Message asynchronously to DevSound server
1.1376 +// -----------------------------------------------------------------------------
1.1377 +//
1.1378 +EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync(
1.1379 + const TMMFMessageDestinationPckg& aDestination,
1.1380 + TInt aFunction,
1.1381 + const TDesC8& aDataTo1,
1.1382 + const TDesC8& aDataTo2,
1.1383 + TDes8& aDataFrom,
1.1384 + TRequestStatus& aStatus )
1.1385 + {
1.1386 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Enter"));
1.1387 + SendReceiveResult(aFunction,
1.1388 + aDestination,
1.1389 + aDataTo1,
1.1390 + aDataTo2,
1.1391 + aDataFrom,
1.1392 + aStatus);
1.1393 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Exit"));
1.1394 + }
1.1395 +
1.1396 +// -----------------------------------------------------------------------------
1.1397 +// RMMFDevSoundProxy::RMMFDevSoundProxy()
1.1398 +// Send Message asynchronously to DevSound server
1.1399 +// -----------------------------------------------------------------------------
1.1400 +//
1.1401 +EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync(
1.1402 + const TMMFMessageDestinationPckg& aDestination,
1.1403 + TInt aFunction,
1.1404 + const TDesC8& aDataTo1,
1.1405 + const TDesC8& aDataTo2,
1.1406 + TRequestStatus& aStatus )
1.1407 + {
1.1408 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Enter"));
1.1409 + SendReceive(aFunction, aDestination, aDataTo1, aDataTo2, aStatus);
1.1410 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Exit"));
1.1411 + }
1.1412 +
1.1413 +// implementation of a simple CustomCommand() scheme
1.1414 +EXPORT_C TInt RMMFDevSoundProxy::SyncCustomCommand(TUid aUid, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam)
1.1415 + {
1.1416 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Enter"));
1.1417 + TMMFMessageDestinationPckg dest(TMMFMessageDestination(aUid, KMMFObjectHandleDevSound));
1.1418 +
1.1419 + TInt err = KErrNone;
1.1420 + if (aOutParam==NULL)
1.1421 + {
1.1422 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Exit"));
1.1423 + err = SendReceive(EMMFDevSoundProxySyncCustomCommand, dest, aParam1, aParam2);
1.1424 + return err;
1.1425 + }
1.1426 + else
1.1427 + {
1.1428 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Exit"));
1.1429 + err = SendReceiveResult(EMMFDevSoundProxySyncCustomCommandResult, dest, aParam1, aParam2, *aOutParam);
1.1430 + return err;
1.1431 + }
1.1432 + }
1.1433 +
1.1434 +EXPORT_C void RMMFDevSoundProxy::AsyncCustomCommand(TUid aUid, TRequestStatus& aStatus, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam)
1.1435 + {
1.1436 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Enter"));
1.1437 + TMMFMessageDestination dest(aUid, KMMFObjectHandleDevSound);
1.1438 + iCustIntPckg = dest;
1.1439 + if (aOutParam==NULL)
1.1440 + {
1.1441 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Exit"));
1.1442 + SendReceive(EMMFDevSoundProxyAsyncCustomCommand, iCustIntPckg, aParam1, aParam2, aStatus);
1.1443 + }
1.1444 + else
1.1445 + {
1.1446 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Exit"));
1.1447 + SendReceiveResult(EMMFDevSoundProxyAsyncCustomCommandResult, iCustIntPckg, aParam1, aParam2, *aOutParam, aStatus);
1.1448 + }
1.1449 + }
1.1450 +
1.1451 +EXPORT_C TInt RMMFDevSoundProxy::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
1.1452 + {
1.1453 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetTimePlayed - Enter"));
1.1454 + TTimeIntervalMicroSeconds time(0);
1.1455 + TPckgBuf<TTimeIntervalMicroSeconds> timePckg(time);
1.1456 + TInt err = SendReceiveResult(EMMFDevSoundProxyGetTimePlayed, iDestinationPckg, KNullDesC8, timePckg);
1.1457 + if(err==KErrNone)
1.1458 + {
1.1459 + aTime = timePckg();
1.1460 + }
1.1461 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::GetTimePlayed - Exit [%d]"), err);
1.1462 + return err;
1.1463 + }
1.1464 +
1.1465 +EXPORT_C TBool RMMFDevSoundProxy::IsResumeSupported()
1.1466 + {
1.1467 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Enter"));
1.1468 + TPckgBuf<TBool> isResumeSupported;
1.1469 + TInt err = SendReceiveResult(EMMFDevSoundProxyIsResumeSupported,
1.1470 + iDestinationPckg,
1.1471 + KNullDesC8,
1.1472 + isResumeSupported);
1.1473 + if(err == KErrNone)
1.1474 + {
1.1475 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Exit"));
1.1476 + return isResumeSupported();
1.1477 + }
1.1478 + else
1.1479 + {
1.1480 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Exit"));
1.1481 + return EFalse;
1.1482 + }
1.1483 + }
1.1484 +
1.1485 +EXPORT_C TInt RMMFDevSoundProxy::Resume()
1.1486 + {
1.1487 + SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Resume - Enter"));
1.1488 + TInt err = KErrNone;
1.1489 + if (!iDevSoundObserver || iState <= EInitialized )
1.1490 + {
1.1491 + err = KErrNotReady;
1.1492 + }
1.1493 + else if(iState == ETonePlaying && iToneMode != ESequence)
1.1494 + {
1.1495 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Resume - Exit [%d]"), err);
1.1496 + return KErrNotSupported;
1.1497 + }
1.1498 + else
1.1499 + {
1.1500 + if (iState==ERecordingInLastBufferCycle)
1.1501 + {
1.1502 + // if we're in a last buffer cycle and get Resume() we have to be careful as the
1.1503 + // server side sent a PausedRecordCompleteEvent and did not actually request a buffer!
1.1504 + // just record the fact we've done this and wait until RecordData() is called
1.1505 + // don't actually resume until then!
1.1506 + iState = ERecordingResumingInLastBufferCycle;
1.1507 + }
1.1508 + else if (iState == ERecordingResumingInLastBufferCycle)
1.1509 + {
1.1510 + //Do Nothing as you can't resume twice on last buffer
1.1511 + }
1.1512 + else
1.1513 + {
1.1514 + err = SendReceive(EMMFDevSoundProxyResume,
1.1515 + iDestinationPckg);
1.1516 + }
1.1517 + }
1.1518 + SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Resume - Exit [%d]"), err);
1.1519 + return err;
1.1520 + }
1.1521 +
1.1522 +// -----------------------------------------------------------------------------
1.1523 +// RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL()
1.1524 +// Starts message queue handler (A/O) to monitor client side events
1.1525 +// -----------------------------------------------------------------------------
1.1526 +//
1.1527 +void RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL(MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
1.1528 + {
1.1529 + if (iMsgQueueHandler)
1.1530 + {
1.1531 + iMsgQueueHandler->Cancel();
1.1532 + }
1.1533 + else
1.1534 + {
1.1535 + iMsgQueueHandler = CMsgQueueHandler::NewL(this,
1.1536 + *this,
1.1537 + &iMsgQueue,
1.1538 + aDevSoundCIObserver);
1.1539 + }
1.1540 +
1.1541 + iMsgQueueHandler->ReceiveEvents();
1.1542 + }
1.1543 +
1.1544 +// MDevSoundObserver
1.1545 +// intercept the calls from the msgQueueHandler going back to the client, so we can track real state
1.1546 +
1.1547 +void RMMFDevSoundProxy::InitializeComplete(TInt aError)
1.1548 + {
1.1549 + SYMBIAN_CHECK(iState==EInitializing, Panic(EMMFDevSoundProxyInitCompleteInWrongState));
1.1550 + if (aError==KErrNone)
1.1551 + {
1.1552 + iState = EInitialized;
1.1553 + }
1.1554 + else
1.1555 + {
1.1556 + iState = EIdle;
1.1557 + }
1.1558 + iDevSoundObserver->InitializeComplete(aError);
1.1559 + }
1.1560 +
1.1561 +void RMMFDevSoundProxy::ToneFinished(TInt aError)
1.1562 + {
1.1563 + SYMBIAN_CHECK(iState==ETonePlaying, Panic(EMMFDevSoundProxyToneFinishedInWrongState));
1.1564 + iState = EInitialized;
1.1565 + iDevSoundObserver->ToneFinished(aError);
1.1566 + }
1.1567 +
1.1568 +void RMMFDevSoundProxy::PlayError(TInt aError)
1.1569 + {
1.1570 + SYMBIAN_CHECK(iState==EPlaying||iState==EPlayingBufferWait, Panic(EMMFDevSoundProxyPlayErrorInWrongState));
1.1571 + iState = EInitialized;
1.1572 + iDevSoundObserver->PlayError(aError);
1.1573 + }
1.1574 +
1.1575 +void RMMFDevSoundProxy::RecordError(TInt aError)
1.1576 + {
1.1577 + SYMBIAN_CHECK(iState==ERecording||iState==ERecordingBufferWait, Panic(EMMFDevSoundProxyRecordErrorInWrongState));
1.1578 + iState = EInitialized;
1.1579 + iDevSoundObserver->RecordError(aError);
1.1580 + }
1.1581 +
1.1582 +void RMMFDevSoundProxy::BufferToBeFilled(CMMFBuffer* aBuffer)
1.1583 + {
1.1584 + SYMBIAN_CHECK(iState==EPlaying, Panic(EMMFDevSoundProxyBTBFInWrongState));
1.1585 + iState = EPlayingBufferWait;
1.1586 + iBuffer = static_cast<CMMFDataBuffer*>(aBuffer); // cache buffer for use in PlayData() later
1.1587 + iDevSoundObserver->BufferToBeFilled(aBuffer);
1.1588 + }
1.1589 +
1.1590 +void RMMFDevSoundProxy::BufferToBeEmptied(CMMFBuffer* aBuffer)
1.1591 + {
1.1592 + SYMBIAN_CHECK(iState==ERecording, Panic(EMMFDevSoundProxyBTBEInWrongState));
1.1593 + if (aBuffer->LastBuffer())
1.1594 + {
1.1595 + // this is end of recording. Assume have an empty buffer. Different state so that Resume() is handled as special case.
1.1596 + iState = ERecordingInLastBufferCycle;
1.1597 + }
1.1598 + else
1.1599 + {
1.1600 + iState = ERecordingBufferWait;
1.1601 + }
1.1602 + iDevSoundObserver->BufferToBeEmptied(aBuffer);
1.1603 + }
1.1604 +
1.1605 +void RMMFDevSoundProxy::ConvertError(TInt /*aError*/)
1.1606 + {
1.1607 + SYMBIAN_CHECK(EFalse, Panic(EMMFDevSoundProxyUnexpectedConvError));
1.1608 + }
1.1609 +
1.1610 +void RMMFDevSoundProxy::DeviceMessage(TUid aMessageType, const TDesC8& aMsg)
1.1611 + {
1.1612 + iDevSoundObserver->DeviceMessage(aMessageType, aMsg);
1.1613 + }
1.1614 +
1.1615 +void RMMFDevSoundProxy::SendEventToClient(const TMMFEvent& aEvent)
1.1616 + {
1.1617 + iDevSoundObserver->SendEventToClient(aEvent);
1.1618 + }
1.1619 +
1.1620 +
1.1621 +// End of File