Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: mdaaudiooutputstream.h
Link against: mediaclientaudiostream.lib

Class CMdaAudioOutputStream

CMdaAudioOutputStream

Support

Supported from 6.1

Description

The interface to an audio stream player.

The class is abstract with a static factory function that returns an instance of a concrete derived class. The concrete derived class is not visible to the user.

This class allows media server clients to:

The API supports callbacks from the server to notify the client:

Derivation

CBaseBase class for all classes to be instantiated on the heap
CMdaAudioOutputStreamThe interface to an audio stream player

Defined in CMdaAudioOutputStream:
MaxVolume(), NewL(), Open(), Position(), SetAudioPropertiesL(), SetPriority(), SetVolume(), Stop(), Volume(), WriteL()

Inherited from CBase:
operator new()


Construction and destruction


NewL()

static CMdaAudioOutputStream* NewL(MMdaAudioOutputStreamCallback& aCallBack,CMdaServer* aServer=NULL);

Description

Static factory function that allocates and constructs an audio stream player and, if necessary, connects to the media server.

Parameters

MMdaAudioOutputStreamCallback& aCallBack

A callback to notify the client when the sound device has stopped playing sound, when each descriptor has been copied to the server, and when the audio streaming object in the server has been opened. The caller must create a callback class which implements this interface.

CMdaServer* aServer=NULL

An optional pointer to a connected session with the media server. A NULL pointer is the default, which means that a connection with the media server is made and owned by the audio output player object. If not NULL, the client is responsible for the pointer and must delete it after use.

Return value

CMdaAudioOutputStream*

The new audio stream player.

Notes:

[Top]


Audio configuration


SetAudioPropertiesL()

virtual void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels) = 0;

Description

Changes the sample rate and number of channels.

Writing to the stream must have stopped before you call this function.

Parameters

TInt aSampleRate

The new sample rate. For possible values, see the TAudioCaps enum in class TMdaAudioDataSettings.

TInt aChannels

The new number of channels. For possible values, see the TAudioCaps enum in class TMdaAudioDataSettings.

Leave codes

KErrNotSupported

Either the number of channels or the sample rate specified is not supported by the sound output device.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.

CMdaAudioOutputStream 0

The stream is busy.

See also:


SetPriority()

virtual void SetPriority(TInt aPriority, TMdaPriorityPreference aPref) = 0;

Description

Sets the client's priority.

This is used to resolve conflicts when more than one client tries to access the sound output device at the same time.

Parameters

TInt aPriority

The client's priority. The possible values are defined by the TMdaPriority enumeration.

TMdaPriorityPreference aPref

The priority preference. This defines the required behaviour if a higher priority client takes over the sound output device.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.

CMdaAudioOutputStream 10

The new priority is not within the range EMdaPriorityMin to EMdaPriorityMax, inclusive.

Notes:

See also:


MaxVolume()

virtual TInt MaxVolume() = 0;

Description

Gets the audio stream player's maximum volume.

This is the maximum value that can be passed to SetVolume().

Return value

TInt

The audio stream player's maximum volume. After calling Open(), this is always equal to or greater than one.


Volume()

virtual TInt Volume() = 0;

Description

Gets the audio stream player's current volume.

The volume is initialised by the server when Open() is called. The client can then change it by calling SetVolume().

Return value

TInt

The current value for the volume.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.


SetVolume()

virtual void SetVolume(const TInt aNewVolume) = 0;

Description

Changes the volume.

This can be called before or during playback.

Parameters

const TInt aNewVolume

The new volume. Must be between 0 and the result returned by MaxVolume().

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.

CMdaAudioOutputStream 4

The new volume setting is out of range.

[Top]


Streaming data


Open()

virtual void Open(TMdaPackage* aSettings) = 0;

Description

Opens the audio output stream.

This function must be called before the stream player can be used. The stream is opened asynchronously, using an active object. On completion, MMdaAudioOutputStreamCallback::MaoscOpenComplete() is called.

Parameters

TMdaPackage* aSettings

Contains the audio settings which are used to configure the device. This must be an object of type TMdaAudioDataSettings.

Panic codes

CMdaAudioOutputStream 8

The audio stream player is already open (Open() has already been called).


WriteL()

virtual void WriteL(const TDesC8& aData) = 0;

Description

Writes data to the audio output stream, via the media server.

This function is asynchronous. When aData has been received by the server, 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. MaoscPlayComplete() is called when all descriptors have been sent.

Parameters

const TDesC8& aData

A descriptor containing the sound data to send to the audio output stream.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.


Position()

virtual const TTimeIntervalMicroSeconds& Position() = 0;

Description

Gets the current position in the stream.

This is the amount of time the stream has been playing sound, as a microseconds time interval.

Return value

TTimeIntervalMicroSeconds&

The amount of time played in microseconds.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.


Stop()

virtual void Stop() = 0;

Description

Ends audio playback.

The function has no effect if the stream is open but playback is not taking place.

Any descriptors in the queue are discarded and MMdaAudioOutputStreamCallback::MaoscBufferCopied() is called with the address of the last descriptor sent and an error value of KErrAbort.

Panic codes

CMdaAudioOutputStream 6

The stream is not yet open.