os/mm/devsound/a3fdevsound/src/devsoundadaptor/cdevplaycontrol.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 #ifndef CDEVPLAYCONTROL_H
    22 #define CDEVPLAYCONTROL_H
    23 
    24 #include <e32base.h>
    25 
    26 #include "cdevcommoncontrol.h"
    27 
    28 #include <a3f/maudiodatasupplier.h>
    29 #include <a3f/maudioprocessingunitobserver.h>
    30 #include <a3f/a3f_trace_utils.h>
    31 
    32 
    33 class MMMFBufferSource;
    34 
    35 /**
    36  * CDevPlayControl.
    37  *
    38  * ?description
    39  *
    40  * @lib mmfdevsoundadaptation.lib
    41  * @since
    42  */
    43 
    44 NONSHARABLE_CLASS(CDevPlayControl) :public CDevCommonControl,
    45 									public MMMFAudioDataSupplier
    46     {
    47 public:
    48 
    49 	/**
    50 	* Destructor.
    51 	* Releases all resources and deletes all objects owned by this instance.
    52 	*/
    53 	~CDevPlayControl();
    54 
    55 	static CDevPlayControl* NewL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aDevSoundObserver);
    56 
    57 	void ConstructL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aAdaptationObserver);
    58 
    59 	// from base class CDevAudioControl
    60 
    61 	/**
    62 	* Initialize playing state control components
    63 	* @since
    64 	* @return error code
    65 	*/
    66 	virtual TInt Initialize(TUid aFormat);
    67 
    68 	/**
    69 	* Initializes the audio device and starts the play process. This
    70 	* function queries and acquires the audio policy before initializing
    71 	* audio device. If there was an error during policy initialization,
    72 	* PlayError() function will be called on the observer with error code
    73 	* KErrAccessDenied, otherwise BufferToBeFilled() function will be called
    74 	* with a buffer reference. After reading data into the buffer reference
    75 	* passed, the client should call PlayData() to play data.
    76 	* The amount of data that can be played is specified in
    77 	* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
    78 	* this size will be ignored.
    79 	* Leaves on failure.
    80 	* @since
    81 	* @return void
    82 	*/
    83 	virtual TInt ProcessInit();
    84 
    85 	/**
    86 	* Plays data in the buffer at the current volume.
    87 	* The client should fill the buffer with audio data before calling this
    88 	* function. The observer gets a reference to the buffer along with the
    89 	* callback function BufferToBeFilled(). When playing of the audio sample
    90 	* is complete, successfully or otherwise, the function PlayError() on
    91 	* the observer is called.
    92 	* The last buffer of the audio stream being played should have the last
    93 	* buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
    94 	* subsequent attempt to play the clip is made, this flag will need
    95 	* resetting by the client.
    96 	* @return void
    97 	*/
    98 	virtual void ProcessData();
    99 
   100 	/*
   101 	Call-back indicating that is the last buffer has been processed
   102 	*/
   103 	virtual void ProcessingFinished (MAudioStream& aStream);
   104 
   105 	// from base class MAudioDataSupplier
   106 
   107 	/**
   108 	* Request a buffer to be filled with audio data by the data supplier.
   109 	*
   110 	* The supplier should fill the buffer as quickly as possible and then call
   111 	* MBufferSource::BufferFilled() passing the filled buffer as a parameter.
   112 	*
   113 	* @param aSource a pointer to the source requesting the buffer
   114 	* @param aBuffer a pointer to the buffer to fill
   115 	*/
   116 	virtual void BufferToBeFilled(MMMFBufferSource* aSource, CMMFBuffer* aBuffer);
   117 
   118 	/**
   119 	* Indicates that all buffers previously requested by this source have become
   120 	* invalid and must not be used.
   121 	*
   122 	* @param aSource the source whose previous buffer requests should be ignored.
   123 	*/
   124 	virtual void DiscardBuffers(MMMFBufferSource* aSource);
   125 
   126 	// from base class CDevCommonControl
   127 	void FinishWithError(TInt aError);
   128 
   129 	/**
   130 	* Called when a ProcessingFinished callback is received
   131 	*
   132 	* @since
   133 	* @param TBool& aAyncCompletion
   134 	* @return an error code KErrNone if successful
   135 	*/
   136 	virtual TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
   137 	
   138 	/*
   139 	Used to send a stop call when there is a error in the buffer
   140 	*/
   141 	void BufferErrorEvent();
   142 	
   143 	virtual TInt ProcessingError(TBool& aAyncCompletion);
   144 	
   145 private:
   146 	CDevPlayControl();
   147 
   148 private: // data
   149 
   150 	/**
   151 	* Casted convenience pointer to DevAudio::iAudioSource
   152 	* Not own.
   153 	*/
   154 	MMMFBufferSource *iBufferSource;
   155 
   156 	};
   157 
   158 #endif // CDEVPLAYCONTROL_H