Symbian
 Developer Library

DEVELOPER LIBRARY

[Index] [Glossary] [Previous] [Next]



Location: SoundDevice.h
Link against: MMFDevSound.lib

Class CMMFDevSound

class CMMFDevSound : public CBase, public MMMFHwDeviceObserver;

Support

Supported from 7.0s

Description

An interface to the raw audio functions of Symbian OS device hardware.

The audio functions include the following functionality:

Derivation

CBaseBase class for all classes to be instantiated on the heap
CMMFDevSoundAn interface to the raw audio functions of Symbian OS device hardware
MMMFHwDeviceObserver 

Defined in CMMFDevSound:
CMMFDevSound(), Capabilities(), Complete(), Config(), ConstructL(), ConvertData(), ConvertInitL(), CustomCommand(), DevSoundInfo(), Device(), DoPlayL(), EmptyThisHwBuffer(), FillFreeToneBuffer(), FillThisHwBuffer(), Gain(), GetPlayBalanceL(), GetRecordBalanceL(), InitAudioDeviceNode(), InitializeFormat(), InitializeL(), InitializeL(), InitializeL(), InitializeL(), LoadL(), MaxGain(), MaxVolume(), MoreData(), MoreRecordData(), MsgFromHwDevice(), NewL(), NumberOfChannels(), Pause(), PlayDTMFStringL(), PlayData(), PlayFixedSequenceL(), PlayInitL(), PlayToneL(), PlayToneSequenceL(), PlayingStopped(), RecordComplete(), RecordData(), RecordInitL(), RecordingStopped(), RequestPolicy(), ResumePlayDTMFStringL(), ResumePlayDataL(), ResumePlayToneL(), ResumePlayToneSequenceL(), ResumeRecordDataL(), SamplesPlayed(), SamplesRecorded(), SamplingFrequency(), SendEventToClient(), SetActiveToneBuffer(), SetConfigL(), SetDTMFLengths(), SetDevSoundId(), SetGain(), SetPlayBalanceL(), SetPrioritySettings(), SetRecordBalanceL(), SetToneRepeats(), SetVolume(), SetVolumeRamp(), Stop(), Stopped(), Unload(), UpdateBytesPlayed(), UpdatePolicyState(), Volume(), iActiveToneBuffer, iAudioPlayer, iAudioPolicyPrioritySettings, iAudioPolicyProxy, iAudioPolicyRequest, iAudioRecorder, iBuffer, iCMMFHwDevice, iClientSessionId, iCurrentGenerator, iDTMFGen, iDevInfo, iDevSoundEventHandler, iDevSoundInfo, iDevSoundObserver, iDevice, iDeviceCapabilities, iDeviceConfig, iDeviceIsOpen, iGain, iHwDeviceBuffer, iMode, iPlayFormat, iPlayFormatsSupported, iPlayedBytesCount, iPlayerErrors, iPrioritySettings, iRampDuration, iReceivingEvents, iRecordFormat, iRecordFormatsSupported, iRecordedBytesCount, iRecorderErrors, iRepeatCount, iRepeatTrailingSilence, iState, iToneBuffer1, iToneBuffer2, iToneGen, iVolume, ~CMMFDevSound()

Inherited from CBase:
operator new()


Construction and destruction


NewL()

static CMMFDevSound* NewL();

Description

Constructs and initialises a new instance of DevSound.

The function leaves if the DevSound object cannot be created.

Return value

CMMFDevSound *

Pointer to the new DevSound object.


~CMMFDevSound()

~CMMFDevSound();

Description

Default destructor.

Frees all resources owned by the object prior to its destruction.

[Top]


Member functions


InitializeL()

void InitializeL(MDevSoundObserver& aDevSoundObserver);

Description

Initialises the CMMFDevSound object and sets raw audio encoding to PCM16 and sampling to 8 KHz.

On completion of initialisation, the observer is notified via the call back MDevSoundObserver::InitializeComplete().

