sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: sl@0: #ifndef MDASOUNDADAPTER_H sl@0: #define MDASOUNDADAPTER_H sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: #define MDADEVSOUNDNAME _L8("RMdaDevSound") sl@0: sl@0: /* sl@0: Adapter class which routes the calls on RMdaDevSound(old sound driver interface) to RSoundSc(new sound driver interface). sl@0: The purpose of this class is to use the new sound driver in MDF without changing the calling code. This class sl@0: does not support any new functionalities supported by the shared chunk sound driver but supports the functionality of the sl@0: of the old driver with the new driver. sl@0: */ sl@0: class RMdaDevSound sl@0: { sl@0: class CBody; sl@0: public: sl@0: /* sl@0: enum for major, minor and build version of sound device driver. sl@0: */ sl@0: enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber}; sl@0: /* sl@0: enum for sound media device play/record request. sl@0: */ sl@0: enum TMdaRequest sl@0: { sl@0: /* Play data request */ sl@0: EMdaRequestPlayData, sl@0: /* Play error notification */ sl@0: EMdaRequestPlayErrorNotification, sl@0: /* Record data request */ sl@0: EMdaRequestRecordData, sl@0: /* Record error notification */ sl@0: EMdaRequestRecordErrorNotification sl@0: }; sl@0: sl@0: /* enum for media device control request */ sl@0: enum TMdaControl sl@0: { sl@0: /* play format (capability) supported request */ sl@0: EMdaControlPlayFormatsSupported, sl@0: /* get the current play format request */ sl@0: EMdaControlGetPlayFormat, sl@0: /* set the play format request */ sl@0: EMdaControlSetPlayFormat, sl@0: /* get play volume request */ sl@0: EMdaControlGetPlayVolume, sl@0: /* set play volume request */ sl@0: EMdaControlSetPlayVolume, sl@0: /* record format supported request */ sl@0: EMdaControlRecordFormatsSupported, sl@0: /* get the current record format request */ sl@0: EMdaControlGetRecordFormat, sl@0: /* set record format request */ sl@0: EMdaControlSetRecordFormat, sl@0: /* get record volume request */ sl@0: EMdaControlGetRecordLevel, sl@0: /* set record volume request */ sl@0: EMdaControlSetRecordLevel, sl@0: /* stop play request */ sl@0: EMdaControlFlushPlayBuffer, sl@0: /* stop record request */ sl@0: EMdaControlFlushRecordBuffer, sl@0: /* bytes played request */ sl@0: EMdaControlBytesPlayed, sl@0: /* set base value for the bytes played */ sl@0: EMdaControlResetBytesPlayed, sl@0: /* Investigate for sound media driver request */ sl@0: EMdaControlIsMdaSound, sl@0: /* pause play request */ sl@0: EMdaControlPausePlayBuffer, sl@0: /* resume play request */ sl@0: EMdaControlResumePlaying sl@0: }; sl@0: sl@0: /* sl@0: This enum corresponds to supported sound encoding schemes sl@0: */ sl@0: enum TMdaSoundEncoding sl@0: { sl@0: /* sound encoding(compression) using 8 bit PCM (pulse code modulation) */ sl@0: EMdaSoundEncoding8BitPCM = 0x00000001, sl@0: /* sound encoding using 16 bit PCM */ sl@0: EMdaSoundEncoding16BitPCM = 0x00000002, sl@0: /* sound encoding using 8 bit A law */ sl@0: EMdaSoundEncoding8BitALaw = 0x00000004, sl@0: /* sound encoding using 8 bit Mu law */ sl@0: EMdaSoundEncoding8BitMuLaw = 0x00000008, sl@0: }; sl@0: sl@0: /* sl@0: This class corresponds to a supported sound format. sl@0: The format describes the supported audio device's min/max sampling rate, encoding, channels and buffer size of play/record and volume. sl@0: */ sl@0: class TSoundFormatsSupported sl@0: { sl@0: public: sl@0: /* sl@0: This corresponds to minimum sample rate supported. This depends on the physical sound device used(example: 8000 hertz). sl@0: */ sl@0: TInt iMinRate; sl@0: sl@0: /* sl@0: This corresponds to maximum sample rate supported. This depends on the physical sound device used(example: 48000 hertz). sl@0: */ sl@0: TInt iMaxRate; sl@0: sl@0: /* sl@0: This corresponds to encoding format supported. sl@0: @see TMdaSoundEncoding sl@0: */ sl@0: TUint32 iEncodings; sl@0: sl@0: /* sl@0: This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound. sl@0: Also this depends on the physical device used. sl@0: */ sl@0: TInt iChannels; sl@0: sl@0: /* sl@0: This corresponds to minimum buffer size. This depends on the physical device used and sampling rate adapted. sl@0: @see KSoundMinBufferSize sl@0: */ sl@0: TInt iMinBufferSize; sl@0: sl@0: /* sl@0: This corresponds to maximum buffer size.This depends on the physical device used and sampling rate adapted. sl@0: @see KSoundPlayBufferSize sl@0: @see KSoundRecordBufferSize sl@0: */ sl@0: TInt iMaxBufferSize; sl@0: sl@0: /* sl@0: This corresponds to minimum play/record volume. sl@0: */ sl@0: TInt iMinVolume; sl@0: sl@0: /* sl@0: This corresponds to maximum play/record volume. sl@0: */ sl@0: TInt iMaxVolume; sl@0: }; sl@0: sl@0: /* A typedef'd packaged RMdaDevSound::TSoundFormatsSupported for passing through a generic API method */ sl@0: typedef TPckgBuf TSoundFormatsSupportedBuf; sl@0: sl@0: /* sl@0: This class corresponds to current supported sound format. sl@0: The format describes the supported audio device's sampling rate, encoding, channels and buffer size of play/record. sl@0: */ sl@0: class TCurrentSoundFormat sl@0: { sl@0: public: sl@0: /* sl@0: This corresponds to sound sampling rate like (44000 Hertz, 8000 Hertz). The possible values depends on the physical device used. sl@0: */ sl@0: TInt iRate; sl@0: sl@0: /* sl@0: @see TMdaSoundEncoding sl@0: */ sl@0: TMdaSoundEncoding iEncoding; sl@0: sl@0: /* sl@0: This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound. sl@0: Also this depends on the physical device used. sl@0: */ sl@0: TInt iChannels; sl@0: sl@0: /* sl@0: Play or Record buffer size. The possible value depends on the physical device used. sl@0: */ sl@0: TInt iBufferSize; sl@0: }; sl@0: sl@0: /* A typedef'd packaged RMdaDevSound::TCurrentSoundFormat for passing through a generic API method */ sl@0: typedef TPckgBuf TCurrentSoundFormatBuf; sl@0: public: sl@0: IMPORT_C RMdaDevSound(); sl@0: IMPORT_C TInt Open(TInt aUnit=KNullUnit); sl@0: IMPORT_C TVersion VersionRequired() const; sl@0: IMPORT_C TInt IsMdaSound(); sl@0: IMPORT_C void PlayFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported); sl@0: IMPORT_C void GetPlayFormat(TCurrentSoundFormatBuf& aFormat); sl@0: IMPORT_C TInt SetPlayFormat(const TCurrentSoundFormatBuf& aFormat); sl@0: IMPORT_C TInt PlayVolume(); sl@0: // This function mimics RMdaDevSound interface with linear volume semantics sl@0: IMPORT_C void SetPlayVolume(TInt aLinearVolume); sl@0: // This function supports volume change with logarithmic semantics sl@0: IMPORT_C void SetVolume(TInt aLogarithmicVolume); sl@0: IMPORT_C void PlayData(TRequestStatus& aStatus,const TDesC8& aData); sl@0: IMPORT_C void CancelPlayData(); sl@0: IMPORT_C void NotifyPlayError(TRequestStatus& aStatus); sl@0: IMPORT_C void CancelNotifyPlayError(); sl@0: sl@0: IMPORT_C void RecordFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported); sl@0: IMPORT_C void GetRecordFormat(TCurrentSoundFormatBuf& aFormat); sl@0: IMPORT_C TInt SetRecordFormat(const TCurrentSoundFormatBuf& aFormat); sl@0: IMPORT_C TInt RecordLevel(); sl@0: IMPORT_C void SetRecordLevel(TInt aLevel); sl@0: IMPORT_C void RecordData(TRequestStatus& aStatus,TDes8& aData); sl@0: IMPORT_C void CancelRecordData(); sl@0: IMPORT_C void NotifyRecordError(TRequestStatus& aStatus); sl@0: IMPORT_C void CancelNotifyRecordError(); sl@0: sl@0: IMPORT_C void FlushPlayBuffer(); sl@0: IMPORT_C void FlushRecordBuffer(); sl@0: IMPORT_C TInt BytesPlayed(); sl@0: IMPORT_C void ResetBytesPlayed(); sl@0: IMPORT_C void PausePlayBuffer(); sl@0: IMPORT_C void ResumePlaying(); sl@0: IMPORT_C void ResumePlaying(TRequestStatus&); sl@0: IMPORT_C void Close(); sl@0: IMPORT_C TInt Handle(); sl@0: IMPORT_C void PauseRecordBuffer(); sl@0: IMPORT_C void ResumeRecording(); sl@0: IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTimePlayed); sl@0: private: sl@0: CBody* iBody; sl@0: }; sl@0: sl@0: #endif sl@0: