mmhais/refacladapt/src/audiosink/buffersink.cpp
author hgs
Fri, 08 Oct 2010 19:40:43 +0100
changeset 0 79dd3e2336a0
permissions -rw-r--r--
2010wk36_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     1
//buffersink.cpp
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     2
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     3
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     4
// All rights reserved.
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     5
// This component and the accompanying materials are made available
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     6
// under the terms of "Eclipse Public License v1.0"
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     7
// which accompanies this distribution, and is available
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     8
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
     9
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    10
// Initial Contributors:
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    11
// Nokia Corporation - initial contribution.
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    12
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    13
// Contributors:
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    14
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    15
// Description:
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    16
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    17
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    18
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    19
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    20
#include "buffersink.h"
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    21
#include "moutputport.h"
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    22
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    23
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    24
// Constructor
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    25
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    26
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    27
CBufferSink::CBufferSink()
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    28
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    29
	TRACE_CREATE();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    30
	DP_CONTEXT(CBufferSink::CBufferSink *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    31
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    32
	DP_OUT();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    33
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    34
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    35
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    36
// Factory method
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    37
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    38
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    39
EXPORT_C CBufferSink* CBufferSink::NewL()
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    40
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    41
	DP_STATIC_CONTEXT(CBufferSink::NewL *CD0*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    42
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    43
	CBufferSink* self = new(ELeave)CBufferSink();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    44
	CleanupStack::PushL(self);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    45
	self->ConstructL();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    46
	CleanupStack::Pop(self);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    47
	DP0_RET(self, "0x%x");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    48
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    49
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    50
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    51
// Second phase constructor
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    52
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    53
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    54
void CBufferSink::ConstructL()
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    55
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    56
	DP_CONTEXT(CBufferSink::ConstructL *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    57
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    58
	DP_OUT();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    59
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    60
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    61
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    62
// Destructor
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    63
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    64
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    65
CBufferSink::~CBufferSink()
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    66
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    67
	DP_CONTEXT(CBufferSink::~CBufferSink *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    68
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    69
	DP_OUT();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    70
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    71
	
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    72
// from class MInputPort
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    73
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    74
// CBufferSink::GetInputPort
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    75
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    76
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    77
TInt CBufferSink::GetInputPort(MInputPort*& aInput)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    78
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    79
	DP_CONTEXT(CBufferSource::GetInputPort *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    80
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    81
	aInput = this;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    82
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    83
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    84
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    85
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    86
// CBufferSink::EmptyBuffer
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    87
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    88
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    89
TInt CBufferSink::EmptyBuffer(CMMFBuffer* aBuffer, MOutputPort* aSupplier)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    90
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    91
	DP_CONTEXT(CBufferSink::EmptyBuffer *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    92
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    93
	TInt err = KErrNone;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    94
	if (aSupplier == iOutput)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    95
		{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    96
		iConsumer->BufferToBeEmptied(static_cast<MMMFBufferSink*>(this), aBuffer);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    97
		}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    98
	else
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
    99
		{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   100
		err = KErrNotSupported;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   101
		}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   102
	DP0_RET(err, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   103
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   104
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   105
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   106
// CBufferSink::BufferFilled
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   108
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   109
TInt CBufferSink::BufferFilled(CMMFBuffer* /*aBuffer*/)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   110
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   111
	DP_CONTEXT(CBufferSink::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   112
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   113
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   114
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   115
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   116
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   117
// CBufferSink::SetOutput
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   118
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   119
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   120
TInt CBufferSink::SetOutput(MOutputPort* aOutput)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   121
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   122
	DP_CONTEXT(CBufferSink::SetOutput *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   123
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   124
	iOutput = aOutput;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   125
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   126
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   127
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   128
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   129
// CBufferSink::RemoveOutput
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   130
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   131
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   132
TInt CBufferSink::RemoveOutput(MOutputPort* /*aOutput*/) 
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   133
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   134
	DP_CONTEXT(CBufferSink::RemoveOutput *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   135
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   136
	iOutput=NULL;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   137
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   138
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   139
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   140
// from MMMFBufferSink
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   141
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   142
// CBufferSink::SetDataConsumer
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   143
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   144
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   145
TInt CBufferSink::SetDataConsumer(MMMFAudioDataConsumer& aConsumer)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   146
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   147
	DP_CONTEXT(CBufferSink::SetDataConsumer *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   148
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   149
	iConsumer = &aConsumer;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   150
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   151
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   152
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   153
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   154
// CBufferSink::BufferEmptied
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   155
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   156
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   157
TInt CBufferSink::BufferEmptied(CMMFBuffer* aBuffer)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   158
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   159
	DP_CONTEXT(CBufferSink::BufferFilled *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   160
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   161
	// Check if need a switch 
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   162
	iBuffer = aBuffer;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   163
	DP_OUT();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   164
	return(iOutput->BufferEmptied(aBuffer));
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   165
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   166
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   167
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   168
// CBufferSink::BuffersDiscarded
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   169
// ---------------------------------------------------------------------------
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   170
//
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   171
TInt CBufferSink::BuffersDiscarded()
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   172
	{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   173
	DP_CONTEXT(CBufferSink::BuffersDiscarded *CD1*, CtxDevSound, DPLOCAL);
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   174
	DP_IN();
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   175
	// Check what we are suppose to do
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   176
	if(iBuffer)
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   177
		{
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   178
		iBuffer = NULL;
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   179
		}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   180
	DP0_RET(KErrNone, "%d");
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   181
	}
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   182
79dd3e2336a0 2010wk36_01
hgs
parents:
diff changeset
   183
// end of file