Parameters

MDevSoundObserver& aDevSoundObserver

An observer class used to notify the client of various events. It also provides a mechanism for the client to pass and receive data to and from DevSound. The caller must create an observer class that implements this interface.


InitializeL()

void InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode);

Description

Initialises the CMMFDevSound object specifying the hardware device and its mode, for example play, record or convert.

On completion of initialisation, the observer is notified via the call back MDevSoundObserver::InitializeComplete().

Parameters

MDevSoundObserver& aDevSoundObserver

An observer class used to notify the client of various events. It also provides a mechanism for the client to pass and receive data to and from DevSound. The caller must create an observer class that implements this interface.

TUid aHWDev

Hardware device ID.

TMMFState aMode

Audio mode, for example, idle, tone playing and so on.


InitializeL()

void InitializeL(MDevSoundObserver& aDevSoundObserver, CArrayPtr<TUid> aHWDevArray, TMMFState aMode);

Description

Initialises the CMMFDevSound object specifying a chain of hardware devices and a single mode to set them to.

The hardware devices are chained together with data flow starting with first array element.

On completion of initialisation, the observer is notified via the call back MDevSoundObserver::InitializeComplete().

Parameters

MDevSoundObserver& aDevSoundObserver

An observer class used to notify the client of various events. It also provides a mechanism for the client to pass and receive data to and from DevSound. The caller must create an observer class that implements this interface.

CArrayPtr<TUid> aHWDevArray

An array of hardware device IDs.

TMMFState aMode

Audio mode, for example, idle, tone playing and so on.


InitializeL()

void InitializeL(MDevSoundObserver& aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode);

Description

Initialises the CMMFDevSound object specifying a hardware device (referenced by its associated TFourCC code) and its mode, for example play, record or convert.

On completion of initialisation, the observer is notified via the call back MDevSoundObserver::InitializeComplete().

Parameters

MDevSoundObserver& aDevSoundObserver

An observer class used to notify the client of various events. It also provides a mechanism for the client to pass and receive data to and from DevSound. The caller must create an observer class that implements this interface.

TFourCC aDesiredFourCC

The TFourCC code for the desired hardware.

TMMFState aMode

Audio mode, for example, idle, tone playing and so on.


Capabilities()

TMMFCapabilities Capabilities();

Description

Returns all possible values that the device configuration can be set to.

Return value

TMMFCapabilities

Device's capability attributes, specifically, encoding, sample rates, mono/stereo indication and buffer size.


Config()

TMMFCapabilities Config() const;

Description

Returns the current settings used by the device.

Return value

TMMFCapabilities

Device's configuration attributes, specifically, encoding, sample rates, mono/stereo indication and buffer size.


SetConfigL()

void SetConfigL(const TMMFCapabilities& aCaps);

Description

Sets new device attribute values.

Use this to set sampling rate, encoding and the mono/stereo indicator.

Parameters

const TMMFCapabilities& aCaps

New device attribute values.


MaxVolume()

TInt MaxVolume();

Description

Returns the maximum volume setting supported by the current device.

Return value

TInt

Maximum volume setting.


Volume()

TInt Volume();

Description

Returns the volume setting of the current device.

Return value

TInt

Current volume setting.


SetVolume()

void SetVolume(TInt aVolume);

Description

Sets the volume of the current device.

Valid volume settings are in the range of 0 to MaxVolume().

Parameters

TInt aVolume

Volume setting.


MaxGain()

TInt MaxGain();

Description

Maximum microphone gain supported by the current device.

Return value

TInt

Maximum microphone gain.


Gain()

TInt Gain();

Description

Returns the microphone gain of the current device.

Return value

TInt

Current microphone gain.


SetGain()

void SetGain(TInt aGain);

Description

Sets the microphone gain of the current device.

Valid gain settings are in the range of 0 to MaxGain().

Parameters

TInt aGain

Microphone gain.


GetPlayBalanceL()

void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);

Description

Gets the balance settings for the current playing device.

Parameters

TInt& aLeftPercentage

On return, contains the left channel's volume balance setting for playing audio.

TInt& aRightPercentage

On return, contains the right channel's volume balance setting for playing audio.


SetPlayBalanceL()

void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage);

Description

Modifies the balance settings for the current playing device.

Both channels require percentage values, therefore, valid range is between 0 and 100 only.

Parameters

TInt aLeftPercentage

The left channel's volume balance setting for playing audio.

TInt aRightPercentage

The right channel's volume balance setting for playing audio.


GetRecordBalanceL()

void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);

Description

Gets the balance settings for the current recording device.

Parameters

TInt& aLeftPercentage

On return, contains the left channel's balance setting for recording audio.

TInt& aRightPercentage

On return, contains the right channel's balance setting for recording audio.


SetRecordBalanceL()

void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage);

Description

Modifies the balance settings for the current recording device.

Both channels require percentage values, therefore, valid range is between 0 and 100 only.

Parameters

TInt aLeftPercentage

The left channel balance setting for recording audio.

TInt aRightPercentage

The right channel balance setting for recording audio.


PlayInitL()

void PlayInitL();

Description

Initialises the audio device and starts the play process.

This method queries the audio policy server before initialising the audio device. If there is an error during policy initialisation, MDevSoundObserver::PlayError() is called with an error code of KErrAccessDenied. If no initialisation error occurs, MDevSoundObserver::BufferToBeFilled() is called with a buffer reference. The client then needs to fill the buffer with the data to play and then call PlayData().

Note: The amount of data that can be played is specified in CMMFBuffer::RequestSize(). Any additional data placed in the buffer is ignored.


RecordInitL()

void RecordInitL();

Description

Initialises the audio device and starts the record process.

This method queries the audio policy server before initialising the audio device. If there is an error during policy initialisation, MDevSoundObserver::RecordError() is called with an error code of KErrAccessDenied. If no initialisation error occurs, MDevSoundObserver::BufferToBeEmptied() is called with a buffer reference. This buffer contains recorded or encoded data. After processing the recorded or encoded data the client should call RecordData() to continue the recording process.


PlayData()

void PlayData();

Description

Plays the audio data provided by the client when processing the BufferToBeFilled() callback.

When playing of the audio sample is complete, successfully or otherwise MDevSoundObserver::PlayError() is called with the appropriate system wide error code.


RecordData()

void RecordData();

Description

Continues the recording process.

Once the recording buffer is filled with audio data, MDevSoundObserver::BufferToBeEmptied() is called so that the client has the opportunity to process the recorded data (usually copying the data to another buffer or writing it to a file.)


Stop()

void Stop();

Description

Stops an ongoing operation, for example, play, record, tone play, convert and so on.


Pause()

void Pause();

Description

Temporarily stops an ongoing operation, for example, play, record, tone play, convert and so on.


SamplesRecorded()

TInt SamplesRecorded();

Description

Returns the number of bytes recorded so far.

Return value

TInt

Recorded bytes.


SamplesPlayed()

TInt SamplesPlayed();

Description

Returns the number of bytes played so far.

Return value

TInt

Played bytes.


PlayToneL()

void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);

Description

Initialises the audio device and starts the play tone process.

The tone is played at a specified frequency for a specified amount of time.

Parameters

TInt aFrequency

The frequency of the tone to play.

const TTimeIntervalMicroSeconds& aDuration

The duration of the tone.


PlayDTMFStringL()

void PlayDTMFStringL(const TDesC& aDTMFString);

Description

Initialises the audio device and starts playing a DTMF string.

Parameters

const TDesC& aDTMFString

DTMF sequence to play.


PlayToneSequenceL()

void PlayToneSequenceL(const TDesC8& aData);

Description

Initialises the audio device and starts playing a sequence of tones.

Note: This function is not currently supported.

Parameters

const TDesC8& aData

Tone sequence to play.


