Archived:Controlling audio routing in S60 3rd Edition FP1
Article Metadata
Compatibility
Article
Overview
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.
Description
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.
Solution
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);
iAudioOutput->SetAudioOutputL(aAudioOutput);
}
CAudioOutput provides NewL contructors also for other audio playback classes in addition to CMdaAudioPlayerUtility.
Description of the different routing options in TAudioOutputPreference
enum 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.


This looks like a very cool API - however, we have a CVideoPlayerUtility and we want to control its audio routing and unfortunately there doesn't seem to be constructor for it - any ideas?
Thank you for your feedback. The AudioOutputRouting API does not provide a constructor for the CVideoPlayerUtility instance. Therefore routing of the audio track of video clips cannot be controlled.
Forum Nokia KB 11:20, 16 October 2007 (UTC)