sl@0: /* sl@0: * Copyright (c) 2006-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: sl@0: sl@0: sl@0: #ifndef CDEVPLAYCONTROL_H sl@0: #define CDEVPLAYCONTROL_H sl@0: sl@0: #include sl@0: sl@0: #include "cdevcommoncontrol.h" sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: class MMMFBufferSource; sl@0: sl@0: /** sl@0: * CDevPlayControl. sl@0: * sl@0: * ?description sl@0: * sl@0: * @lib mmfdevsoundadaptation.lib sl@0: * @since sl@0: */ sl@0: sl@0: NONSHARABLE_CLASS(CDevPlayControl) :public CDevCommonControl, sl@0: public MMMFAudioDataSupplier sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: * Destructor. sl@0: * Releases all resources and deletes all objects owned by this instance. sl@0: */ sl@0: ~CDevPlayControl(); sl@0: sl@0: static CDevPlayControl* NewL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aDevSoundObserver); sl@0: sl@0: void ConstructL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aAdaptationObserver); sl@0: sl@0: // from base class CDevAudioControl sl@0: sl@0: /** sl@0: * Initialize playing state control components sl@0: * @since sl@0: * @return error code sl@0: */ sl@0: virtual TInt Initialize(TUid aFormat); sl@0: sl@0: /** sl@0: * Initializes the audio device and starts the play process. This sl@0: * function queries and acquires the audio policy before initializing sl@0: * audio device. If there was an error during policy initialization, sl@0: * PlayError() function will be called on the observer with error code sl@0: * KErrAccessDenied, otherwise BufferToBeFilled() function will be called sl@0: * with a buffer reference. After reading data into the buffer reference sl@0: * passed, the client should call PlayData() to play data. sl@0: * The amount of data that can be played is specified in sl@0: * CMMFBuffer::RequestSize(). Any data that is read into buffer beyond sl@0: * this size will be ignored. sl@0: * Leaves on failure. sl@0: * @since sl@0: * @return void sl@0: */ sl@0: virtual TInt ProcessInit(); sl@0: sl@0: /** sl@0: * Plays data in the buffer at the current volume. sl@0: * The client should fill the buffer with audio data before calling this sl@0: * function. The observer gets a reference to the buffer along with the sl@0: * callback function BufferToBeFilled(). When playing of the audio sample sl@0: * is complete, successfully or otherwise, the function PlayError() on sl@0: * the observer is called. sl@0: * The last buffer of the audio stream being played should have the last sl@0: * buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a sl@0: * subsequent attempt to play the clip is made, this flag will need sl@0: * resetting by the client. sl@0: * @return void sl@0: */ sl@0: virtual void ProcessData(); sl@0: sl@0: /* sl@0: Call-back indicating that is the last buffer has been processed sl@0: */ sl@0: virtual void ProcessingFinished (MAudioStream& aStream); sl@0: sl@0: // from base class MAudioDataSupplier sl@0: sl@0: /** sl@0: * Request a buffer to be filled with audio data by the data supplier. sl@0: * sl@0: * The supplier should fill the buffer as quickly as possible and then call sl@0: * MBufferSource::BufferFilled() passing the filled buffer as a parameter. sl@0: * sl@0: * @param aSource a pointer to the source requesting the buffer sl@0: * @param aBuffer a pointer to the buffer to fill sl@0: */ sl@0: virtual void BufferToBeFilled(MMMFBufferSource* aSource, CMMFBuffer* aBuffer); sl@0: sl@0: /** sl@0: * Indicates that all buffers previously requested by this source have become sl@0: * invalid and must not be used. sl@0: * sl@0: * @param aSource the source whose previous buffer requests should be ignored. sl@0: */ sl@0: virtual void DiscardBuffers(MMMFBufferSource* aSource); sl@0: sl@0: // from base class CDevCommonControl sl@0: void FinishWithError(TInt aError); sl@0: sl@0: /** sl@0: * Called when a ProcessingFinished callback is received sl@0: * sl@0: * @since sl@0: * @param TBool& aAyncCompletion sl@0: * @return an error code KErrNone if successful sl@0: */ sl@0: virtual TInt ProcessingFinishedReceived(TBool& aAyncCompletion); sl@0: sl@0: /* sl@0: Used to send a stop call when there is a error in the buffer sl@0: */ sl@0: void BufferErrorEvent(); sl@0: sl@0: virtual TInt ProcessingError(TBool& aAyncCompletion); sl@0: sl@0: private: sl@0: CDevPlayControl(); sl@0: sl@0: private: // data sl@0: sl@0: /** sl@0: * Casted convenience pointer to DevAudio::iAudioSource sl@0: * Not own. sl@0: */ sl@0: MMMFBufferSource *iBufferSource; sl@0: sl@0: }; sl@0: sl@0: #endif // CDEVPLAYCONTROL_H