PlayFixedSequenceL()

void PlayFixedSequenceL(TInt aSequenceNumber);

Description

Initialises the audio device and starts playing a fixed sequence of tones.

Note: This function is not currently supported.

Parameters

TInt aSequenceNumber

Tone sequence number pointing to an index in a fixed sequence table.


SetToneRepeats()

void SetToneRepeats(TInt aRepeatCount, const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);

Description

Defines the number of times the tone should be repeated during playback.

A period of silence can follow each playing of tone.

This function is only available while a tone is playing.

Parameters

TInt aRepeatCount

The number of times to repeat the tone. Use 0 for no repeat, or KMdaRepeatForever to repeat until Stop() is called.

const TTimeIntervalMicroSeconds& aRepeatTrailingSilence

Duration of a trailing silence after a tone has been played.


SetDTMFLengths()

void SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength, TTimeIntervalMicroSeconds32& aToneOffLength, TTimeIntervalMicroSeconds32& aPauseLength);

Description

Defines the duration of tone on, tone off and tone pause to be used during the DTMF tone playback operation.

Parameters

TTimeIntervalMicroSeconds32& aToneOnLength

The period over which the tone will be played. If this is set to zero, then the tone is not played.

TTimeIntervalMicroSeconds32& aToneOffLength

The period over which the no tone will be played.

TTimeIntervalMicroSeconds32& aPauseLength

The period over which the tone playing will be paused.


SetVolumeRamp()

void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);

Description

Defines the period over which the volume level is to rise smoothly from nothing to the normal volume level.

This function is only available while a tone is playing.

Parameters

const TTimeIntervalMicroSeconds& aRampDuration

The period over which the volume is to rise. Zero causes the tone sample to be played at the normal level for the duration of the playback.


SetPrioritySettings()

void SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);

Description

Defines the priority settings to use for this instance.

Parameters

const TMMFPrioritySettings& aPrioritySettings

Priority settings.


ConvertInitL()

void ConvertInitL();

Description

Initialises the audio device and starts the convert process.

This method queries the audio policy server before initialising audio device. If there is an error during policy initialisation, MDevSoundObserver::PlayError() is called with an error code of KErrAccessDenied. If no initialisation error occurs, MDevSoundObserver::BufferToBeFilled() is called with a buffer reference used to store the source audio data. The client then needs to fill the buffer with the data to convert and then call ConvertData().

Note: The amount of data that can be converted is specified in CMMFBuffer::RequestSize(). Any additional data placed in the buffer is ignored.

Note: This function is not currently supported.


ConvertData()

void ConvertData();

Description

Completes the conversion process.

Once the conversion buffer is filled with converted audio data MDevSoundObserver::BufferToBeEmptied() is called so that the client has the opportunity to process the converted data (usually copying the data to another buffer or writing it to a file.)

Note: This function is not currently supported.


CustomCommand()

TInt CustomCommand(TDesC8& aCommand);

Description

Used to issue device specific commands that cannot be executed through the DevSound API.

The command is packed in the form of a descriptor. After executing the custom command, the device may or may not send a command execution message to the observer via MDevSoundObserver::DeviceMessage().

Note: This function is not currently supported.

Parameters

TDesC8& aCommand

Device specific command.

Return value

TInt

Returns KErrNotSupported.

[Top]


Internal members


CMMFDevSound()

protected: CMMFDevSound();

Description

This member is internal and not intended for use.


ConstructL()

private: void ConstructL();

Description

This member is internal and not intended for use.


InitializeFormat()

private: TInt InitializeFormat(RMdaDevSound::TSoundFormatsSupportedBuf& aSupportedFormat, RMdaDevSound::TCurrentSoundFormatBuf& aFormat);

Description

This member is internal and not intended for use.


LoadL()

private: void LoadL();

Description

This member is internal and not intended for use.


Unload()

private: void Unload();

Description

This member is internal and not intended for use.


RequestPolicy()

