os/mm/mmhais/refacladapt/src/audiosink/buffersink.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmhais/refacladapt/src/audiosink/buffersink.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,183 @@
     1.4 +//buffersink.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 "buffersink.h"
    1.24 +#include "moutputport.h"
    1.25 +
    1.26 +// ---------------------------------------------------------------------------
    1.27 +// Constructor
    1.28 +// ---------------------------------------------------------------------------
    1.29 +//
    1.30 +CBufferSink::CBufferSink()
    1.31 +	{
    1.32 +	TRACE_CREATE();
    1.33 +	DP_CONTEXT(CBufferSink::CBufferSink *CD1*, CtxDevSound, DPLOCAL);
    1.34 +	DP_IN();
    1.35 +	DP_OUT();
    1.36 +	}
    1.37 +
    1.38 +// ---------------------------------------------------------------------------
    1.39 +// Factory method
    1.40 +// ---------------------------------------------------------------------------
    1.41 +//
    1.42 +EXPORT_C CBufferSink* CBufferSink::NewL()
    1.43 +	{
    1.44 +	DP_STATIC_CONTEXT(CBufferSink::NewL *CD0*, CtxDevSound, DPLOCAL);
    1.45 +	DP_IN();
    1.46 +	CBufferSink* self = new(ELeave)CBufferSink();
    1.47 +	CleanupStack::PushL(self);
    1.48 +	self->ConstructL();
    1.49 +	CleanupStack::Pop(self);
    1.50 +	DP0_RET(self, "0x%x");
    1.51 +	}
    1.52 +
    1.53 +// ---------------------------------------------------------------------------
    1.54 +// Second phase constructor
    1.55 +// ---------------------------------------------------------------------------
    1.56 +//
    1.57 +void CBufferSink::ConstructL()
    1.58 +	{
    1.59 +	DP_CONTEXT(CBufferSink::ConstructL *CD1*, CtxDevSound, DPLOCAL);
    1.60 +	DP_IN();
    1.61 +	DP_OUT();
    1.62 +	}
    1.63 +
    1.64 +// ---------------------------------------------------------------------------
    1.65 +// Destructor
    1.66 +// ---------------------------------------------------------------------------
    1.67 +//
    1.68 +CBufferSink::~CBufferSink()
    1.69 +	{
    1.70 +	DP_CONTEXT(CBufferSink::~CBufferSink *CD1*, CtxDevSound, DPLOCAL);
    1.71 +	DP_IN();
    1.72 +	DP_OUT();
    1.73 +	}
    1.74 +	
    1.75 +// from class MInputPort
    1.76 +// ---------------------------------------------------------------------------
    1.77 +// CBufferSink::GetInputPort
    1.78 +// ---------------------------------------------------------------------------
    1.79 +//
    1.80 +TInt CBufferSink::GetInputPort(MInputPort*& aInput)
    1.81 +	{
    1.82 +	DP_CONTEXT(CBufferSource::GetInputPort *CD1*, CtxDevSound, DPLOCAL);
    1.83 +	DP_IN();
    1.84 +	aInput = this;
    1.85 +	DP0_RET(KErrNone, "%d");
    1.86 +	}
    1.87 +
    1.88 +// ---------------------------------------------------------------------------
    1.89 +// CBufferSink::EmptyBuffer
    1.90 +// ---------------------------------------------------------------------------
    1.91 +//
    1.92 +TInt CBufferSink::EmptyBuffer(CMMFBuffer* aBuffer, MOutputPort* aSupplier)
    1.93 +	{
    1.94 +	DP_CONTEXT(CBufferSink::EmptyBuffer *CD1*, CtxDevSound, DPLOCAL);
    1.95 +	DP_IN();
    1.96 +	TInt err = KErrNone;
    1.97 +	if (aSupplier == iOutput)
    1.98 +		{
    1.99 +		iConsumer->BufferToBeEmptied(static_cast<MMMFBufferSink*>(this), aBuffer);
   1.100 +		}
   1.101 +	else
   1.102 +		{
   1.103 +		err = KErrNotSupported;
   1.104 +		}
   1.105 +	DP0_RET(err, "%d");
   1.106 +	}
   1.107 +
   1.108 +// ---------------------------------------------------------------------------
   1.109 +// CBufferSink::BufferFilled
   1.110 +// ---------------------------------------------------------------------------
   1.111 +//
   1.112 +TInt CBufferSink::BufferFilled(CMMFBuffer* /*aBuffer*/)
   1.113 +	{
   1.114 +	DP_CONTEXT(CBufferSink::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
   1.115 +	DP_IN();
   1.116 +	DP0_RET(KErrNone, "%d");
   1.117 +	}
   1.118 +
   1.119 +// ---------------------------------------------------------------------------
   1.120 +// CBufferSink::SetOutput
   1.121 +// ---------------------------------------------------------------------------
   1.122 +//
   1.123 +TInt CBufferSink::SetOutput(MOutputPort* aOutput)
   1.124 +	{
   1.125 +	DP_CONTEXT(CBufferSink::SetOutput *CD1*, CtxDevSound, DPLOCAL);
   1.126 +	DP_IN();
   1.127 +	iOutput = aOutput;
   1.128 +	DP0_RET(KErrNone, "%d");
   1.129 +	}
   1.130 +
   1.131 +// ---------------------------------------------------------------------------
   1.132 +// CBufferSink::RemoveOutput
   1.133 +// ---------------------------------------------------------------------------
   1.134 +//
   1.135 +TInt CBufferSink::RemoveOutput(MOutputPort* /*aOutput*/) 
   1.136 +	{
   1.137 +	DP_CONTEXT(CBufferSink::RemoveOutput *CD1*, CtxDevSound, DPLOCAL);
   1.138 +	DP_IN();
   1.139 +	iOutput=NULL;
   1.140 +	DP0_RET(KErrNone, "%d");
   1.141 +	}
   1.142 +
   1.143 +// from MMMFBufferSink
   1.144 +// ---------------------------------------------------------------------------
   1.145 +// CBufferSink::SetDataConsumer
   1.146 +// ---------------------------------------------------------------------------
   1.147 +//
   1.148 +TInt CBufferSink::SetDataConsumer(MMMFAudioDataConsumer& aConsumer)
   1.149 +	{
   1.150 +	DP_CONTEXT(CBufferSink::SetDataConsumer *CD1*, CtxDevSound, DPLOCAL);
   1.151 +	DP_IN();
   1.152 +	iConsumer = &aConsumer;
   1.153 +	DP0_RET(KErrNone, "%d");
   1.154 +	}
   1.155 +
   1.156 +// ---------------------------------------------------------------------------
   1.157 +// CBufferSink::BufferEmptied
   1.158 +// ---------------------------------------------------------------------------
   1.159 +//
   1.160 +TInt CBufferSink::BufferEmptied(CMMFBuffer* aBuffer)
   1.161 +	{
   1.162 +	DP_CONTEXT(CBufferSink::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
   1.163 +	DP_IN();
   1.164 +	// Check if need a switch 
   1.165 +	iBuffer = aBuffer;
   1.166 +	DP_OUT();
   1.167 +	return(iOutput->BufferEmptied(aBuffer));
   1.168 +	}
   1.169 +
   1.170 +// ---------------------------------------------------------------------------
   1.171 +// CBufferSink::BuffersDiscarded
   1.172 +// ---------------------------------------------------------------------------
   1.173 +//
   1.174 +TInt CBufferSink::BuffersDiscarded()
   1.175 +	{
   1.176 +	DP_CONTEXT(CBufferSink::BuffersDiscarded *CD1*, CtxDevSound, DPLOCAL);
   1.177 +	DP_IN();
   1.178 +	// Check what we are suppose to do
   1.179 +	if(iBuffer)
   1.180 +		{
   1.181 +		iBuffer = NULL;
   1.182 +		}
   1.183 +	DP0_RET(KErrNone, "%d");
   1.184 +	}
   1.185 +
   1.186 +// end of file