devsound/devsoundrefplugin/src/swcodecwrapper/mmfSwCodecPlayDataPath.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __MMFSWCODECPLAYDATAPATH_H__
       
    17 #define __MMFSWCODECPLAYDATAPATH_H__
       
    18 
       
    19 
       
    20 #include "mmfSwCodecDataPath.h"
       
    21 #include <mmf/server/mmfswcodecwrapper.h>
       
    22 
       
    23 
       
    24 class CMMFSwCodecPlayDataPath; //fwd ref
       
    25 class CMMFSwCodecUtility;	// fwd ref
       
    26 class MEmptyBuffersCustomInterface;	// fwd ref
       
    27 class MSetVbrFlagCustomInterface;	// fwd ref
       
    28 
       
    29 /**
       
    30  * Active object used by the CMMFSwCodecPlayDataPath to send data to the sound
       
    31  * driver  This particular active object encapsulates the asynchronous play 
       
    32  * function, where a buffer of data is sent to the WINS audio device, and the
       
    33  * active object's RunL is called when the buffer has been consumed by the 
       
    34  * WINS audio device.
       
    35  * @internalComponent
       
    36  */
       
    37 class CDataPathPlayer : public CActive
       
    38 	{
       
    39 public:
       
    40 	CDataPathPlayer(CMMFSwCodecPlayDataPath& aParent, TInt aPriority);
       
    41 	~CDataPathPlayer();
       
    42 	void Start();
       
    43 	void ResumePlaying();
       
    44 	void PlayData(const CMMFDataBuffer& aData);
       
    45 	void Stop();
       
    46 	virtual void RunL();
       
    47 	virtual TInt RunError(TInt aError);
       
    48 	virtual void DoCancel();
       
    49 	virtual void Error(TInt aError);
       
    50 private:
       
    51 	CMMFSwCodecPlayDataPath& iParent;
       
    52 	const CMMFDataBuffer* iDataFromSource;
       
    53 	TBool iResumePlaying;
       
    54 	};
       
    55 
       
    56 /*
       
    57 * Active object used by CMMFSwCodecPlayDataPath to listening for error messages
       
    58 * from the WINS audio device.  If this object's RunL is called, playback has 
       
    59 * been terminated for some reason.  The active object then 
       
    60 * notifies its parent the datapath, so that proper cleanup and client 
       
    61 * notification can occur.
       
    62 * @internalComponent
       
    63 */
       
    64 class CSoundDevPlayErrorReceiver : public CActive
       
    65 	{
       
    66 public:
       
    67 	CSoundDevPlayErrorReceiver(CMMFSwCodecPlayDataPath& aParent, TInt aPriority);
       
    68 	~CSoundDevPlayErrorReceiver();
       
    69 	void Start();
       
    70 	void Stop();
       
    71 	virtual void RunL();
       
    72 	virtual void DoCancel();
       
    73 private:
       
    74 	CMMFSwCodecPlayDataPath& iParent;
       
    75 	};
       
    76 
       
    77 
       
    78 /**
       
    79  *  Derived class for play datapath internal to the Sw codec wrapper
       
    80  *  @internalComponent
       
    81  */
       
    82 class CMMFSwCodecPlayDataPath : public CMMFSwCodecDataPathX, 
       
    83 								public MEmptyBuffersCustomInterface, 
       
    84 								public MSetVbrFlagCustomInterface,
       
    85 								public MTimePlayedCustomInterface,
       
    86 								public MIgnoreUnderflowEventsCustomInterface
       
    87 	{ 
       
    88 public:	
       
    89 	static CMMFSwCodecPlayDataPath* NewL();
       
    90 	virtual ~CMMFSwCodecPlayDataPath(); 
       
    91 	virtual TInt SetObserver(MMMFHwDeviceObserver &aHwObserver);
       
    92 	virtual TInt AddCodec(CMMFSwCodec& aCodec);
       
    93 	virtual TInt Start();
       
    94 	virtual void Stop();
       
    95 	virtual void Pause();
       
    96 	virtual void BufferFilledL(CMMFDataBuffer& aBuffer);
       
    97 	virtual void BufferEmptiedL(const CMMFDataBuffer& aBuffer);
       
    98 	virtual void SoundDeviceException(TInt aError);
       
    99 	virtual RMdaDevSound& Device();
       
   100 	virtual void SetPlayCustomInterface(MPlayCustomInterface& aCustomInterface);
       
   101 	virtual TInt EmptyBuffers();
       
   102 	virtual TAny* CustomInterface(TUid aInterfaceId);
       
   103 	//From MSetVbrFlagCustomInterface
       
   104 	virtual void SetVbrFlag();
       
   105 	virtual TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
       
   106 	virtual void IgnoreUnderflowEvents();
       
   107 protected:	
       
   108 	CMMFSwCodecPlayDataPath() {};
       
   109 	void ConstructL();
       
   110 	void FillSourceBufferL();
       
   111 	void FillSoundDeviceBufferL();
       
   112 protected: 
       
   113 	CDataPathPlayer* iAudioPlayer;
       
   114 	CSoundDevPlayErrorReceiver* iSoundDeviceErrorReceiver;
       
   115 	RMdaDevSound iSoundDevice;
       
   116 	CMMFDataBuffer* iSourceBuffer;
       
   117 	CMMFDataBuffer* iSoundDeviceBuffer;
       
   118 	TBool iNoMoreSourceData;
       
   119 	TBool iSinkCanReceive;
       
   120 	TUint iSourceBufferSize;
       
   121 	TUint iSoundDevBufferSize;
       
   122 	CMMFSwCodecUtility* iUtility;
       
   123 	TBool iRampAudioSample;
       
   124 	MPlayCustomInterface* iCustomInterface;	// not owned
       
   125 	TTimeIntervalMicroSeconds iVolumeRamp;
       
   126 	// DEF048512
       
   127 	TInt iSampleRate;
       
   128 	TInt iChannels;
       
   129 	TBool iVbrFlag;
       
   130 	TInt64 iBytesPlayed;
       
   131 	TBool iNoMoreSoundDeviceData;
       
   132 	TBool iIgnoreUnderflow;
       
   133 	};
       
   134 
       
   135 #endif
       
   136