private: TInt RequestPolicy();

Description

This member is internal and not intended for use.


DoPlayL()

private: void DoPlayL();

Description

This member is internal and not intended for use.


SetActiveToneBuffer()

private: void SetActiveToneBuffer();

Description

This member is internal and not intended for use.


FillFreeToneBuffer()

private: TInt FillFreeToneBuffer();

Description

This member is internal and not intended for use.


UpdatePolicyState()

private: TInt UpdatePolicyState();

Description

This member is internal and not intended for use.


InitAudioDeviceNode()

private: TInt InitAudioDeviceNode();

Description

This member is internal and not intended for use.


SamplingFrequency()

private: TInt SamplingFrequency();

Description

This member is internal and not intended for use.


NumberOfChannels()

private: TInt NumberOfChannels();

Description

This member is internal and not intended for use.


SetDevSoundId()

void SetDevSoundId(TInt aDevSoundId);

Description

This member is internal and not intended for use.


DevSoundInfo()

TMMFDevSoundInfo DevSoundInfo();

Description

This member is internal and not intended for use.


ResumePlayDataL()

void ResumePlayDataL();

Description

This member is internal and not intended for use.


ResumeRecordDataL()

void ResumeRecordDataL();

Description

This member is internal and not intended for use.


ResumePlayToneL()

void ResumePlayToneL();

Description

This member is internal and not intended for use.


ResumePlayDTMFStringL()

void ResumePlayDTMFStringL();

Description

This member is internal and not intended for use.


ResumePlayToneSequenceL()

void ResumePlayToneSequenceL();

Description

This member is internal and not intended for use.


SendEventToClient()

void SendEventToClient(const TMMFEvent& aEvent);

Description

This member is internal and not intended for use.


Device()

RMdaDevSound& Device();

Description

This member is internal and not intended for use.


UpdateBytesPlayed()

void UpdateBytesPlayed();

Description

This member is internal and not intended for use.


PlayingStopped()

void PlayingStopped(TInt aReason);

Description

This member is internal and not intended for use.


RecordingStopped()

void RecordingStopped(TInt aReason);

Description

This member is internal and not intended for use.


Complete()

void Complete();

Description

This member is internal and not intended for use.


RecordComplete()

void RecordComplete();

Description

This member is internal and not intended for use.


MoreData()

void MoreData();

Description

This member is internal and not intended for use.


MoreRecordData()

TBool MoreRecordData();

Description

This member is internal and not intended for use.


FillThisHwBuffer()

virtual TInt FillThisHwBuffer(CMMFDataBuffer& aHwDataBuffer);

Description

This member is internal and not intended for use.


EmptyThisHwBuffer()

virtual TInt EmptyThisHwBuffer(CMMFDataBuffer& aHwDataBuffer);

Description

This member is internal and not intended for use.


MsgFromHwDevice()

virtual TInt MsgFromHwDevice(TDesC8& aMsg);

Description

This member is internal and not intended for use.


Stopped()

virtual void Stopped();

Description

This member is internal and not intended for use.


iAudioPolicyProxy

private: RMMFAudioPolicyProxy* iAudioPolicyProxy;

Description

This member is internal and not intended for use.


iAudioPolicyRequest

private: CMMFAudioPolicyRequest* iAudioPolicyRequest;

Description

This member is internal and not intended for use.


iDevSoundObserver

private: MDevSoundObserver* iDevSoundObserver;

Description

This member is internal and not intended for use.


iAudioPlayer

private: CDevSoundPlayer* iAudioPlayer;

Description

This member is internal and not intended for use.


iPlayerErrors

private: CDevSoundError* iPlayerErrors;

Description

This member is internal and not intended for use.


iAudioRecorder

private: CDevSoundRecorder* iAudioRecorder;

Description

This member is internal and not intended for use.


iRecorderErrors

private: CDevSoundRecordError* iRecorderErrors;

Description

This member is internal and not intended for use.


iDevSoundEventHandler

