DevSound provides a common interface to the audio hardware for all audio functionality. DevSound is responsible for providing access to available audio resources, initialization and configuration of hardware devices, and playing and recording audio.
Before you start, you must:
DevSound's functionality is provided by the CMMFDevSound class.
Construction and initialization
Once created, the CMMFDevSound::InitializeL() method is used to initialize DevSound to play and record. There are three versions of the CMMFDevSound::InitializeL() method, differing in type and number of parameters. The three versions are:
CMMFDevSound::InitializeL() - initializes CMMFDevSound object to play and record PCM16 raw audio data with sampling rate of 8 KHz.
This method has two parameters:
MDevSoundObserver - a reference to a DevSound Observer instance.
TMMFState - the mode for which this object is to be used, for example, EMMFStatePlaying .
CMMFDevSound::InitializeL() - initializes DevSound object for the mode aMode for processing audio data with hardware device aHWDev .
This method has three parameters:
CMMFDevSound::InitializeL() - initializes DevSound object for the mode aMode for processing audio data with hardware device supporting FourCC aDesiredFourCC .
IMPORT_C void InitializeL(MDevSoundObserver &aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode);
This method has three parameters:
All versions of CMMFDevSound::InitializeL() require a reference to a DevSound Observer instance. As soon as initialization of DevSound has completed, successfully or otherwise, the callback function MDevSoundObserver::InitializeComplete() is called.
The DevSound Observer
Most methods in the CMMFDevSound class are asynchronous. Callbacks occur through the MDevSoundObserver class. MDevSoundObserver is an interface to a set of DevSound callback functions. It serves as the method of communication between the client and the DevSound. A class that uses DevSound will typically inherit from MDevSoundObserver .
Refer to the following sections for detailed information on how to use the main features of DevSound:
These examples describe some different uses of DevSound:
Recording a WAV file
In this example, a client application wants to record a WAV file. As WAV is a standard file format supported by the MMF controller framework, the CMdaAudioRecorderUtility client API is used to interact with DevSound.
The main steps in recording the WAV file are:
The client application gives a request to record to the MMF CMdaAudioRecorderUtility client API.
The MMF CMdaAudioRecorderUtility client API passes the command down through the controller framework to the MMF controller plug-in.
The MMF controller plug-in initializes DevSound for recording.
Recording starts and continues until the client stops the recording or the limit on the file size is reached.
Upon completion, the client gives a request to the MMF controller framework to stop the recording. The controller framework passes the command down to the MMF controller plug-in.
The MMF controller plug-in stops DevSound and sends the completion event back to the client via controller framework.
Playing a DTMF tone
In this example, a client application wants to play a Dual-Tone Multi-Frequency (DTMF) tone. The MMF CMdaAudioToneUtility client API is used to play the DTMF tone. Unlike other MMF APIs, the CMdaAudioToneUtility does not require a controller plug-in. This is because the input and output of the API is already in a known data format and does not require encoding or decoding. The CMdaAudioToneUtility communicates directly with DevSound.
The main steps in playing the DTMF tone are:
The client application prepares the CMdaAudioToneUtility to play a DTMF tone.
The client application asks the CMdaAudioToneUtility to start playing the tone.
The CMdaAudioToneUtility asks DevSound to play the tone.
The CMdaAudioToneUtility informs the client application that the playing of the tone is complete.
Playing an AVI file
In this example, a client application wants to play an Audio Video Interleaved (AVI) file; output is to a screen and speakers. The AVI file contains audio and video data, so the CVideoPlayerUtility class that can manipulate both types of data is used.
The main steps in playing the AVI file are:
The client application requests to play an AVI file to the MMF CVideoPlayerUtility class.
The MMF CVideoPlayerUtility class passes the request to the MMF controller framework. The controller framework loads the AVI controller
The AVI controller plug-in initializes the DevSound and DevVideo.
The AVI controller plug-in reads the data in the AVI file and sends the audio data to DevSound and the video data to DevVideo.
DevSound outputs the audio data.
DevVideo sends the video data to be decoded to the corresponding codec. The decoded video data is then displayed on the screen.
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.