1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/a3fdevsound/src/devsoundadaptor/cdevplaycontrol.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,158 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +#ifndef CDEVPLAYCONTROL_H
1.25 +#define CDEVPLAYCONTROL_H
1.26 +
1.27 +#include <e32base.h>
1.28 +
1.29 +#include "cdevcommoncontrol.h"
1.30 +
1.31 +#include <a3f/maudiodatasupplier.h>
1.32 +#include <a3f/maudioprocessingunitobserver.h>
1.33 +#include <a3f/a3f_trace_utils.h>
1.34 +
1.35 +
1.36 +class MMMFBufferSource;
1.37 +
1.38 +/**
1.39 + * CDevPlayControl.
1.40 + *
1.41 + * ?description
1.42 + *
1.43 + * @lib mmfdevsoundadaptation.lib
1.44 + * @since
1.45 + */
1.46 +
1.47 +NONSHARABLE_CLASS(CDevPlayControl) :public CDevCommonControl,
1.48 + public MMMFAudioDataSupplier
1.49 + {
1.50 +public:
1.51 +
1.52 + /**
1.53 + * Destructor.
1.54 + * Releases all resources and deletes all objects owned by this instance.
1.55 + */
1.56 + ~CDevPlayControl();
1.57 +
1.58 + static CDevPlayControl* NewL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aDevSoundObserver);
1.59 +
1.60 + void ConstructL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aAdaptationObserver);
1.61 +
1.62 + // from base class CDevAudioControl
1.63 +
1.64 + /**
1.65 + * Initialize playing state control components
1.66 + * @since
1.67 + * @return error code
1.68 + */
1.69 + virtual TInt Initialize(TUid aFormat);
1.70 +
1.71 + /**
1.72 + * Initializes the audio device and starts the play process. This
1.73 + * function queries and acquires the audio policy before initializing
1.74 + * audio device. If there was an error during policy initialization,
1.75 + * PlayError() function will be called on the observer with error code
1.76 + * KErrAccessDenied, otherwise BufferToBeFilled() function will be called
1.77 + * with a buffer reference. After reading data into the buffer reference
1.78 + * passed, the client should call PlayData() to play data.
1.79 + * The amount of data that can be played is specified in
1.80 + * CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
1.81 + * this size will be ignored.
1.82 + * Leaves on failure.
1.83 + * @since
1.84 + * @return void
1.85 + */
1.86 + virtual TInt ProcessInit();
1.87 +
1.88 + /**
1.89 + * Plays data in the buffer at the current volume.
1.90 + * The client should fill the buffer with audio data before calling this
1.91 + * function. The observer gets a reference to the buffer along with the
1.92 + * callback function BufferToBeFilled(). When playing of the audio sample
1.93 + * is complete, successfully or otherwise, the function PlayError() on
1.94 + * the observer is called.
1.95 + * The last buffer of the audio stream being played should have the last
1.96 + * buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
1.97 + * subsequent attempt to play the clip is made, this flag will need
1.98 + * resetting by the client.
1.99 + * @return void
1.100 + */
1.101 + virtual void ProcessData();
1.102 +
1.103 + /*
1.104 + Call-back indicating that is the last buffer has been processed
1.105 + */
1.106 + virtual void ProcessingFinished (MAudioStream& aStream);
1.107 +
1.108 + // from base class MAudioDataSupplier
1.109 +
1.110 + /**
1.111 + * Request a buffer to be filled with audio data by the data supplier.
1.112 + *
1.113 + * The supplier should fill the buffer as quickly as possible and then call
1.114 + * MBufferSource::BufferFilled() passing the filled buffer as a parameter.
1.115 + *
1.116 + * @param aSource a pointer to the source requesting the buffer
1.117 + * @param aBuffer a pointer to the buffer to fill
1.118 + */
1.119 + virtual void BufferToBeFilled(MMMFBufferSource* aSource, CMMFBuffer* aBuffer);
1.120 +
1.121 + /**
1.122 + * Indicates that all buffers previously requested by this source have become
1.123 + * invalid and must not be used.
1.124 + *
1.125 + * @param aSource the source whose previous buffer requests should be ignored.
1.126 + */
1.127 + virtual void DiscardBuffers(MMMFBufferSource* aSource);
1.128 +
1.129 + // from base class CDevCommonControl
1.130 + void FinishWithError(TInt aError);
1.131 +
1.132 + /**
1.133 + * Called when a ProcessingFinished callback is received
1.134 + *
1.135 + * @since
1.136 + * @param TBool& aAyncCompletion
1.137 + * @return an error code KErrNone if successful
1.138 + */
1.139 + virtual TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
1.140 +
1.141 + /*
1.142 + Used to send a stop call when there is a error in the buffer
1.143 + */
1.144 + void BufferErrorEvent();
1.145 +
1.146 + virtual TInt ProcessingError(TBool& aAyncCompletion);
1.147 +
1.148 +private:
1.149 + CDevPlayControl();
1.150 +
1.151 +private: // data
1.152 +
1.153 + /**
1.154 + * Casted convenience pointer to DevAudio::iAudioSource
1.155 + * Not own.
1.156 + */
1.157 + MMMFBufferSource *iBufferSource;
1.158 +
1.159 + };
1.160 +
1.161 +#endif // CDEVPLAYCONTROL_H