Archived:Controlling audio routing in S60 3rd Edition FP1
In S60 3rd Edition, Feature Pack 1 devices, audio output (playback) routing can be controlled with the Audio Output Routing API, included in the Extensions plug-in package for S60 3rd Edition SDK for Symbian OS, for C++, supporting Feature Pack 1.
When playing audio using either CMdaAudioPlayerUtility, CMdaAudioRecorderUtility, CMdaAudioOutputStream, or CMMFDevSound, the audio will be routed to the loudspeaker by default. When a headset or another accessory is connected, the audio is routed to the headset automatically.
The Audio Output Routing API provides means to change the routing from the default.
When no headset is connected, audio can be routed to the earpiece using the SetAudioOutputL() function in AudioOutput.h. Likewise, audio can be routed to the loudspeaker even when a headset is connected.
AudioOutput.h, part of the Audio Output Routing API, is included in the Extensions plug-in package for S60 3rd Edition SDK for Symbian OS, for C++, supporting Feature Pack 1.
Once the audio playback is started with CMdaAudioPlayerUtility, create a CAudioOutput instance and pass a reference of the player utility to it. The output routing can be now controlled with the TAudioOutputPreference parameter, passed to the SetAudioOutputL() function:
void CMySound::SetRoutingL(CAudioOutput::TAudioOutputPreference aAudioOutput)
iAudioOutput = CAudioOutput::NewL(*iMyAudioPlayerUtility);
CAudioOutput provides NewL contructors also for other audio playback classes in addition to CMdaAudioPlayerUtility.
Description of the different routing options in TAudioOutputPreference
ENoPreference, // Used to indicate that the playing audio can be routed to
// any speaker. This is the default value for audio.
EAll, // Used to indicate that the playing audio should be routed
// to all speakers.
ENoOutput, // Used to indicate that the playing audio should not be
// routed to any output.
EPrivate, // Used to indicate that the playing audio should be routed
// to the default private speaker. A private speaker is one
// that can only be heard by one person.
EPublic // Used to indicate that the playing audio should be routed
// to the default public speaker. A public speaker is one
// that can be heard by multiple people.
Note that the AudioOutputRouting API does not provide a constructor for the CVideoPlayerUtility instance. Therefore routing of the audio track of video clips cannot be controlled.