1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/mdf/src/audio/AudioDevice/audiodevice.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,202 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef AUDIODEVICE_H
1.20 +#define AUDIODEVICE_H
1.21 +
1.22 +#include <e32msgqueue.h>
1.23 +#include <mdf/mdfprocessingunit.h>
1.24 +#include <mdf/mdfinputport.h>
1.25 +#include <mdf/mdfoutputport.h>
1.26 +#include <mmf/server/mmfhwdevicesetup.h>
1.27 +#include <mdf/mdfcommon.h>
1.28 +
1.29 +#ifdef SYMBIAN_MDF_SHAREDCHUNK_SOUNDDRIVER
1.30 + #include "mdasoundadapter.h"
1.31 +#else
1.32 + #include <mdasound.h>
1.33 +#endif
1.34 +
1.35 +class CMMFBuffer;
1.36 +
1.37 +/*
1.38 +Audio Sink/Source processing unit
1.39 +*/
1.40 +class CAudioDevice : public CMdfProcessingUnit
1.41 + {
1.42 +public:
1.43 + /*
1.44 + Audio Sink/Source input port
1.45 + */
1.46 + class CInputPort: public CActive,
1.47 + public MMdfInputPort,
1.48 + public MPlayCustomInterface
1.49 + {
1.50 + public:
1.51 + static CInputPort* NewL(CAudioDevice& aParent);
1.52 +
1.53 + // from MMdfInputPort
1.54 + TInt MipConfigure(const TPuConfig& aConfiguration);
1.55 + TInt MipGetConfig(TPuConfig& aConfigurationSetup);
1.56 + void MipInitialize();
1.57 + void MipSetObserver(const MMdfInputPortObserver& aInputPortObserver);
1.58 + CMMFBuffer* MipCreateBuffer(TInt aBufferSize);
1.59 + TInt MipUseBuffer(CMMFBuffer& aBuffer);
1.60 + TInt MipFreeBuffer(CMMFBuffer* aBuffer);
1.61 + TInt MipTunnelRequest(const MMdfOutputPort& aOutputPortToBeConnectedTo,
1.62 + TTunnelFlags& aTunnelFlags, TSupplierType& aSupplierType);
1.63 + void MipWriteData(CMMFBuffer& aBuffer);
1.64 + void MipDisconnectTunnel();
1.65 + void MipRestartTunnel();
1.66 + TBool MipIsTunnelled() const;
1.67 + TInt MipIndex() const;
1.68 + TUint32 MipBufferSize() const;
1.69 + TInt MipCreateCustomInterface(TUid aUid);
1.70 + TAny* MipCustomInterface(TUid aUid);
1.71 +
1.72 + // from MPlayCustomInterface
1.73 + void SetVolume(TUint aVolume);
1.74 + TUint Volume();
1.75 + TUint BytesPlayed();
1.76 + void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
1.77 + TTimeIntervalMicroSeconds& VolumeRamp();
1.78 + TInt SampleRate();
1.79 + TInt Channels();
1.80 +
1.81 + // from CActive
1.82 + void RunL();
1.83 + void DoCancel();
1.84 +
1.85 + // CInputPort
1.86 + void Execute();
1.87 + void Pause();
1.88 + void Stop();
1.89 + ~CInputPort();
1.90 +
1.91 + private:
1.92 + explicit CInputPort(CAudioDevice& aParent);
1.93 + void ConstructL();
1.94 + private:
1.95 + CMMFBuffer* iCurrentBuffer;
1.96 + CAudioDevice& iParent;
1.97 + MMdfOutputPort* iPortConnectedTo;
1.98 + RPointerArray<CMMFBuffer> iBuffers;
1.99 + MMdfInputPortObserver* iObserver;
1.100 + TInt iSampleRate;
1.101 + TInt iChannels;
1.102 + TBool iInterleaved;
1.103 + TUint iVolume;
1.104 + TTimeIntervalMicroSeconds iRampDuration;
1.105 + TUint iBytesPlayed;
1.106 + TBool iPaused;
1.107 + TBool iStopped;
1.108 + TUint iBufferSize;
1.109 + };
1.110 + /*
1.111 + Audio Sink/Source output port
1.112 + */
1.113 + class COutputPort: public CActive,
1.114 + public MMdfOutputPort,
1.115 + public MRecordCustomInterface
1.116 + {
1.117 + public:
1.118 + static COutputPort* NewL(CAudioDevice& aParent);
1.119 +
1.120 + // from MMdfOutputPort
1.121 + TInt MopConfigure(const TPuConfig& aConfiguration);
1.122 + TInt MopGetConfig(TPuConfig& aConfigurationSetup);
1.123 + void MopInitialize();
1.124 + void MopSetObserver(const MMdfOutputPortObserver& aOutputPortObserver);
1.125 + CMMFBuffer* MopCreateBuffer(TInt aBufferSize);
1.126 + TInt MopUseBuffer(CMMFBuffer& aBuffer);
1.127 + TInt MopFreeBuffer(CMMFBuffer* aBuffer);
1.128 + TInt MopTunnelRequest(const MMdfInputPort& aInputPortToBeConnectedTo,
1.129 + TTunnelFlags& aTunnelFlags, TSupplierType& aSupplierType);
1.130 + void MopReadData(CMMFBuffer& aBuffer);
1.131 + void MopDisconnectTunnel();
1.132 + void MopRestartTunnel();
1.133 + TBool MopIsTunnelled() const;
1.134 + TInt MopIndex() const;
1.135 + TUint32 MopBufferSize() const;
1.136 + TInt MopCreateCustomInterface(TUid aUid);
1.137 + TAny* MopCustomInterface(TUid aUid);
1.138 +
1.139 + // from MRecordCustomInterface
1.140 + void SetGain(TUint aGain);
1.141 + TUint Gain();
1.142 + TUint BytesRecorded();
1.143 + TInt SampleRate();
1.144 + TInt Channels();
1.145 +
1.146 + // from CActive
1.147 + void RunL();
1.148 + void DoCancel();
1.149 +
1.150 + // COutputPort
1.151 + ~COutputPort();
1.152 + void Execute();
1.153 + void Pause();
1.154 + void Stop();
1.155 +
1.156 + private:
1.157 + explicit COutputPort(CAudioDevice& aParent);
1.158 + void ConstructL();
1.159 + private:
1.160 + CMMFBuffer* iCurrentBuffer;
1.161 + CAudioDevice& iParent;
1.162 + RPointerArray<CMMFBuffer> iBuffers;
1.163 + MMdfOutputPortObserver* iObserver;
1.164 + MMdfInputPort* iPortConnectedTo;
1.165 + TInt iSampleRate;
1.166 + TInt iChannels;
1.167 + TBool iInterleaved;
1.168 + TUint iGain;
1.169 + TUint iBytesRecorded;
1.170 + TBool iPaused;
1.171 + TUint iBufferSize;
1.172 + };
1.173 +public:
1.174 + static CAudioDevice* NewL();
1.175 + // from CMdfProcessingUnit
1.176 + TInt Create(const MMdfProcessingUnitObserver& aProcessingUnitObserver);
1.177 + TInt GetInputPorts(RPointerArray<MMdfInputPort>& aComponentInputPorts);
1.178 + TInt GetOutputPorts(RPointerArray<MMdfOutputPort>& aComponentOutputPorts);
1.179 + TInt Configure(const TPuConfig& aConfigurationSetup);
1.180 + TInt GetConfig(TPuConfig& aConfigurationSetup);
1.181 + void Initialize();
1.182 + void Execute ();
1.183 + TInt Pause ();
1.184 + void Stop ();
1.185 + TProcessingUnitState State();
1.186 + TInt CreateCustomInterface(TUid aUid);
1.187 + TAny* CustomInterface(TUid aUid);
1.188 +
1.189 + // CAudioDevice
1.190 + RMdaDevSound& SoundDevice();
1.191 + MMdfProcessingUnitObserver* Observer();
1.192 + ~CAudioDevice();
1.193 +
1.194 +private:
1.195 + CAudioDevice();
1.196 + void ConstructL();
1.197 +private:
1.198 + CInputPort* iInputPort;
1.199 + COutputPort* iOutputPort;
1.200 + RMdaDevSound iSoundDevice;
1.201 + MMdfProcessingUnitObserver* iObserver;
1.202 + TProcessingUnitState iState;
1.203 + };
1.204 +
1.205 +#endif // AUDIODEVICE_H