1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmhais/refacladapt/src/audiosource/buffersource.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,232 @@
1.4 +//buffersource.cpp
1.5 +
1.6 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.7 +// All rights reserved.
1.8 +// This component and the accompanying materials are made available
1.9 +// under the terms of "Eclipse Public License v1.0"
1.10 +// which accompanies this distribution, and is available
1.11 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.12 +//
1.13 +// Initial Contributors:
1.14 +// Nokia Corporation - initial contribution.
1.15 +//
1.16 +// Contributors:
1.17 +//
1.18 +// Description:
1.19 +//
1.20 +
1.21 +
1.22 +
1.23 +#include "buffersource.h"
1.24 +#include "minputport.h"
1.25 +
1.26 +// ---------------------------------------------------------------------------
1.27 +// Constructor
1.28 +// ---------------------------------------------------------------------------
1.29 +//
1.30 +CBufferSource::CBufferSource()
1.31 + : CActive(EPriorityStandard)
1.32 + {
1.33 + TRACE_CREATE();
1.34 + DP_CONTEXT(CBufferSource::CBufferSource *CD1*, CtxDevSound, DPLOCAL);
1.35 + DP_IN();
1.36 + DP_OUT();
1.37 + }
1.38 +
1.39 +// ---------------------------------------------------------------------------
1.40 +// Factory method
1.41 +// ---------------------------------------------------------------------------
1.42 +//
1.43 +EXPORT_C CBufferSource* CBufferSource::NewL()
1.44 + {
1.45 + DP_STATIC_CONTEXT(CBufferSource::NewL *CD0*, CtxDevSound, DPLOCAL);
1.46 + DP_IN();
1.47 + CBufferSource* self = new(ELeave)CBufferSource();
1.48 + CleanupStack::PushL(self);
1.49 + self->ConstructL();
1.50 + CleanupStack::Pop(self);
1.51 + DP0_RET(self, "0x%x");
1.52 + }
1.53 +
1.54 +// ---------------------------------------------------------------------------
1.55 +// Second phase constructor
1.56 +// ---------------------------------------------------------------------------
1.57 +//
1.58 +void CBufferSource::ConstructL()
1.59 + {
1.60 + DP_CONTEXT(CBufferSource::ConstructL *CD1*, CtxDevSound, DPLOCAL);
1.61 + DP_IN();
1.62 + CActiveScheduler::Add(this);
1.63 + DP_OUT();
1.64 + }
1.65 +
1.66 +// ---------------------------------------------------------------------------
1.67 +// Destructor
1.68 +// ---------------------------------------------------------------------------
1.69 +//
1.70 +CBufferSource::~CBufferSource()
1.71 + {
1.72 + DP_CONTEXT(CBufferSource::~CBufferSource *CD1*, CtxDevSound, DPLOCAL);
1.73 + DP_IN();
1.74 + DP_OUT();
1.75 + }
1.76 +
1.77 +
1.78 +// from MMMFBufferSource
1.79 +// ---------------------------------------------------------------------------
1.80 +// CBufferSource::SetDataSupplier
1.81 +// ---------------------------------------------------------------------------
1.82 +TInt CBufferSource::SetDataSupplier(MMMFAudioDataSupplier& aSupplier)
1.83 + {
1.84 + DP_CONTEXT(CBufferSource::SetDataSupplier *CD1*, CtxDevSound, DPLOCAL);
1.85 + DP_IN();
1.86 + iSupplier = &aSupplier;
1.87 + DP0_RET(KErrNone, "%d");
1.88 + }
1.89 +
1.90 +// ---------------------------------------------------------------------------
1.91 +// CBufferSource::BufferFilled
1.92 +// ---------------------------------------------------------------------------
1.93 +TInt CBufferSource::BufferFilled(CMMFBuffer* aBuffer)
1.94 + {
1.95 + DP_CONTEXT(CBufferSource::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
1.96 + DP_IN();
1.97 + iBuffer = aBuffer;
1.98 + DP_OUT();
1.99 + return iInput->BufferFilled(aBuffer);
1.100 + }
1.101 +
1.102 +// ---------------------------------------------------------------------------
1.103 +// CBufferSource::BuffersDiscarded
1.104 +// ---------------------------------------------------------------------------
1.105 +TInt CBufferSource::BuffersDiscarded()
1.106 + {
1.107 + DP_CONTEXT(CBufferSource::BuffersDiscarded *CD1*, CtxDevSound, DPLOCAL);
1.108 + // Check what we are suppose to do
1.109 + DP_IN();
1.110 + if(iBuffer)
1.111 + {
1.112 + iBuffer = NULL;
1.113 + }
1.114 + DP0_RET(KErrNone, "%d");
1.115 + }
1.116 +
1.117 +
1.118 +//From MOutputPort
1.119 +// ---------------------------------------------------------------------------
1.120 +// CBufferSource::FillBuffer
1.121 +// ---------------------------------------------------------------------------
1.122 +//
1.123 +TInt CBufferSource::FillBuffer(CMMFBuffer* aBuffer, MInputPort* aConsumer)
1.124 + {
1.125 + DP_CONTEXT(CBufferSource::FillBuffer *CD1*, CtxDevSound, DPLOCAL);
1.126 + DP_IN();
1.127 + TInt err = KErrNone;
1.128 + if (aConsumer == iInput)
1.129 + {
1.130 + iSupplier->BufferToBeFilled(static_cast<MMMFBufferSource*>(this), aBuffer);
1.131 + }
1.132 + else
1.133 + {
1.134 + err = KErrNotSupported;
1.135 + }
1.136 + DP0_RET(err, "%d");
1.137 + }
1.138 +
1.139 +// ---------------------------------------------------------------------------
1.140 +// CBufferSource::BufferEmptied
1.141 +// ---------------------------------------------------------------------------
1.142 +//
1.143 +TInt CBufferSource::BufferEmptied(CMMFBuffer* /*aBuffer*/)
1.144 + {
1.145 + DP_CONTEXT(CBufferSource::BufferEmptied *CD1*, CtxDevSound, DPLOCAL);
1.146 + DP_IN();
1.147 + DP0_RET(KErrNone, "%d");
1.148 + }
1.149 +
1.150 +// ---------------------------------------------------------------------------
1.151 +// CBufferSource::SetInput
1.152 +// ---------------------------------------------------------------------------
1.153 +//
1.154 +TInt CBufferSource::SetInput(MInputPort* aInput)
1.155 + {
1.156 + DP_CONTEXT(CBufferSource::SetInput *CD1*, CtxDevSound, DPLOCAL);
1.157 + DP_IN();
1.158 + iInput = aInput;
1.159 + DP0_RET(KErrNone, "%d");
1.160 + }
1.161 +
1.162 +// ---------------------------------------------------------------------------
1.163 +// CBufferSource::RemoveInput
1.164 +// ---------------------------------------------------------------------------
1.165 +//
1.166 +TInt CBufferSource::RemoveInput(MInputPort* /*aInput*/)
1.167 + {
1.168 + DP_CONTEXT(CBufferSource::RemoveInput *CD1*, CtxDevSound, DPLOCAL);
1.169 + DP_IN();
1.170 + iInput = NULL;
1.171 + DP0_RET(KErrNone, "%d");
1.172 + }
1.173 +
1.174 +// ---------------------------------------------------------------------------
1.175 +// CBufferSource::GetOutputPort
1.176 +// ---------------------------------------------------------------------------
1.177 +//
1.178 +TInt CBufferSource::GetOutputPort(MOutputPort*& aOutputPort)
1.179 + {
1.180 + DP_CONTEXT(CBufferSource::GetOutputPort *CD1*, CtxDevSound, DPLOCAL);
1.181 + DP_IN();
1.182 + aOutputPort = this;
1.183 + DP0_RET(KErrNone, "%d");
1.184 + }
1.185 +
1.186 +// ---------------------------------------------------------------------------
1.187 +// CBufferSource::FlushBuffer
1.188 +// ---------------------------------------------------------------------------
1.189 +//
1.190 +TInt CBufferSource::FlushBuffer(MFlushHandlerObserver* aFlushObserver)
1.191 + {
1.192 + DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
1.193 + DP_IN();
1.194 + iObserver = aFlushObserver;
1.195 + if (!IsActive())
1.196 + {
1.197 + TRequestStatus* status = &iStatus;
1.198 + User::RequestComplete(status, KErrNone);
1.199 + SetActive();
1.200 + }
1.201 + DP0_RET(KErrNone, "%d");
1.202 + }
1.203 +
1.204 +// From CActive
1.205 +// ---------------------------------------------------------------------------
1.206 +// CBufferSource::DoCancel
1.207 +// ---------------------------------------------------------------------------
1.208 +//
1.209 +void CBufferSource::DoCancel()
1.210 + {
1.211 + DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
1.212 + DP_IN();
1.213 +
1.214 + // Nothing to do
1.215 +
1.216 + DP_OUT();
1.217 + }
1.218 +
1.219 +// ---------------------------------------------------------------------------
1.220 +// CBufferSource::RunL
1.221 +// ---------------------------------------------------------------------------
1.222 +//
1.223 +void CBufferSource::RunL()
1.224 + {
1.225 + DP_CONTEXT(CBufferSource::RunL *CD1*, CtxDevSound, DPLOCAL);
1.226 + DP_IN();
1.227 +
1.228 + iSupplier->DiscardBuffers(this);
1.229 + iObserver->FlushComplete(KErrNone);
1.230 +
1.231 + DP_OUT();
1.232 + }
1.233 +
1.234 +
1.235 +// end of file