private: CMMFDevSoundEventHandler* iDevSoundEventHandler;

Description

This member is internal and not intended for use.


iDevice

private: RMdaDevSound iDevice;

Description

This member is internal and not intended for use.


iPlayFormatsSupported

private: RMdaDevSound::TSoundFormatsSupportedBuf iPlayFormatsSupported;

Description

This member is internal and not intended for use.


iPlayFormat

private: RMdaDevSound::TCurrentSoundFormatBuf iPlayFormat;

Description

This member is internal and not intended for use.


iRecordFormatsSupported

private: RMdaDevSound::TSoundFormatsSupportedBuf iRecordFormatsSupported;

Description

This member is internal and not intended for use.


iRecordFormat

private: RMdaDevSound::TCurrentSoundFormatBuf iRecordFormat;

Description

This member is internal and not intended for use.


iDeviceCapabilities

private: TMMFCapabilities iDeviceCapabilities;

Description

This member is internal and not intended for use.


iDeviceConfig

private: TMMFCapabilities iDeviceConfig;

Description

This member is internal and not intended for use.


iState

private: TMMFState iState;

Description

This member is internal and not intended for use.


iPrioritySettings

private: TMMFPrioritySettings iPrioritySettings;

Description

This member is internal and not intended for use.


iAudioPolicyPrioritySettings

private: TMMFAudioPolicyPrioritySettings iAudioPolicyPrioritySettings;

Description

This member is internal and not intended for use.


iPlayedBytesCount

private: TInt iPlayedBytesCount;

Description

This member is internal and not intended for use.


iRecordedBytesCount

private: TInt iRecordedBytesCount;

Description

This member is internal and not intended for use.


iDeviceIsOpen

private: TBool iDeviceIsOpen;

Description

This member is internal and not intended for use.


iGain

private: TInt iGain;

Description

This member is internal and not intended for use.


iVolume

private: TInt iVolume;

Description

This member is internal and not intended for use.


iClientSessionId

private: TInt iClientSessionId;

Description

This member is internal and not intended for use.


iDevSoundInfo

private: TMMFDevSoundInfo iDevSoundInfo;

Description

This member is internal and not intended for use.


iReceivingEvents

private: TBool iReceivingEvents;

Description

This member is internal and not intended for use.


iCurrentGenerator

private: MMdaToneSynthesis* iCurrentGenerator;

Description

This member is internal and not intended for use.


iToneGen

private: TMdaSimpleToneGenerator iToneGen;

Description

This member is internal and not intended for use.


iDTMFGen

private: TMdaDTMFGenerator iDTMFGen;

Description

This member is internal and not intended for use.


iRepeatCount

private: TInt iRepeatCount;

Description

This member is internal and not intended for use.


iRepeatTrailingSilence

private: TTimeIntervalMicroSeconds iRepeatTrailingSilence;

Description

This member is internal and not intended for use.


iRampDuration

private: TTimeIntervalMicroSeconds iRampDuration;

Description

This member is internal and not intended for use.


iToneBuffer1

private: CMMFDataBuffer* iToneBuffer1;

Description

This member is internal and not intended for use.


iToneBuffer2

private: CMMFDataBuffer* iToneBuffer2;

Description

This member is internal and not intended for use.


iActiveToneBuffer

private: CMMFDataBuffer* iActiveToneBuffer;

Description

This member is internal and not intended for use.


iBuffer

private: CMMFDataBuffer* iBuffer;

Description

This member is internal and not intended for use.


iCMMFHwDevice

private: CMMFHwDevice* iCMMFHwDevice;

Description

This member is internal and not intended for use.


iMode

private: TMMFState iMode;

Description

This member is internal and not intended for use.


iDevInfo

private: THwDeviceInitParams iDevInfo;

Description

This member is internal and not intended for use.


iHwDeviceBuffer

private: CMMFDataBuffer* iHwDeviceBuffer;

Description

This member is internal and not intended for use.