mmhais/refacladapt/src/audiosource/buffersource.cpp
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     1 //buffersource.cpp
       
     2 
       
     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".
       
     9 //
       
    10 // Initial Contributors:
       
    11 // Nokia Corporation - initial contribution.
       
    12 //
       
    13 // Contributors:
       
    14 //
       
    15 // Description:
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 #include "buffersource.h"
       
    21 #include "minputport.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Constructor
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CBufferSource::CBufferSource()
       
    28 	: CActive(EPriorityStandard)
       
    29 	{
       
    30 	TRACE_CREATE();
       
    31 	DP_CONTEXT(CBufferSource::CBufferSource *CD1*, CtxDevSound, DPLOCAL);
       
    32 	DP_IN();
       
    33 	DP_OUT();
       
    34 	}
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Factory method
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CBufferSource* CBufferSource::NewL()
       
    41 	{
       
    42 	DP_STATIC_CONTEXT(CBufferSource::NewL *CD0*, CtxDevSound, DPLOCAL);
       
    43 	DP_IN();
       
    44 	CBufferSource* self = new(ELeave)CBufferSource();
       
    45 	CleanupStack::PushL(self);
       
    46 	self->ConstructL();
       
    47 	CleanupStack::Pop(self);
       
    48 	DP0_RET(self, "0x%x");
       
    49 	}
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Second phase constructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CBufferSource::ConstructL()
       
    56 	{
       
    57 	DP_CONTEXT(CBufferSource::ConstructL *CD1*, CtxDevSound, DPLOCAL);
       
    58 	DP_IN();
       
    59 	CActiveScheduler::Add(this);
       
    60 	DP_OUT();
       
    61 	}
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Destructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CBufferSource::~CBufferSource()
       
    68 	{
       
    69 	DP_CONTEXT(CBufferSource::~CBufferSource *CD1*, CtxDevSound, DPLOCAL);
       
    70 	DP_IN();
       
    71 	DP_OUT();
       
    72 	}
       
    73 
       
    74 
       
    75 // from MMMFBufferSource
       
    76 // ---------------------------------------------------------------------------
       
    77 // CBufferSource::SetDataSupplier
       
    78 // ---------------------------------------------------------------------------
       
    79 TInt CBufferSource::SetDataSupplier(MMMFAudioDataSupplier& aSupplier)
       
    80 	{
       
    81 	DP_CONTEXT(CBufferSource::SetDataSupplier *CD1*, CtxDevSound, DPLOCAL);
       
    82 	DP_IN();
       
    83 	iSupplier = &aSupplier;
       
    84 	DP0_RET(KErrNone, "%d");
       
    85 	}
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CBufferSource::BufferFilled
       
    89 // ---------------------------------------------------------------------------
       
    90 TInt CBufferSource::BufferFilled(CMMFBuffer* aBuffer)
       
    91 	{
       
    92 	DP_CONTEXT(CBufferSource::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
       
    93 	DP_IN();
       
    94 	iBuffer = aBuffer;
       
    95 	DP_OUT();
       
    96 	return iInput->BufferFilled(aBuffer);
       
    97 	}
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CBufferSource::BuffersDiscarded
       
   101 // ---------------------------------------------------------------------------
       
   102 TInt CBufferSource::BuffersDiscarded()
       
   103 	{
       
   104 	DP_CONTEXT(CBufferSource::BuffersDiscarded *CD1*, CtxDevSound, DPLOCAL);
       
   105 	// Check what we are suppose to do
       
   106 	DP_IN();
       
   107 	if(iBuffer)
       
   108 		{
       
   109 		iBuffer = NULL;
       
   110 		}
       
   111 	DP0_RET(KErrNone, "%d");
       
   112 	}
       
   113 
       
   114 
       
   115 //From MOutputPort	
       
   116 // ---------------------------------------------------------------------------
       
   117 // CBufferSource::FillBuffer
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 TInt CBufferSource::FillBuffer(CMMFBuffer* aBuffer, MInputPort* aConsumer)
       
   121 	{
       
   122 	DP_CONTEXT(CBufferSource::FillBuffer *CD1*, CtxDevSound, DPLOCAL);
       
   123 	DP_IN();
       
   124 	TInt err = KErrNone;
       
   125 	if (aConsumer == iInput)
       
   126 		{
       
   127 		iSupplier->BufferToBeFilled(static_cast<MMMFBufferSource*>(this), aBuffer);
       
   128 		}
       
   129 	else
       
   130 		{
       
   131 		err = KErrNotSupported;
       
   132 		}
       
   133 	DP0_RET(err, "%d");
       
   134 	}
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // CBufferSource::BufferEmptied
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 TInt CBufferSource::BufferEmptied(CMMFBuffer* /*aBuffer*/)
       
   141 	{
       
   142 	DP_CONTEXT(CBufferSource::BufferEmptied *CD1*, CtxDevSound, DPLOCAL);
       
   143 	DP_IN();
       
   144 	DP0_RET(KErrNone, "%d");
       
   145 	}
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CBufferSource::SetInput
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 TInt CBufferSource::SetInput(MInputPort* aInput)
       
   152 	{
       
   153 	DP_CONTEXT(CBufferSource::SetInput *CD1*, CtxDevSound, DPLOCAL);
       
   154 	DP_IN();
       
   155 	iInput = aInput;
       
   156 	DP0_RET(KErrNone, "%d");
       
   157 	}
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CBufferSource::RemoveInput
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 TInt CBufferSource::RemoveInput(MInputPort* /*aInput*/)
       
   164 	{
       
   165 	DP_CONTEXT(CBufferSource::RemoveInput *CD1*, CtxDevSound, DPLOCAL);
       
   166 	DP_IN();
       
   167 	iInput = NULL;
       
   168 	DP0_RET(KErrNone, "%d");
       
   169 	}
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CBufferSource::GetOutputPort
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 TInt CBufferSource::GetOutputPort(MOutputPort*& aOutputPort)
       
   176 	{
       
   177 	DP_CONTEXT(CBufferSource::GetOutputPort *CD1*, CtxDevSound, DPLOCAL);
       
   178 	DP_IN();
       
   179 	aOutputPort = this;
       
   180 	DP0_RET(KErrNone, "%d");
       
   181 	}
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CBufferSource::FlushBuffer
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 TInt CBufferSource::FlushBuffer(MFlushHandlerObserver* aFlushObserver)
       
   188 	{
       
   189 	DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
       
   190 	DP_IN();
       
   191 	iObserver = aFlushObserver;
       
   192 	if (!IsActive())
       
   193 		{
       
   194 		TRequestStatus* status = &iStatus;
       
   195 		User::RequestComplete(status, KErrNone);
       
   196 		SetActive();
       
   197 		}
       
   198 	DP0_RET(KErrNone, "%d");
       
   199 	}
       
   200 
       
   201 // From CActive
       
   202 // ---------------------------------------------------------------------------
       
   203 // CBufferSource::DoCancel
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 void CBufferSource::DoCancel()
       
   207 	{
       
   208 	DP_CONTEXT(CBufferSource::FlushBuffer *CD1*, CtxDevSound, DPLOCAL);
       
   209 	DP_IN();
       
   210 
       
   211 	// Nothing to do
       
   212 
       
   213 	DP_OUT();
       
   214 	}
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // CBufferSource::RunL
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 void CBufferSource::RunL()
       
   221 	{
       
   222 	DP_CONTEXT(CBufferSource::RunL *CD1*, CtxDevSound, DPLOCAL);
       
   223 	DP_IN();
       
   224 
       
   225 	iSupplier->DiscardBuffers(this);
       
   226 	iObserver->FlushComplete(KErrNone);
       
   227 
       
   228 	DP_OUT();
       
   229 	}
       
   230 
       
   231 
       
   232 // end of file