Update contrib.
3 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 // All rights reserved.
5 // This component and the accompanying materials are made available
6 // under the terms of "Eclipse Public License v1.0"
7 // which accompanies this distribution, and is available
8 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
10 // Initial Contributors:
11 // Nokia Corporation - initial contribution.
20 #include "buffersource.h"
21 #include "minputport.h"
23 // ---------------------------------------------------------------------------
25 // ---------------------------------------------------------------------------
27 CBufferSource::CBufferSource()
28 : CActive(EPriorityStandard)
31 DP_CONTEXT(CBufferSource::CBufferSource *CD1*, CtxDevSound, DPLOCAL);
36 // ---------------------------------------------------------------------------
38 // ---------------------------------------------------------------------------
40 EXPORT_C CBufferSource* CBufferSource::NewL()
42 DP_STATIC_CONTEXT(CBufferSource::NewL *CD0*, CtxDevSound, DPLOCAL);
44 CBufferSource* self = new(ELeave)CBufferSource();
45 CleanupStack::PushL(self);
47 CleanupStack::Pop(self);
48 DP0_RET(self, "0x%x");
51 // ---------------------------------------------------------------------------
52 // Second phase constructor
53 // ---------------------------------------------------------------------------
55 void CBufferSource::ConstructL()
57 DP_CONTEXT(CBufferSource::ConstructL *CD1*, CtxDevSound, DPLOCAL);
59 CActiveScheduler::Add(this);
63 // ---------------------------------------------------------------------------
65 // ---------------------------------------------------------------------------
67 CBufferSource::~CBufferSource()
69 DP_CONTEXT(CBufferSource::~CBufferSource *CD1*, CtxDevSound, DPLOCAL);
75 // from MMMFBufferSource
76 // ---------------------------------------------------------------------------
77 // CBufferSource::SetDataSupplier
78 // ---------------------------------------------------------------------------
79 TInt CBufferSource::SetDataSupplier(MMMFAudioDataSupplier& aSupplier)
81 DP_CONTEXT(CBufferSource::SetDataSupplier *CD1*, CtxDevSound, DPLOCAL);
83 iSupplier = &aSupplier;
84 DP0_RET(KErrNone, "%d");
87 // ---------------------------------------------------------------------------
88 // CBufferSource::BufferFilled
89 // ---------------------------------------------------------------------------
90 TInt CBufferSource::BufferFilled(CMMFBuffer* aBuffer)
92 DP_CONTEXT(CBufferSource::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
96 return iInput->BufferFilled(aBuffer);
99 // ---------------------------------------------------------------------------
100 // CBufferSource::BuffersDiscarded
101 // ---------------------------------------------------------------------------
102 TInt CBufferSource::BuffersDiscarded()
104 DP_CONTEXT(CBufferSource::BuffersDiscarded *CD1*, CtxDevSound, DPLOCAL);
105 // Check what we are suppose to do
111 DP0_RET(KErrNone, "%d");
116 // ---------------------------------------------------------------------------
117 // CBufferSource::FillBuffer
118 // ---------------------------------------------------------------------------
120 TInt CBufferSource::FillBuffer(CMMFBuffer* aBuffer, MInputPort* aConsumer)
122 DP_CONTEXT(CBufferSource::FillBuffer *CD1*, CtxDevSound, DPLOCAL);
125 if (aConsumer == iInput)
127 iSupplier->BufferToBeFilled(static_cast<MMMFBufferSource*>(this), aBuffer);
131 err = KErrNotSupported;
136 // ---------------------------------------------------------------------------
137 // CBufferSource::BufferEmptied
138 // ---------------------------------------------------------------------------
140 TInt CBufferSource::BufferEmptied(CMMFBuffer* /*aBuffer*/)
142 DP_CONTEXT(CBufferSource::BufferEmptied *CD1*, CtxDevSound, DPLOCAL);
144 DP0_RET(KErrNone, "%d");
147 // ---------------------------------------------------------------------------
148 // CBufferSource::SetInput
149 // ---------------------------------------------------------------------------
151 TInt CBufferSource::SetInput(MInputPort* aInput)
153 DP_CONTEXT(CBufferSource::SetInput *CD1*, CtxDevSound, DPLOCAL);
156 DP0_RET(KErrNone, "%d");
159 // ---------------------------------------------------------------------------
160 // CBufferSource::RemoveInput
161 // ---------------------------------------------------------------------------
163 TInt CBufferSource::RemoveInput(MInputPort* /*aInput*/)
165 DP_CONTEXT(CBufferSource::RemoveInput *CD1*, CtxDevSound, DPLOCAL);
168 DP0_RET(KErrNone, "%d");
171 // ---------------------------------------------------------------------------
172 // CBufferSource::GetOutputPort
173 // ---------------------------------------------------------------------------
175 TInt CBufferSource::GetOutputPort(MOutputPort*& aOutputPort)
177 DP_CONTEXT(CBufferSource::GetOutputPort *CD1*, CtxDevSound, DPLOCAL);
180 DP0_RET(KErrNone, "%d");
183 // ---------------------------------------------------------------------------
184 // CBufferSource::FlushBuffer
185 // ---------------------------------------------------------------------------
187 TInt CBufferSource::FlushBuffer(MFlushHandlerObserver* aFlushObserver)
189 DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
191 iObserver = aFlushObserver;
194 TRequestStatus* status = &iStatus;
195 User::RequestComplete(status, KErrNone);
198 DP0_RET(KErrNone, "%d");
202 // ---------------------------------------------------------------------------
203 // CBufferSource::DoCancel
204 // ---------------------------------------------------------------------------
206 void CBufferSource::DoCancel()
208 DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
216 // ---------------------------------------------------------------------------
217 // CBufferSource::RunL
218 // ---------------------------------------------------------------------------
220 void CBufferSource::RunL()
222 DP_CONTEXT(CBufferSource::RunL *CD1*, CtxDevSound, DPLOCAL);
225 iSupplier->DiscardBuffers(this);
226 iObserver->FlushComplete(KErrNone);