Update contrib.
2 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
3 // All rights reserved.
4 // This component and the accompanying materials are made available
5 // under the terms of "Eclipse Public License v1.0"
6 // which accompanies this distribution, and is available
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 // Initial Contributors:
10 // Nokia Corporation - initial contribution.
20 #include <mmf/server/mmfhwdevice.h>
21 #include "tonehwdevice.hrh" //for KUidToneHwDevice
22 #include <ecom/implementationproxy.h> // For making it ECom plugin
23 #include "tonehwdevice.h"
26 // EXTERNAL DATA STRUCTURES
28 // EXTERNAL FUNCTION PROTOTYPES
31 const TImplementationProxy ImplementationTable[] =
33 IMPLEMENTATION_PROXY_ENTRY(KUidToneHwDevice, CToneHwDevice::NewL),
35 //current supported sample rate
36 const TInt KSupportedSampleRate = 8000;
38 // ---------------------------------------------------------------------------
39 // Default constructor
40 // ---------------------------------------------------------------------------
42 CToneHwDevice::CToneHwDevice()
44 DP_CONTEXT(CToneHwDevice::CToneHwDevice *CD1*, CtxDevSound, DPLOCAL);
49 // -----------------------------------------------------------------------------
50 // Symbian 2nd phase constructor
51 // -----------------------------------------------------------------------------
53 void CToneHwDevice::ConstructL()
55 DP_CONTEXT(CToneHwDevice::ConstructL *CD0*, CtxDevSound, DPLOCAL);
58 iHwDataBufferFill = CMMFDataBuffer::NewL(sizeof(TToneData));
59 iHwDataBufferFill->SetLastBuffer(EFalse);
60 iHwDataBufferFill->Data().SetLength(sizeof(TToneData));
61 iHwDataBufferFill->SetRequestSizeL(sizeof(TToneData));
63 iCodec = new(ELeave)CToneCodec();
68 // -----------------------------------------------------------------------------
69 // Symbian constructor
70 // -----------------------------------------------------------------------------
72 CToneHwDevice* CToneHwDevice::NewL()
74 DP_STATIC_CONTEXT(CToneHwDevice::NewL *CD0*, CtxDevSound, DPLOCAL);
76 CToneHwDevice* self = new (ELeave) CToneHwDevice();
77 CleanupStack::PushL(self);
80 DP0_RET(self, "0x%x");
83 // ---------------------------------------------------------------------------
85 // ---------------------------------------------------------------------------
87 CToneHwDevice::~CToneHwDevice()
89 DP_CONTEXT(CToneHwDevice::~CToneHwDevice *CD0*, CtxDevSound, DPLOCAL);
91 delete iHwDataBufferFill;
93 delete iPlayCustomInterface;
116 CToneCodec& CToneHwDevice::Codec()
121 // ---------------------------------------------------------------------------
122 // from class CMMFHwDevice
123 // CToneHwDevice::Init
124 // ---------------------------------------------------------------------------
126 TInt CToneHwDevice::Init(THwDeviceInitParams& aDevInfo)
128 DP_CONTEXT(CToneHwDevice::Init *CD1*, CtxDevSound, DPLOCAL);
131 if (!iToneInitialized) // Check if tones is not initialized yet.
133 iToneInitialized = ETrue;
136 // [ precondition that aDevInfo has a valid observer ]
137 if (!aDevInfo.iHwDeviceObserver)
139 DP0_RET(KErrArgument, "%d");
142 iHwDeviceObserver = aDevInfo.iHwDeviceObserver;
144 //[ assert the post condition ]
147 DP0_RET(KErrNotSupported, "%d");
150 DP0_RET(KErrNone, "%d");
153 // ---------------------------------------------------------------------------
154 // from class CMMFHwDevice
155 // CToneHwDevice::Start
156 // ---------------------------------------------------------------------------
158 TInt CToneHwDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/)
160 DP_CONTEXT(CToneHwDevice::Start *CD1*, CtxDevSound, DPLOCAL);
163 TInt error = KErrNone;
165 // Start for first time OR resuming
166 if (!iTonePlaying || iDataPath->State() == CToneDataPath::EPaused)
168 iLastBuffer = EFalse;
169 //[ assert precondition that play custom interface is present]
170 //if there is no tone play custom interface then the user of the CToneHwDevice
171 //cannot have set any of the custom settings such as sample rate.
172 if (!iPlayCustomInterface)
174 DP0_RET(KErrNotReady, "%d");
181 TRAP(error,iDataPath = CToneDataPath::NewL());
182 if ((iDataPath)&&(error == KErrNone))
184 ASSERT(iHwDeviceObserver);
185 iDataPath->SetObserver(*this);
186 error = iDataPath->AddCodec(*iCodec);
187 if (error == KErrNone)
189 iDeviceBufferSize = (iCodec->SinkBufferSize());
193 if ((error == KErrNone) && (iDataPath->State() != CToneDataPath::EPlaying))
195 //datapath was created ok and we are not playing
196 if (iDataPath->State() == CToneDataPath::EStopped)
198 // starting from 'fresh so set sound device settings
199 if (!iDataPath->Device().Handle())
201 //if Device() is called then we need a valid sound device handle
202 error = iDataPath->Device().Open();
203 if (error != KErrNone)
205 DP0_RET(error, "%d");
209 static_cast<TToneCustomInterface*>(iPlayCustomInterface)->SetDevice(&(iDataPath->Device()));
211 TUint iVol = iPlayCustomInterface->Volume();
212 iDataPath->Device().SetPlayVolume(iVol);
214 soundDeviceSettings().iRate = iSampleRate;
216 //this would normally be pcm16
217 soundDeviceSettings().iEncoding = RMdaDevSound::EMdaSoundEncoding16BitPCM;
219 //1 = mono 2 = stereo
220 soundDeviceSettings().iChannels = iChannels;
222 //tell sound driver what buffer size to expect
223 //it is up the the implementor to make use the device can support
224 //the required buffer size
225 soundDeviceSettings().iBufferSize = iDeviceBufferSize;
226 error = iDataPath->Device().SetPlayFormat(soundDeviceSettings);
228 } // End of iDataPath->State() == CToneDataPath::EStopped
230 //else resuming from pause
231 if ((error == KErrNone)||(error == KErrInUse))
233 // Hw device hasn't played anything yet so don't change
234 // active buffer. This is checked in FillThisHwBuffer.
235 if(iDataPath->State() != CToneDataPath::EPaused)
237 iFirstCallFromHwDevice = ETrue;
239 iTonePlaying = ETrue;
240 error = iDataPath->Start();
242 }//status == KErrNone
244 else // if tone playback is already ongoing do nothing
246 DP0(DLINFO,"Previous tone call is not completed yet");
248 DP0_RET(error, "%d");
251 // ---------------------------------------------------------------------------
252 // from class CMMFHwDevice
253 // CToneHwDevice::Stop
254 // ---------------------------------------------------------------------------
255 TInt CToneHwDevice::Stop()
257 DP_CONTEXT(CToneHwDevice::Stop *CD1*, CtxDevSound, DPLOCAL);
261 iTonePlaying = EFalse;
266 DP0_RET(KErrNotReady, "%d");
272 //Setting device to NULL since after stop it doesn't exists any more
273 if(iPlayCustomInterface)
275 static_cast<TToneCustomInterface*>(iPlayCustomInterface)->SetDevice(NULL);
278 DP0_RET(KErrNone, "%d");
281 // ---------------------------------------------------------------------------
282 // from class CMMFHwDevice
283 // CToneHwDevice::Pause
284 // ---------------------------------------------------------------------------
286 TInt CToneHwDevice::Pause()
288 DP_CONTEXT(CToneHwDevice::Pause *CD1*, CtxDevSound, DPLOCAL);
293 DP0_RET(KErrNotReady, "%d");
297 DP0_RET(KErrNone, "%d");
300 // ---------------------------------------------------------------------------
301 // from class CMMFHwDevice
302 // CToneHwDevice::StopAndDeleteCodec
303 // ---------------------------------------------------------------------------
305 TInt CToneHwDevice::StopAndDeleteCodec()
307 DP_CONTEXT(CToneHwDevice::StopAndDeleteCodec *CD1*, CtxDevSound, DPLOCAL);
309 DP0_RET(KErrNotSupported, "%d");
312 // ---------------------------------------------------------------------------
313 // from class CMMFHwDevice
314 // CToneHwDevice::DeleteCodec
315 // ---------------------------------------------------------------------------
317 TInt CToneHwDevice::DeleteCodec()
319 DP_CONTEXT(CToneHwDevice::DeleteCodec *CD1*, CtxDevSound, DPLOCAL);
321 DP0_RET(KErrNotSupported, "%d");
324 // ---------------------------------------------------------------------------
325 // from class CMMFHwDevice
326 // CToneHwDevice::SetConfig
327 // ---------------------------------------------------------------------------
329 TInt CToneHwDevice::SetConfig(TTaskConfig& aConfig)
331 DP_CONTEXT(CToneHwDevice::SetConfig *CD1*, CtxDevSound, DPLOCAL);
334 if (aConfig.iUid != KUidRefDevSoundTaskConfig)
336 DP0_RET(KErrArgument, "%d");
339 if (aConfig.iRate != KSupportedSampleRate )
341 DP0_RET(KErrNotSupported, "%d");
344 iSampleRate = aConfig.iRate;
346 if (aConfig.iStereoMode == ETaskMono)
350 else if (aConfig.iStereoMode == ETaskInterleaved || aConfig.iStereoMode == ETaskNonInterleaved)
356 DP0_RET(KErrArgument, "%d");
359 DP0_RET(KErrNone, "%d");
362 // CToneHwDevice::FillThisHwBuffer
363 // ---------------------------------------------------------------------------
364 TInt CToneHwDevice::FillThisHwBuffer(CMMFBuffer& aHwBuffer)
366 DP_CONTEXT(CToneHwDevice::FillThisHwBuffer *CD1*, CtxDevSound, DPLOCAL);
371 if(iFirstCallFromHwDevice)
373 err = iHwDeviceObserver->FillThisHwBuffer(aHwBuffer);
377 err = ThisHwBufferFilled(aHwBuffer);
382 // ---------------------------------------------------------------------------
383 // from class CMMFHwDevice
384 // CToneHwDevice::ThisHwBufferFilled
385 // ---------------------------------------------------------------------------
387 TInt CToneHwDevice::ThisHwBufferFilled(CMMFBuffer& aMmfBuffer)
389 DP_CONTEXT(CToneHwDevice::ThisHwBufferFilled *CD1*, CtxDevSound, DPLOCAL);
393 CMMFDataBuffer* myBuffer = static_cast<CMMFDataBuffer*> (&aMmfBuffer);
394 // Set the request length, From HwDevice this comes with buffer
396 TInt len = myBuffer->Data().MaxLength();
397 // Ignore error. since buffer size = Buffer Length
398 TRAP(err, myBuffer->SetRequestSizeL(len));
400 if(iFirstCallFromHwDevice)
402 myBuffer->SetLastBuffer(EFalse);
404 Mem::Copy((TAny*)(&myToneData), (TAny*)(myBuffer->Data().Ptr()), sizeof(TToneData));
406 err = ReadToneData();
409 err= GenerateBufferData();
414 // Hw device will call this method right after its Start was called.
415 // When it calls this for the first time it hasn't played one single
416 // buffer yet so check that.
417 // In this case there's no need to set the active buffer as it's already
418 // waiting to be played.
419 SetActiveToneBuffer();
424 // If there is no data in the active buffer, tone play is finished.
425 // DevSound just have to wait for completion event from audio device.
426 if (iActiveToneBuffer->Data().Length() == 0)
428 iActiveToneBuffer->SetLastBuffer(ETrue);
429 myBuffer->SetLastBuffer(ETrue);
433 TInt tonelen = iActiveToneBuffer->Data().Length();
435 // don't enter more data than can be handled by the receiving buffer
441 // Copy data from tone buffer to hw device buffer
442 Mem::Copy((TAny*)(myBuffer->Data().Ptr()), (TAny*)(iActiveToneBuffer->Data().Ptr()), len);
444 myBuffer->Data().SetLength(len);
446 //Play data and try to generate next data block
447 TRAP(err,iDataPath->BufferFilledL(static_cast<CMMFDataBuffer&> (*myBuffer)));
452 // coverity[check_after_deref]
458 iFirstCallFromHwDevice = EFalse;
462 // Check again whether this is the first call from Hw device.
463 // FillFreeToneBuffer assumes the iActiveToneBuffer has already
465 if (!iFirstCallFromHwDevice)
467 err = FillFreeToneBuffer();
471 iFirstCallFromHwDevice = EFalse; // Reset flag
476 if ( err != KErrNone )
478 myBuffer->SetLastBuffer(ETrue);
479 myBuffer->Data().SetLength(0);
480 //Use error additional variable for sending last buffer so can still send Error(err)
481 TRAPD(datapathErr, iDataPath->BufferFilledL(static_cast<CMMFDataBuffer&> (*myBuffer)));
482 // coverity[check_after_deref]
488 iFirstCallFromHwDevice = EFalse;
489 if ( datapathErr != KErrNone )
491 iHwDeviceObserver->Error(datapathErr);
492 DP0_RET(datapathErr, "%d");
494 iHwDeviceObserver->Error(err);
499 // ---------------------------------------------------------------------------
500 // from class MMMFHwDeviceObserver
501 // CToneHwDevice::ThisHwBufferEmptied
502 // ---------------------------------------------------------------------------
503 TInt CToneHwDevice::ThisHwBufferEmptied(CMMFBuffer& /*aMmfBuffer*/)
505 DP_CONTEXT(CToneHwDevice::ThisHwBufferEmptied *CD1*, CtxDevSound, DPLOCAL);
507 DP0_RET(KErrNotSupported, "%d");
510 // ---------------------------------------------------------------------------
511 // from class MMMFHwDeviceObserver
512 // CToneHwDevice::EmptyThisHwBuffer
513 // ---------------------------------------------------------------------------
514 TInt CToneHwDevice::EmptyThisHwBuffer(CMMFBuffer& /*aMmfBuffer*/)
516 DP_CONTEXT(CToneHwDevice::EmptyThisHwBuffer *CD1*, CtxDevSound, DPLOCAL);
518 DP0_RET(KErrNotSupported, "%d");
521 // ---------------------------------------------------------------------------
522 // from class MMMFHwDeviceObserver
523 // CToneHwDevice::MsgFromHwDevice
524 // ---------------------------------------------------------------------------
525 TInt CToneHwDevice::MsgFromHwDevice(TUid aMessageType, const TDesC8& aMsg)
527 DP_CONTEXT(CToneHwDevice::MsgFromHwDevice *CD1*, CtxDevSound, DPLOCAL);
530 err = iHwDeviceObserver->MsgFromHwDevice(aMessageType, aMsg);
534 // ---------------------------------------------------------------------------
535 // from class MMMFHwDeviceObserver
536 // CToneHwDevice::Stopped
537 // ---------------------------------------------------------------------------
538 void CToneHwDevice::Stopped()
540 DP_CONTEXT(CToneHwDevice::Stopped *CD1*, CtxDevSound, DPLOCAL);
542 iHwDeviceObserver->Stopped();
546 // ---------------------------------------------------------------------------
547 // from class MMMFHwDeviceObserver
548 // CToneHwDevice::Error
549 // ---------------------------------------------------------------------------
550 void CToneHwDevice::Error(TInt aError)
552 DP_CONTEXT(CToneHwDevice::Error *CD1*, CtxDevSound, DPLOCAL);
554 iHwDeviceObserver->Error(aError);
558 // ---------------------------------------------------------------------------
559 // from class CMMFHwDevice
560 // CToneHwDevice::CustomInterface
561 // ---------------------------------------------------------------------------
563 TAny* CToneHwDevice::CustomInterface(TUid aInterfaceUid)
565 DP_CONTEXT(CToneHwDevice::CustomInterface *CD1*, CtxDevSound, DPLOCAL);
571 if (aInterfaceUid.iUid == KMmfPlaySettingsCustomInterface)
573 if (!iPlayCustomInterface)
575 TRAP(err,iPlayCustomInterface = new(ELeave)TToneCustomInterface());
583 ret = static_cast<TAny*>(iPlayCustomInterface);
586 else if (aInterfaceUid == KIgnoreUnderflowCustomInterfaceTypeUid)
594 ret = static_cast<CToneDataPath*>(iDataPath)->CustomInterface(aInterfaceUid);
602 TInt CToneHwDevice::ReadToneData()
604 DP_CONTEXT(CToneHwDevice::ReadToneData *CD1*, CtxDevSound, DPLOCAL);
608 myToneData.GetType(iToneType);
610 iFrequency1 = myToneData.GetFrequencyOne();
611 iFrequency2 = myToneData.GetFrequencyTwo();
612 myToneData.GetDuration(iDuration);
614 myToneData.GetRepeatTrailingSilence(iRepeatTrailingSilence);
615 iRepeatCount = myToneData.GetRepeatCount();
616 iRampDuration = iPlayCustomInterface->VolumeRamp();
617 vol = iPlayCustomInterface->Volume();
618 iDataPath->Device().SetPlayVolume(vol);
621 case TToneData::ESimple:
622 DP0(DLINFO, "Playing simple tone");
623 iDataPath->Device().GetPlayFormat(soundDeviceSettings);
624 if((iFrequency1<0) || (iDuration.Int64() < zeroInt64))
626 iHwDeviceObserver->Error(KErrArgument);
627 DP0_RET(KErrArgument, "%d");
629 iToneGen.SetFrequencyAndDuration(iFrequency1,iDuration);
630 // Configure tone generator
632 soundDeviceSettings().iRate,
633 soundDeviceSettings().iChannels,
635 I64LOW((iRepeatTrailingSilence.Int64()*soundDeviceSettings().iRate)/1000000),
636 I64LOW((iRampDuration.Int64()*soundDeviceSettings().iRate)/1000000)
638 iCurrentGenerator = &iToneGen;
640 case TToneData::EDual:
641 DP0(DLINFO, "Playing dual tone");
642 iDataPath->Device().GetPlayFormat(soundDeviceSettings);
643 if((iFrequency1<0) || (iFrequency2<0) || (iDuration.Int64() < zeroInt64))
645 iHwDeviceObserver->Error(KErrArgument);
646 DP0_RET(KErrArgument, "%d");
648 iDualToneGen.SetFrequencyAndDuration(iFrequency1, iFrequency2, iDuration);
649 // Configure dual tone generator
650 iDualToneGen.Configure(
651 soundDeviceSettings().iRate,
652 soundDeviceSettings().iChannels,
654 I64LOW((iRepeatTrailingSilence.Int64()*soundDeviceSettings().iRate)/KOneMillionMicroSeconds),
655 I64LOW((iRampDuration.Int64()*soundDeviceSettings().iRate)/KOneMillionMicroSeconds)
657 iCurrentGenerator = &iDualToneGen;
659 case TToneData::EDtmfString:
660 DP0(DLINFO, "Playing DTMF string");
661 myToneData.GetDtmfLenghts(myToneOnLength, myToneOffLength, myPauseLength);
662 iDTMFGen.SetToneDurations(myToneOnLength, myToneOffLength, myPauseLength);
663 iDTMFString = myToneData.GetDTMFString();
664 if(!ValidDTMFString(const_cast<TDesC&>(*iDTMFString)))
666 DP0(DLINFO, "Invalid DTMF String");
667 iHwDeviceObserver->Error(KErrCorrupt);
668 DP0_RET(KErrCorrupt, "%d");
670 iDTMFGen.SetString(const_cast<TDesC&>(*iDTMFString));
671 iDataPath->Device().GetPlayFormat(soundDeviceSettings);
673 soundDeviceSettings().iRate,
674 soundDeviceSettings().iChannels,
676 I64LOW((iRepeatTrailingSilence.Int64()*soundDeviceSettings().iRate)/1000000),
677 I64LOW((iRampDuration.Int64()*soundDeviceSettings().iRate)/1000000)
679 iCurrentGenerator = &iDTMFGen;
681 case TToneData::ESequence:
682 DP0(DLINFO, "Playing tone sequence");
683 iSequenceData = myToneData.GetSequenceData();
684 // Check whether the sequence is signed or not
685 if (!RecognizeSequence(*iSequenceData))
687 DP0(DLINFO, "Invalid Sequence Sign");
688 iHwDeviceObserver->Error(KErrCorrupt);
689 DP0_RET(KErrCorrupt, "%d");
691 iSequenceGen.SetSequenceData(*iSequenceData);
692 iDataPath->Device().GetPlayFormat(soundDeviceSettings);
693 iSequenceGen.Configure(
694 soundDeviceSettings().iRate,
695 soundDeviceSettings().iChannels,
697 I64LOW((iRepeatTrailingSilence.Int64()*soundDeviceSettings().iRate)/1000000),
698 I64LOW((iRampDuration.Int64()*soundDeviceSettings().iRate)/1000000)
700 iCurrentGenerator = &iSequenceGen;
702 case TToneData::EFixedSequence:
703 DP0(DLINFO, "Playing FixedSequnce");
704 iHwDeviceObserver->Error(KErrNotSupported);
705 DP0_RET(KErrNotSupported, "%d");
707 DP0_RET(KErrNotSupported, "%d");
709 DP0_RET(KErrNone, "%d");
714 * Creates buffer and begin playback using the specified tone generator.
717 TInt CToneHwDevice::GenerateBufferData()
719 DP_CONTEXT(CToneHwDevice::GenerateBufferData *CD1*, CtxDevSound, DPLOCAL);
725 // Delete any buffer from previous call and try to create maximum buffer
726 // size. Double Buffer the Tone data.
732 //note the tone buffer needs to be the same as the pcm16->pcm16 'null'
734 // Buffer size = (SampleRate * BytesPerSample * Channels) / 4
735 TInt useBufferOfSize = ((SamplingFrequency() * 2 * NumberOfChannels())/KDevSoundFramesPerSecond + (KDevSoundDeltaFrameSize-1)) &~ (KDevSoundDeltaFrameSize-1);
736 //clamp buffer to desired limits
737 if(useBufferOfSize < KDevSoundMinFrameSize)
739 useBufferOfSize = KDevSoundMinFrameSize;
741 else if(useBufferOfSize > KDevSoundMaxFrameSize)
743 useBufferOfSize = KDevSoundMaxFrameSize;
746 TRAP(err, iToneBuffer1 = CMMFDataBuffer::NewL(useBufferOfSize));
747 if ( err != KErrNone )
752 err = iCurrentGenerator->FillBuffer(iToneBuffer1->Data());
764 TRAP(err, iToneBuffer2 = CMMFDataBuffer::NewL(useBufferOfSize));
765 if ( err != KErrNone )
770 err = iCurrentGenerator->FillBuffer(iToneBuffer2->Data());
776 // Assign active buffer
777 iActiveToneBuffer = iToneBuffer1;
778 DP0_RET(KErrNone, "%d");
783 * This method assigns the other buffer as active buffer. The tone audio
784 * generator should fill data in the other buffer by now.
787 void CToneHwDevice::SetActiveToneBuffer()
789 if (iActiveToneBuffer == iToneBuffer1)
790 iActiveToneBuffer = iToneBuffer2;
791 else if (iActiveToneBuffer == iToneBuffer2)
792 iActiveToneBuffer = iToneBuffer1;
796 void CToneHwDevice::FreeBuffers()
812 * Returns an integer representing Sampling Frequency the device is currently
816 * Sampling Frequency.
819 TInt CToneHwDevice::SamplingFrequency()
826 * Returns an integer representing number of channels the device is currently
830 * Number of audio channels 1 if mono, 2 if stereo.
833 TInt CToneHwDevice::NumberOfChannels()
835 if(iChannels == EMMFMono)
843 * This method fills data into the free buffer.
846 * Error code. KErrNone if success.
849 TInt CToneHwDevice::FillFreeToneBuffer()
852 if (iActiveToneBuffer == iToneBuffer1)
854 err = iCurrentGenerator->FillBuffer(iToneBuffer2->Data());
856 else if (iActiveToneBuffer == iToneBuffer2)
858 err = iCurrentGenerator->FillBuffer(iToneBuffer1->Data());
863 TBool CToneHwDevice::RecognizeSequence(const TDesC8& aData)
865 // Reference plug-in only supports its own sequence format
866 _LIT8(KSequenceSignature,"SQNC");
867 if (aData.Length() > 4)
869 if (aData.Left(4) == KSequenceSignature)
878 TBool CToneHwDevice::ValidDTMFString(const TDesC& aDTMFString)
880 const TDesC* stringDTMF = &aDTMFString;;
882 if (stringPos == stringDTMF->Length())
884 return EFalse; // Finished. Nothing to do
888 TChar c((*stringDTMF)[stringPos++]);
889 if (static_cast<TUint> (c)=='#' || static_cast<TUint> (c)=='*' || static_cast<TUint> (c)==',' || c.IsHexDigit() || c.IsSpace())
891 //Do nothing, valid character
899 while(stringPos < stringDTMF->Length());
904 /************************************************************************
905 * TToneCustomInterface *
906 ************************************************************************/
908 * This method is not be exported as it is only
909 * intended to be called within this DLL.
910 * It's purpose is to assign an RMdaDevSound to the play
914 void TToneCustomInterface::SetDevice(RMdaDevSound* aDevice)
919 void TToneCustomInterface::SetVolume(TUint aVolume)
922 if (iDevice && iDevice->Handle()!=0)
924 iDevice->SetPlayVolume(aVolume);
929 * Procedure to get the number of bytes played by the device driver
930 * If there is no handle available to the device driver then the
931 * procedure returns the last known value
933 * @return number of bytes played
935 TUint TToneCustomInterface::BytesPlayed()
939 if (iDevice->Handle())
941 iBytesPlayed = iDevice->BytesPlayed();
949 // class CToneCodec //
952 // ---------------------------------------------------------------------------
953 // from class CToneCodec
954 // CToneCodec::CToneCodec
955 // ---------------------------------------------------------------------------
957 CToneCodec::CToneCodec()
961 // ---------------------------------------------------------------------------
962 // from class CToneCodec
963 // CToneCodec::~CToneCodec
964 // ---------------------------------------------------------------------------
966 CToneCodec::~CToneCodec()
970 // ---------------------------------------------------------------------------
971 // from class CToneCodec
972 // CToneCodec::ConstructL
973 // ---------------------------------------------------------------------------
975 void CToneCodec::ConstructL()
980 // ---------------------------------------------------------------------------
981 // from class CToneCodec
982 // CToneCodec::ProcessL
983 // ---------------------------------------------------------------------------
985 CToneCodec::TCodecProcessResult CToneCodec::ProcessL(const CMMFBuffer& /*aSource*/, CMMFBuffer& /*aDest*/)
987 //no processing required for null codec
988 User::Leave(KErrNotSupported);
989 //to keep compiler happy
990 TCodecProcessResult result;
991 result.iCodecProcessStatus = TCodecProcessResult::EEndOfData;
992 result.iSrcBytesProcessed = 0;
993 result.iDstBytesAdded = 0;
997 // ---------------------------------------------------------------------------
998 // from class CToneCodec
999 // CToneCodec::SourceBufferSize
1000 // ---------------------------------------------------------------------------
1002 TUint CToneCodec::SourceBufferSize()
1004 return KPCM16ToPCM16BufferSize;
1007 // ---------------------------------------------------------------------------
1008 // from class CToneCodec
1009 // CToneCodec::SinkBufferSize
1010 // ---------------------------------------------------------------------------
1012 TUint CToneCodec::SinkBufferSize()
1014 return KPCM16ToPCM16BufferSize;
1018 // ========================== OTHER EXPORTED FUNCTIONS =========================
1020 * ImplementationGroupProxy
1021 * is called to get a pointer to the plugin's implementation table, or table
1022 * of functions used to instantiate the plugin.
1024 * @param aTableCount returns the number of functions in the table.
1025 * @return retuns a pointer to the table.
1027 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1029 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1030 return ImplementationTable;