os/mm/devsound/devsoundrefplugin/src/platsec/SoundDevice/SoundDeviceBody.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __SOUNDDEVICEBODY__H__
    17 #define __SOUNDDEVICEBODY__H__
    18 
    19 #include "MmfDevSoundCallbackHandler.h" 
    20 #include <mmf/plugin/devsoundplugin.h>
    21 #include <mmf/server/mmfdevsoundcustominterfacesupport.h>
    22 #include <mmf/server/mmfdevsoundcustominterface.h>
    23 #include "MmfDevSoundCIMuxUtility.h"
    24 
    25  
    26 /*
    27  *
    28  *	Class Name:	CMMFDevSoundClientImp
    29  *
    30  *	Reference internals for CMMFDevSound
    31  *  @internalComponent
    32  *
    33  */
    34 class CMMFDevSoundClientImp : public CBase, 
    35 							  public MMMFDevSoundPlugin,
    36 							  public MAudioClientThreadInfo,
    37   							  public MAutoPauseResumeSupport,
    38 							  public MMMFDevSoundCustomInterfaceChannel,
    39 							  public MMMFDevSoundEmptyBuffers,
    40 							  public MMMFDevSoundCustomInterfaceObserver,
    41 							  public MMMFDevSoundTimePlayed
    42 
    43 	{
    44 public:
    45 	static CMMFDevSoundClientImp* NewL();
    46 	~CMMFDevSoundClientImp();
    47 
    48 	// Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz. 
    49 	void InitializeL(MDevSoundObserver& aDevSoundObserver, TMMFState aMode);
    50 	// Initializes with hardware device and mode (play, record, convert)
    51 	void InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode);
    52 	// Initializes with hardware device associated with specific FourCC code 
    53 	// and desired mode (play, record, convert)
    54 	void InitializeL(MDevSoundObserver& aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode); 
    55 
    56 	// Returns device capabilities
    57 	TMMFCapabilities Capabilities();
    58 	// Returns device configuration
    59 	TMMFCapabilities Config() const;
    60 	// Sets device configuration
    61 	void SetConfigL(const TMMFCapabilities& aCaps);
    62 
    63 	// Returns maximum play volume device supports
    64 	TInt MaxVolume();
    65 	// Returns play volume device is configured to
    66 	TInt Volume();
    67 	// Sets device play volume
    68 	void SetVolume(TInt aVolume);
    69 
    70 	// Returns maximum record gain device supports
    71 	TInt MaxGain();
    72 	// Returns record gain device is configured to
    73 	TInt Gain();
    74 	// Sets device record gain
    75 	void SetGain(TInt aGain);
    76 
    77 	// Returns play balance
    78 	void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
    79 	// Sets play balance
    80 	void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
    81 
    82 	// Returns record balance
    83 	void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
    84 	// Sets record balance
    85 	void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage);
    86 
    87 	// Initializes audio device and start play process
    88 	void PlayInitL();
    89 	// Initializes audio device and start record process
    90 	void RecordInitL();
    91 	// Plays the data in the buffer
    92 	void PlayData();
    93 	// Records data into buffer
    94 	void RecordData();
    95 	// Stops the ongoing operation
    96 	void Stop();
    97 	// Tempororily Stops the ongoing operation
    98 	void Pause();
    99 
   100 	// Returns the Sample recorded so far
   101 	TInt SamplesRecorded();
   102 	// Returns the Sample played so far
   103 	TInt SamplesPlayed();
   104 
   105 	// Initializes device and start playing tone
   106 	void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
   107 	// Initializes device and start playing dual tone
   108 	void PlayDualToneL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration);
   109 	// Initializes device and start playing DTMF String
   110 	void PlayDTMFStringL(const TDesC& aDTMFString);
   111 	// Initializes device and start playing tone sequence
   112 	void PlayToneSequenceL(const TDesC8& aData);
   113 	// Initializes device and start playing fixed sequence
   114 	void PlayFixedSequenceL(TInt aSequenceNumber);
   115 
   116 	// Sets tone repeat attributes
   117 	void SetToneRepeats(TInt aRepeatCount,
   118 					const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
   119 	// Sets DTMF tone attributes
   120 	void SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
   121 									TTimeIntervalMicroSeconds32& aToneOffLength,
   122 									TTimeIntervalMicroSeconds32& aPauseLength);
   123 	// Sets volume ramp for playing
   124 	void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
   125 	// Sets priority settings
   126 	void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
   127 
   128 	// Provides interface for sending custom commands for the audio device
   129 	TAny* CustomInterface(TUid aInterfaceId);
   130 
   131 	// Provides interface for querying fixed sequence count
   132 	TInt FixedSequenceCount();
   133 	// Provides interface for querying fixed sequence name
   134 	const TDesC& FixedSequenceName(TInt aSequenceNumber);
   135 	// Gets the supported input datatypes
   136 	void GetSupportedInputDataTypesL(RArray<TFourCC>& aSupportedDataTypesconst, const TMMFPrioritySettings& aPrioritySettings) const;
   137 	// Gets the supported output datatypes
   138 	void GetSupportedOutputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const;
   139 	// Set the real client thread with thread Id
   140 	TInt SetClientThreadInfo(TThreadId aTid);
   141 
   142 	// Registers the client for notification
   143 	TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
   144 	//cancels the registered notification
   145 	TInt CancelRegisterAsClient(TUid aEventType);
   146 	//get the notification data to resume 
   147 	TInt GetResourceNotificationData(TUid aEventType,TDes8& aNotificationData);
   148 	//if client need more than the default timeout period
   149 	TInt WillResumePlay();
   150 	
   151 	// from MMMFDevSoundEmptyBuffers
   152 	//Empties the buffers below DevSound without causing the codec to be deleted.
   153 	TInt EmptyBuffers();
   154 
   155 	// added to support custom command passing through DevSound
   156 	TInt SyncCustomCommand(TUid aUid, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam);
   157 	void AsyncCustomCommand(TUid aUid, TRequestStatus& aStatus, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam);
   158 
   159 	//from MMMFDevSoundCustomInterfaceObserver
   160 	void CloseCustomInterface(TInt aIndex);
   161 	
   162 	//from MMMFDevSoundTimePlayed
   163 	TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
   164 private:
   165 	// So that nobody can extend 
   166 	CMMFDevSoundClientImp();
   167 	// Second phase constructor
   168 	void ConstructL();
   169 
   170 	TInt FindCustomInterface(TUid aInterfaceId);
   171 private:
   172 	// custom interface storage
   173 	RArray<TMMFDevSoundCustomInterfaceData> iCustomInterfaceArray;
   174 	CMMFDevSoundCIMuxUtility* iMuxUtility;
   175 	
   176 	RMMFDevSoundProxy* iDevSoundProxy;
   177 	MDevSoundObserver* iDevSoundObserver;
   178 	
   179 	RMsgQueue<TMMFDevSoundQueueItem> iMsgQueue;
   180 	CMsgQueueHandler* iMsgQueueHandler;
   181 	};
   182 
   183 #include "SoundDeviceBody.inl"
   184 
   185 #endif // __SOUNDDEVICEBODY__H__