sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "tonedatapath.h" sl@0: sl@0: sl@0: CToneDataPath* CToneDataPath::NewL() sl@0: { sl@0: CToneDataPath* self = new(ELeave) CToneDataPath; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::ConstructL() sl@0: { sl@0: iAudioPlayer = new (ELeave) CToneDataPathPlayer(*this,CActive::EPriorityUserInput); sl@0: iSoundDeviceErrorReceiver = new (ELeave) CToneSoundDevPlayErrorReceiver(*this, CActive::EPriorityUserInput); sl@0: } sl@0: sl@0: sl@0: CToneDataPath::~CToneDataPath() sl@0: { sl@0: delete iAudioPlayer; sl@0: delete iSoundDeviceErrorReceiver; sl@0: sl@0: iSoundDevice.Close(); sl@0: sl@0: if (iCodec) sl@0: { sl@0: delete iSourceBuffer; sl@0: if (!iCodec->IsNullCodec()) sl@0: { sl@0: delete iSoundDeviceBuffer; sl@0: } sl@0: } sl@0: sl@0: #ifdef __USE_MMF_TRANSFERBUFFERS__ sl@0: delete iTransferWindow; sl@0: sl@0: if(iTransferBuffer) sl@0: { sl@0: iTransferBuffer->Close(); sl@0: delete iTransferBuffer; sl@0: } sl@0: #endif sl@0: sl@0: #ifdef __USE_MMF_PTRBUFFERS__ sl@0: delete iPtrBufferMemoryBlock; sl@0: #endif sl@0: } sl@0: sl@0: sl@0: TInt CToneDataPath::SetObserver(MMMFHwDeviceObserver& aObserver) sl@0: { sl@0: TInt error; sl@0: if (iHwDeviceObserver) sl@0: { sl@0: error = KErrAlreadyExists; sl@0: } sl@0: else sl@0: { sl@0: iHwDeviceObserver = &aObserver; sl@0: error = KErrNone; sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: sl@0: TInt CToneDataPath::AddCodec(CToneCodec& aCodec) sl@0: { sl@0: if (iCodec) sl@0: { sl@0: return KErrNotSupported; //doesn't support multiple codecs sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: iCodec = &aCodec; sl@0: sl@0: // Allocate data buffer sl@0: iSourceBufferSize = iCodec->SourceBufferSize(); sl@0: iSoundDevBufferSize = iCodec->SinkBufferSize(); sl@0: sl@0: if ((!iSourceBufferSize)||(!iSoundDevBufferSize)) sl@0: { sl@0: err = KErrArgument; //codec plugin has not specified buffer size sl@0: } sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: #ifdef __USE_MMF_TRANSFERBUFFERS__ sl@0: TRAP(err,iSourceBuffer = CreateTransferBufferL(iSourceBufferSize, static_cast(iSourceBuffer))); sl@0: #endif sl@0: #ifdef __USE_MMF_PTRBUFFERS__ sl@0: TRAP(err,iSourceBuffer = CreatePtrBufferL(iSourceBufferSize)); sl@0: #else sl@0: TRAP(err,iSourceBuffer = CMMFDataBuffer::NewL(iSourceBufferSize)); sl@0: #endif sl@0: } sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: if (iCodec->IsNullCodec()) sl@0: {//use source buffer for sound device buffer sl@0: iSoundDeviceBuffer = NULL; sl@0: } sl@0: else sl@0: {//codec needs separate source and sound device buffers sl@0: TRAP(err,iSoundDeviceBuffer = CMMFDataBuffer::NewL(iSoundDevBufferSize)); sl@0: } sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: TInt CToneDataPath::Start() sl@0: { sl@0: TInt startError = KErrNone; sl@0: sl@0: if (!iCodec) sl@0: {//check that a codec has been added sl@0: startError = KErrNotReady; sl@0: } sl@0: if ((!iSoundDevice.Handle())&&(!startError)) sl@0: {//check that the sound drivers can be opened sl@0: startError = iSoundDevice.Open(); sl@0: } sl@0: sl@0: if (iState == EPaused) sl@0: {//we are paused so need to resume play sl@0: if (!startError) sl@0: { sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPath::Start-Resume")); sl@0: #endif sl@0: iAudioPlayer->ResumePlaying(); sl@0: iState = EPlaying; sl@0: } sl@0: } sl@0: else if (!startError) sl@0: { sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPath::Start-Normal")); sl@0: #endif sl@0: // get sample rate and channels from RMdaDevSound sl@0: RMdaDevSound::TCurrentSoundFormatBuf format; sl@0: iSoundDevice.GetPlayFormat(format); sl@0: iSampleRate = format().iRate; sl@0: iChannels = format().iChannels; sl@0: sl@0: iNoMoreSourceData = EFalse; sl@0: iSourceBuffer->SetLastBuffer(EFalse); sl@0: iState = EPlaying; sl@0: iSoundDeviceErrorReceiver->Start(); sl@0: TRAP(startError,FillSourceBufferL()); //get initial buffer of audio data sl@0: if (startError == KErrNone) sl@0: { sl@0: // Start the player objects sl@0: iAudioPlayer->Start(); sl@0: } sl@0: else sl@0: {//failed to start up correctly go back to stopped state sl@0: iState = EStopped; sl@0: iSoundDeviceErrorReceiver->Stop(); sl@0: } sl@0: } sl@0: return startError; sl@0: } sl@0: sl@0: sl@0: // *** Main Play Loop *** sl@0: sl@0: void CToneDataPath::FillSourceBufferL() sl@0: {//asks observer to fill the source buffer sl@0: // Ask immediately for data from the observer sl@0: #ifdef __CYCLE_MMF_DATABUFFERS__ sl@0: // Create a new buffer to replicate INC021405 Play-EOF-Play on HwAccelerated solution Panics sl@0: // If the creation fails, we carry on regardless as the original buffer will not have been sl@0: // destroyed. Must do this as alloc fail tests will not run. sl@0: if(iSourceBuffer) sl@0: { sl@0: iSourceBuffer = CycleAudioBuffer(iSourceBuffer); sl@0: } sl@0: #endif // __CYCLE_MMF_DATABUFFERS__ sl@0: User::LeaveIfError(iHwDeviceObserver->FillThisHwBuffer(*iSourceBuffer)); sl@0: sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::BufferFilledL(CMMFDataBuffer& aBuffer) sl@0: {//call back from observer to indicate buffer has been filled sl@0: sl@0: if (iState == EStopped) sl@0: { sl@0: User::Leave(KErrNotReady);//ok if paused? sl@0: } sl@0: sl@0: iSourceBuffer = &aBuffer; sl@0: iSourceBuffer->SetStatus(EFull); sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPath::BufferFilledL")); sl@0: #endif sl@0: sl@0: //need to check that the buffer size is not 0 - if so assume we've reached the end of the data sl@0: iBuffSize = iSourceBuffer->BufferSize(); sl@0: if (!iBuffSize) sl@0: {//no buffer - could be end of source or could be that the source has no data?? sl@0: iNoMoreSourceData = ETrue; sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPath::BufferFilledL-NoMoreSourceData")); sl@0: #endif sl@0: } sl@0: //even if the buffer size is 0 we still sl@0: //need to perform the following to get the sound device callback sl@0: FillSoundDeviceBufferL(); //get buffer in pcm16 format for sound device sl@0: sl@0: iAudioPlayer->PlayData(*iSoundDeviceBuffer); //play data to sound drivers sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::FillSoundDeviceBufferL() sl@0: {//use CToneCodec to fill the sound device buffer sl@0: sl@0: CToneCodec::TCodecProcessResult codecProcessResult; sl@0: sl@0: if (iCodec->IsNullCodec()) sl@0: {//no codec so data can be sent direct to sink sl@0: iSoundDeviceBuffer = iSourceBuffer; sl@0: iSoundDeviceBuffer->SetStatus(EFull); //sink buffer is full sl@0: } sl@0: else sl@0: { sl@0: //pass buffer to codec for processing sl@0: codecProcessResult = iCodec->ProcessL(*iSourceBuffer, *iSoundDeviceBuffer); sl@0: sl@0: if (iSourceBuffer->LastBuffer()) //if source is last buffer so is sound dev sl@0: { sl@0: iSoundDeviceBuffer->SetLastBuffer(ETrue); sl@0: } sl@0: if ((!iSoundDeviceBuffer->BufferSize())&&(codecProcessResult.iDstBytesAdded)) sl@0: {//the codec has added data but not set the buffer length sl@0: iSoundDeviceBuffer->Data().SetLength(codecProcessResult.iDstBytesAdded); sl@0: } sl@0: //only supports EProcessComplete sl@0: switch (codecProcessResult.iCodecProcessStatus) sl@0: { sl@0: case CToneCodec::TCodecProcessResult::EProcessComplete: sl@0: //finished procesing source data - all data in sink buffer sl@0: { sl@0: iSoundDeviceBuffer->SetStatus(EFull); //sink buffer is full sl@0: } sl@0: break; sl@0: #ifdef SYMBIAN_VARIABLE_BITRATE_CODEC sl@0: case CToneCodec::TCodecProcessResult::EProcessIncomplete: sl@0: //finished procesing source data - all data in sink buffer sl@0: { sl@0: iSoundDeviceBuffer->SetStatus(EFull); //sink buffer is full sl@0: } sl@0: break; sl@0: #endif sl@0: case CToneCodec::TCodecProcessResult::EDstNotFilled: sl@0: //could be the last buffer in which case dst might not get filled sl@0: { sl@0: iSoundDeviceBuffer->SetStatus(EFull); //sink buffer is full sl@0: } sl@0: break; sl@0: case CToneCodec::TCodecProcessResult::EEndOfData: sl@0: //no more data - send what we've got to the sink sl@0: //note we can't always rely on this - in many cases the codec will not know when sl@0: //it has reached the end of data. sl@0: { sl@0: iSoundDeviceBuffer->SetStatus(EFull);//sink buffer may not really be 'full' but its as full as it going to get sl@0: iNoMoreSourceData = ETrue; sl@0: //doesn't matter if sink buffer is not full sl@0: } sl@0: break; sl@0: default: sl@0: //Panic(EMMFSwCodecWrapperBadCodec); //should never get here - bad codec sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::BufferEmptiedL(const CMMFDataBuffer& aBuffer) sl@0: {//call back from CToneDataPathPlayer when the sound device buffer has been emptied sl@0: if (&aBuffer != iSoundDeviceBuffer) sl@0: { sl@0: Panic(EToneBadBuffer); sl@0: } sl@0: sl@0: if (!iNoMoreSourceData) sl@0: { sl@0: FillSourceBufferL(); sl@0: } sl@0: } sl@0: sl@0: //*** End of Main Play Loop *** sl@0: sl@0: sl@0: void CToneDataPath::Stop() sl@0: { sl@0: iAudioPlayer->Cancel(); sl@0: iSoundDeviceErrorReceiver->Cancel(); sl@0: iSoundDevice.Close(); sl@0: sl@0: #ifdef __CYCLE_MMF_DATABUFFERS__ sl@0: // Create a new buffer to replicate INC021405 Play-EOF-Play on HwAccelerated solution Panics sl@0: // If the creation fails, we carry on regardless as the original buffer will not have been sl@0: // destroyed. Must do this as alloc fail tests will not run. sl@0: if(iSourceBuffer) sl@0: { sl@0: iSourceBuffer = CycleAudioBuffer(iSourceBuffer); sl@0: } sl@0: #endif // __CYCLE_MMF_DATABUFFERS__ sl@0: sl@0: iState = EStopped; sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::Pause() sl@0: { sl@0: //since a pause can happen anyway in the datatransfer -need to set to a known sl@0: //state so that when play is resumed the behaviour is predictable sl@0: if (iSoundDevice.Handle()) sl@0: { sl@0: iSoundDevice.PausePlayBuffer(); //needs new LDD sl@0: iState = EPaused; sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("Pause")); sl@0: #endif sl@0: } sl@0: else sl@0: {//an error must have occured sl@0: iState = EStopped; sl@0: } sl@0: } sl@0: sl@0: sl@0: TInt CToneDataPath::EmptyBuffers() sl@0: { sl@0: TInt error = KErrNone; sl@0: if (iSoundDevice.Handle() == 0) sl@0: { sl@0: error = KErrNotReady; sl@0: } sl@0: else sl@0: { sl@0: iSoundDevice.FlushPlayBuffer(); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: sl@0: RMdaDevSound& CToneDataPath::Device() sl@0: { sl@0: return iSoundDevice; sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::SoundDeviceException(TInt aError) sl@0: { sl@0: if(iIgnoreUnderflow) sl@0: { sl@0: if((aError == KErrUnderflow) && (!iNoMoreSourceData)) sl@0: { sl@0: //ignore underflow sl@0: return; sl@0: } sl@0: } sl@0: sl@0: //this sends a request to the hw device observer sl@0: //to update the bytes played sl@0: //it is done here so that the sound driver can be closed prior to sl@0: //updating the policy and sending the error back sl@0: TUid uidUpdateBytesPlayed; sl@0: uidUpdateBytesPlayed.iUid = KToneHwDeviceObserverUpdateBytesPlayed; sl@0: TPtrC8 dummy(0,0); sl@0: sl@0: ASSERT(iHwDeviceObserver); sl@0: iHwDeviceObserver->MsgFromHwDevice(uidUpdateBytesPlayed,dummy); sl@0: sl@0: //this closes RMdaDevSound. sl@0: Stop(); sl@0: sl@0: //inform devsound so it can update policy sl@0: iHwDeviceObserver->Stopped(); sl@0: sl@0: // Inform the observer of the exception condition sl@0: // We inform the hw device observer after the policy has been sl@0: // updated incase the observer relied on the error to assume sl@0: // the policy has been updated sl@0: iHwDeviceObserver->Error(aError); sl@0: sl@0: RDebug::Print(_L("CToneDataPath::iHwDeviceObserver->Error(%d)"),aError); sl@0: } sl@0: sl@0: /** sl@0: Retrieves a custom interface to the device. sl@0: The reference CToneDataPath supports three custom interfaces, sl@0: MEmptyBuffersCustomInterface, MSetVbrFlagCustomInterface and MIgnoreUnderflowEventsCustomInterface sl@0: sl@0: @param aInterface sl@0: Interface UID, defined with the custom interface. sl@0: aInterface = KMmfUidEmptyBuffersCustomInterface for MEmptyBuffersCustomInterface, sl@0: KSetVbrFlagCustomInterfaceTypeUid for MSetVbrFlagCustomInterface sl@0: sl@0: @return A pointer to the interface implementation, or NULL if the device can not sl@0: implement the interface requested. The return value must be cast to the sl@0: correct type by the user. sl@0: */ sl@0: TAny* CToneDataPath::CustomInterface(TUid aInterface) sl@0: { sl@0: TAny* ret = NULL; sl@0: sl@0: if (aInterface == KIgnoreUnderflowCustomInterfaceTypeUid) sl@0: { sl@0: MIgnoreUnderflowEventsCustomInterface* result = static_cast (this); sl@0: ret = static_cast(result); sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: void CToneDataPath::IgnoreUnderflowEvents() sl@0: { sl@0: iIgnoreUnderflow = ETrue; sl@0: } sl@0: sl@0: sl@0: sl@0: /************************************************************************ sl@0: * CDataPathPlayer * sl@0: ************************************************************************/ sl@0: sl@0: CToneDataPathPlayer::CToneDataPathPlayer(CToneDataPath& aParent, TInt aPriority) sl@0: : CActive(aPriority), iParent(aParent) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: sl@0: CToneDataPathPlayer::~CToneDataPathPlayer() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::Start() sl@0: { sl@0: // No implementation sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::ResumePlaying() sl@0: { sl@0: if (iParent.Device().Handle()) sl@0: { sl@0: //should be ok to call this even if we are active sl@0: iParent.Device().ResumePlaying(); sl@0: iResumePlaying = ETrue; sl@0: } sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("Playing Resumed")); sl@0: #endif sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::PlayData(const CMMFDataBuffer& aData) sl@0: { sl@0: iDataFromSource = &aData; sl@0: if (!IsActive()) sl@0: { sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPathPlayer::PlayData")); sl@0: #endif sl@0: iParent.Device().PlayData(iStatus,(static_cast (iDataFromSource))->Data()); sl@0: SetActive(); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::Stop() sl@0: { sl@0: if (!IsActive()) sl@0: { sl@0: iParent.Device().FlushPlayBuffer(); // Otherwise won't be flushed sl@0: } sl@0: Cancel(); sl@0: iParent.SoundDeviceException(KErrCancel); sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::RunL() sl@0: { sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneDataPathPlayer::RunL error[%d]"), iStatus.Int()); sl@0: #endif sl@0: if (iStatus.Int()!=KErrNone) sl@0: { sl@0: iParent.SoundDeviceException(iStatus.Int()); sl@0: } sl@0: else sl@0: { sl@0: iParent.BufferEmptiedL(static_cast(*iDataFromSource)); sl@0: iResumePlaying = EFalse; sl@0: } sl@0: } sl@0: sl@0: sl@0: TInt CToneDataPathPlayer::RunError(TInt aError) sl@0: { sl@0: Error(aError); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::DoCancel() sl@0: { sl@0: if (iParent.Device().Handle()) sl@0: { sl@0: iParent.Device().CancelPlayData(); sl@0: iParent.Device().FlushPlayBuffer(); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CToneDataPathPlayer::Error(TInt aError) sl@0: { sl@0: iParent.SoundDeviceException(aError); sl@0: } sl@0: sl@0: sl@0: sl@0: /************************************************************************ sl@0: * CToneSoundDevPlayErrorReceiver * sl@0: ************************************************************************/ sl@0: sl@0: CToneSoundDevPlayErrorReceiver::CToneSoundDevPlayErrorReceiver(CToneDataPath& aParent, TInt aPriority) sl@0: : CActive(aPriority), iParent(aParent) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CToneSoundDevPlayErrorReceiver::~CToneSoundDevPlayErrorReceiver() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CToneSoundDevPlayErrorReceiver::Start() sl@0: { sl@0: iParent.Device().NotifyPlayError(iStatus); sl@0: SetActive(); sl@0: } sl@0: sl@0: void CToneSoundDevPlayErrorReceiver::Stop() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CToneSoundDevPlayErrorReceiver::RunL() sl@0: { sl@0: TInt reason = iStatus.Int(); sl@0: Start(); sl@0: sl@0: // An error has been returned sl@0: #ifdef _SCW_DEBUG sl@0: RDebug::Print(_L("CToneSoundDevPlayErrorReceiver::RunL[%d]"), reason); sl@0: #endif sl@0: iParent.SoundDeviceException(reason); sl@0: } sl@0: sl@0: void CToneSoundDevPlayErrorReceiver::DoCancel() sl@0: { sl@0: iParent.Device().CancelNotifyPlayError(); sl@0: } sl@0: sl@0: sl@0: sl@0: /* sl@0: * CycleAudioBufferL sl@0: * sl@0: * Sets up a usable buffer for passing to MMF sl@0: * sl@0: * This method has been written such that it must allocate a new buffer before sl@0: * replacing the existing one. The purpose of this is to force creation of a sl@0: * new buffer. Simply deleting and then re-allocing may result in the same sl@0: * address being used. sl@0: * sl@0: * Only cycles if there is enough memory sl@0: * sl@0: */ sl@0: #ifdef __CYCLE_MMF_DATABUFFERS__ sl@0: CMMFDataBuffer* CToneDataPath::CycleAudioBuffer(CMMFDataBuffer* aBuffer) sl@0: { sl@0: CMMFDataBuffer* buffer = NULL; sl@0: TUint bufferSize = aBuffer->Data().MaxLength(); sl@0: sl@0: #ifdef __USE_MMF_TRANSFERBUFFERS__ sl@0: TRAPD(err, buffer = CreateTransferBufferL(bufferSize, static_cast(aBuffer))); sl@0: #else sl@0: TRAPD(err,buffer = CMMFDataBuffer::NewL(bufferSize)); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: delete aBuffer; sl@0: } sl@0: #endif sl@0: if (err != KErrNone) sl@0: {//there was a problem creating buffer eg OOM so use same buffer sl@0: buffer = aBuffer; sl@0: } sl@0: sl@0: return buffer; sl@0: sl@0: } sl@0: #endif sl@0: sl@0: /* sl@0: * DoCleanupRHandleBase sl@0: * sl@0: * This method will initially Close the handle and then delete it. sl@0: * sl@0: */ sl@0: #ifdef __USE_MMF_TRANSFERBUFFERS__ sl@0: inline static void DoCleanupRHandleBase(TAny* aRHandleBase) sl@0: { sl@0: ASSERT(aRHandleBase); sl@0: RHandleBase* rHandleBase = static_cast (aRHandleBase); sl@0: TRAPD(error, rHandleBase->Close()); sl@0: delete aRHandleBase; sl@0: } sl@0: sl@0: CMMFTransferBuffer* CToneDataPath::CreateTransferBufferL(TUint aBufferSize, CMMFTransferBuffer* aOldBuffer) sl@0: { sl@0: CMMFTransferBuffer* buffer = NULL; sl@0: sl@0: RTransferBuffer* transBuffer = new (ELeave) RTransferBuffer; sl@0: sl@0: TCleanupItem bufferCleanupItem(DoCleanupRHandleBase, transBuffer); //closes and deletes. sl@0: CleanupStack::PushL(bufferCleanupItem); sl@0: sl@0: RTransferWindow* transWindow = new (ELeave) RTransferWindow; sl@0: sl@0: TCleanupItem windowCleanupItem(DoCleanupRHandleBase, transWindow); //closes and deletes. sl@0: CleanupStack::PushL(windowCleanupItem); sl@0: sl@0: User::LeaveIfError(transBuffer->Create(aBufferSize)); sl@0: User::LeaveIfError(transWindow->Create(aBufferSize)); sl@0: User::LeaveIfError(transWindow->MapInBuffer(*transBuffer)); sl@0: sl@0: buffer = CMMFTransferBuffer::NewL(*transWindow); sl@0: sl@0: delete aOldBuffer; //closes RTransferWindow sl@0: delete iTransferWindow; sl@0: sl@0: if(iTransferBuffer) sl@0: { sl@0: iTransferBuffer->Close(); sl@0: } sl@0: delete iTransferBuffer; sl@0: sl@0: iTransferBuffer = transBuffer; sl@0: iTransferWindow = transWindow; sl@0: sl@0: CleanupStack::Pop(transWindow); sl@0: CleanupStack::Pop(transBuffer); sl@0: sl@0: return buffer; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: #ifdef __USE_MMF_PTRBUFFERS__ sl@0: CMMFPtrBuffer* CToneDataPath::CreatePtrBufferL(TUint aBufferSize) sl@0: { sl@0: CMMFPtrBuffer* buffer = NULL; sl@0: if (iPtrBufferMemoryBlock) sl@0: { sl@0: delete iPtrBufferMemoryBlock;//incase already exisits sl@0: } sl@0: iPtrBufferMemoryBlock = HBufC8::NewL(aBufferSize); sl@0: TPtr8 ptrMemoryBlock(iPtrBufferMemoryBlock->Des()); sl@0: buffer = CMMFPtrBuffer::NewL(ptrMemoryBlock); sl@0: return buffer; sl@0: } sl@0: #endif // __USE_MMF_PTRBUFFERS__ sl@0: sl@0: sl@0: