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