First public contribution.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "pcmoutputport.h"
17 #include "pcmprocessingunit.h"
18 #include <mdf/mdfpuconfig.h>
20 const TUint KSampleRate = 8000;
21 const TUint KMonoChannel = 1;
22 const TUint KStereoChannel = 2;
25 CPcmOutputPort* CPcmOutputPort::NewL(TInt aIndex, COmxProcessingUnit* aParent, TPcmDataType aDataType)
27 CPcmOutputPort* self = new (ELeave) CPcmOutputPort(aDataType);
28 CleanupStack::PushL (self);
29 self->ConstructL(aIndex, aParent);
34 void CPcmOutputPort::ConstructL(TInt aIndex, COmxProcessingUnit* aParent)
36 COmxOutputPort::ConstructL(aIndex, aParent);
39 CPcmOutputPort::CPcmOutputPort(TPcmDataType aDataType) :
41 iSampleRate(KSampleRate),
42 iChannels(KMonoChannel),
48 TInt CPcmOutputPort::MopConfigure(const TPuConfig& aConfig)
50 if (aConfig.Uid() == TUid::Uid(KUidTTaskConfig))
52 const TTaskConfig* config = TPuTaskConfig::GetStructure(aConfig);
53 iSampleRate = config->iRate;
54 iChannels = (config->iStereoMode & ETaskMono)? KMonoChannel : KStereoChannel;
55 iInterleaved = (config->iStereoMode & ETaskInterleaved)?ETrue : EFalse;
58 return KErrNotSupported;
61 void CPcmOutputPort::MopInitialize()
63 COmxOutputPort::MopInitialize();
64 OMX_AUDIO_PARAM_PCMMODETYPE pcm;
70 pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
71 pcm.nPortIndex = MopIndex();
72 pcm.nSamplingRate = iSampleRate;
73 pcm.ePCMMode = OMX_AUDIO_PCMModeLinear;
74 pcm.nChannels = iChannels;
75 pcm.bInterleaved = (OMX_BOOL)iInterleaved;
80 pcm.nBitPerSample = 8;
81 pcm.eNumData = OMX_NumericalDataSigned;
84 pcm.nBitPerSample = 8;
85 pcm.eNumData = OMX_NumericalDataUnsigned;
88 pcm.nBitPerSample = 16;
89 pcm.eNumData = OMX_NumericalDataSigned;
94 Component()->OmxSetParameter(OMX_IndexParamAudioPcm, &pcm);