class CMdaAudioOutputStream : public CBase |
The interface to an audio stream player passing raw audio data from specified buffers to the audio hardware.
This class enables MMF clients to:
Stream raw audio data to the audio hardware from specified buffers
Specify the priority of the audio stream in relation to other clients that may request to use the same audio hardware
Set the sample rate and the number of channels after successfully opening the stream. It is not possible to change these values once streaming has started.
Change the volume and balance before or while the stream is open for writing. Volume and balance settings take effect immediately.
The API supports callbacks from the server to notify the client:
MaoscOpenComplete() will be called when the audio streaming object is open and ready to stream data back to the audio hardware as a result of a previous call to Open().
MaoscBufferCopied() will be called each time audio data has been successfully copied to the lower layers of the MMF as a result of a previous WriteL().
MaoscPlayComplete() will be called when the audio data stream has been closed as a result of a previous Stop().
Public Member Functions | |
---|---|
~CMdaAudioOutputStream() | |
IMPORT_C TInt | CancelRegisterAudioResourceNotification(TUid) |
IMPORT_C TAny * | CustomInterface(TUid) |
IMPORT_C TFourCC | DataType() |
IMPORT_C TInt | GetBalanceL() |
IMPORT_C TInt | GetBytes() |
IMPORT_C TInt | KeepOpenAtEnd() |
TInt | MaxVolume() |
IMPORT_C CMdaAudioOutputStream * | NewL(MMdaAudioOutputStreamCallback &, CMdaServer *) |
IMPORT_C CMdaAudioOutputStream * | NewL(MMdaAudioOutputStreamCallback &, TInt, TInt) |
void | Open(TMdaPackage *) |
IMPORT_C TInt | Pause() |
const TTimeIntervalMicroSeconds & | Position() |
IMPORT_C TInt | RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback &, TUid, const TDesC8 &) |
IMPORT_C TInt | RequestStop() |
IMPORT_C TInt | Resume() |
void | SetAudioPropertiesL(TInt, TInt) |
IMPORT_C void | SetBalanceL(TInt) |
IMPORT_C void | SetDataTypeL(TFourCC) |
void | SetPriority(TInt, TInt) |
void | SetVolume(const TInt) |
void | Stop() |
TInt | Volume() |
IMPORT_C TInt | WillResumePlay() |
void | WriteL(const TDesC8 &) |
Private Member Functions | |
---|---|
CMdaAudioOutputStream() |
Private Attributes | |
---|---|
CMMFMdaAudioOutputStream * | iProperties |
~CMdaAudioOutputStream | ( | ) |
Destructor.
Frees all resources owned by the object prior to its destruction.
IMPORT_C TInt | CancelRegisterAudioResourceNotification | ( | TUid | aNotificationEventId | ) |
Cancels the registered notification event.
TUid aNotificationEventId | The Event to notify the client. |
IMPORT_C TAny * | CustomInterface | ( | TUid | aInterfaceId | ) |
Retrieves a custom interface to the underlying device.
TUid aInterfaceId | The interface UID, defined with the custom interface. |
IMPORT_C TInt | KeepOpenAtEnd | ( | ) |
When this method is called, AudioOutputStream goes into a different mode wherein it does not call MaoscPlayComplete() with KErrUnderflow when all the supplied data has been played. Instead client should signal the end of the play by calling RequestStop() or Stop() on AudioOutputStream. If the client calls RequestStop(), AudioOutputStream waits until all the queued data has been played out and then calls MaoscPlayComplete(). This behaviour is different from that of Stop(), which stops the play immediately by discarding all the queued data.
Client should call this method on CMdaAudioOutputStream just after its construction and its effect remains through out its lifetime.
Note: This feature is supported only on a DevSound which ignores the underflow errors in the middle of the play i.e which returns ETrue from QueryIgnoresUnderflow().
CMdaAudioOutputStream::RequestStop() CMMFDevSound::QueryIgnoresUnderflow()
IMPORT_C CMdaAudioOutputStream * | NewL | ( | MMdaAudioOutputStreamCallback & | aCallBack, |
CMdaServer * | aServer = NULL | |||
) | [static] |
Allocates and constructs an audio stream player object.
Static NewL
MMdaAudioOutputStreamCallback & aCallBack | A callback to notify the client when the sound device is open and ready to receive data, when each descriptor has been copied and when the stream is closed. The caller must create a callback class which implements this interface. |
CMdaServer * aServer = NULL | A pointer to a CMdaServer. CMdaServer is deprecated and as such this parameter is only provided for backward compatibility. |
IMPORT_C CMdaAudioOutputStream * | NewL | ( | MMdaAudioOutputStreamCallback & | aCallBack, |
TInt | aPriority, | |||
TInt | aPref = EMdaPriorityPreferenceTimeAndQuality | |||
) | [static] |
Constructs and initialises a new instance of an audio streaming object.
The function leaves if the audio streaming object cannot be created.
Note: The Priority Value and Priority Preference are used primarily when deciding what to do when several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference, the adaptation may consider other parameters such as the SecureId and Capabilities of the client process. Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may vary between different phones. Portable applications are advised not to assume any specific behaviour.
Static NewL
MMdaAudioOutputStreamCallback & aCallBack | A callback to notify the client when the sound device is open and ready to receive data, when each descriptor has been copied and when the stream is closed. The caller must create a callback class which implements this interface. |
TInt aPriority | The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request. |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality | The Priority Preference - an additional audio policy parameter. The suggested default is EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional values may be supported by given phones and/or platforms, but should not be depended upon by portable code. |
void | Open | ( | TMdaPackage * | aSettings | ) | [virtual] |
Opens an output audio stream package.
The MMdaAudioOutputStreamCallback::MaoscOpenComplete() callback function is called when the stream has been opened and is ready to receive audio data. If the open was unsuccessful, this is indicated by the aError parameter of the callback.
TMdaPackage * aSettings | A pointer to a TMdaPackage object. |
const TTimeIntervalMicroSeconds & | Position | ( | ) | [virtual] |
Returns the current position within the data stream.
IMPORT_C TInt | RegisterAudioResourceNotification | ( | MMMFAudioResourceNotificationCallback & | aCallback, |
TUid | aNotificationEventUid, | |||
const TDesC8 & | aNotificationRegistrationData = KNullDesC8 | |||
) |
Registers the Event for Notification when resource is avaliable. Registers the Event for Notification when resource is avaliable.
MMMFAudioResourceNotificationCallback & aCallback | The audio player observer interface. |
TUid aNotificationEventUid | The event uid to notify the client. |
const TDesC8 & aNotificationRegistrationData = KNullDesC8 | Notification registration specific data. |
IMPORT_C TInt | RequestStop | ( | ) |
This method signals the end of play when the AudioOutputStream is in KeepOpenAtEnd mode i.e when client makes KeepOpenAtEnd call on it. When RequestStop is called, AudioOutputStream completes playing all the data that is supplied to it and calls MaoscPlayComplete() with KErrUnderflow.
Note: Before calling this method, client must have already called KeepOpenAtEnd() successfully, Otherwise, this method returns KErrNotSupported. It is recommended to use KeepOpenAtEnd and RequestStop calls to get a predictable behaviour during stopping.
void | SetAudioPropertiesL | ( | TInt | aSampleRate, |
TInt | aChannels | |||
) | [virtual] |
Sets the sample rate and number of audio channels.
IMPORT_C void | SetBalanceL | ( | TInt | aBalance = KMMFBalanceCenter | ) |
Sets the audio balance.
TInt aBalance = KMMFBalanceCenter | A specified balance volume. Default is KMMFBalanceCenter. |
IMPORT_C void | SetDataTypeL | ( | TFourCC | aAudioType | ) |
Sets the data type. If the data type is not explicitly set it will assumed to be pcm16. If it is set then the hardware must support the data type being set otherwise the function leaves with KErrNotSupported.
TFourCC aAudioType | The fourCC code used to specify the data type of the streamed audio |
void | SetPriority | ( | TInt | aPriority, |
TInt | aPref | |||
) | [virtual] |
void | SetVolume | ( | const TInt | aNewVolume | ) | [virtual] |
Sets the audio volume.
Set the volume to zero for "sound off" or any other value between 1 and MaxVolume().
const TInt aNewVolume | A specified audio volume. |
IMPORT_C TInt | WillResumePlay | ( | ) |
Waits for the client to resume the play even after the default timer expires.
void | WriteL | ( | const TDesC8 & | aData | ) | [virtual] |
Writes (plays) streaming raw audio data.
This function is asynchronous. When aData has been received, the client is notified by a call to MMdaAudioOutputStreamCallback::MaoscBufferCopied(). The client can call WriteL() again before this notification takes place because the buffers are maintained in a client-side queue until they have been sent. An active object performs the notification, and copies the next item in the queue to the server. MMdaAudioOutputStreamCallback::MaoscPlayComplete() is called when all descriptors have been sent.
const TDesC8 & aData | A reference to the stream data. |
CMMFMdaAudioOutputStream * | iProperties | [private] |
This member is internal and not intended for use.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.