diff -r 000000000000 -r bde4ae8d615e os/kernelhwsrv/kerneltest/e32test/multimedia/t_soundutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/kernelhwsrv/kerneltest/e32test/multimedia/t_soundutils.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,418 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\multimedia\t_soundutils.cpp +// +// + +/** + @file Utilities used by the shared chunk sound driver test code. +*/ + +#include +#include +#include "t_soundutils.h" + +const TInt SineAddressBits = 10; +const TInt SineAddressFractionBits = 32-SineAddressBits; +const TInt SineTableSize = 1<>SineAddressFractionBits]; + if (aPlayFormat.iChannels == 2) + *ptr++ = (TInt16)table[index>>SineAddressFractionBits]; + index += step; + } + } + break; + case ESoundEncoding8BitPCM: + { + TUint8* ptr = (TUint8*)aBuffer.Ptr(); + TUint8* end = ptr+aBuffer.Length(); + while(ptr>8]; + if (aPlayFormat.iChannels == 2) + *ptr++ = (TInt8)table[index>>8]; + index += step; + } + } + break; + case ESoundEncoding24BitPCM: + { + TUint8* ptr = (TUint8*)aBuffer.Ptr(); + TUint8* end = ptr+aBuffer.Length(); + while(ptr>24]; + if (aPlayFormat.iChannels == 2) + *ptr++ = (TInt8)table[index>>24]; + index += step; + } + } + break; + + default: + break; + } + + ToneIndex = index; + } + +GLDEF_C void Cleanup() + { + delete SineTable; + } + +GLDEF_C void PrintCaps(TSoundFormatsSupportedV02& aCaps,RTest& aTest) + { + TBuf<128> buf; + + aTest.Printf(_L("**Sound Capabilities**\r\n")); + + // Display the data transfer direction + buf.Zero(); + buf.Append(KSndDirCapsTitle); + if (aCaps.iDirection==ESoundDirRecord) + buf.Append(KSndDirRecord); + else + buf.Append(KSndDirPlay); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the channel configuration + buf.Zero(); + buf.Append(KSndChanConfigCapsTitle); + if (aCaps.iChannels & KSoundMonoChannel) + buf.Append(KSndChanConfigMono); + if (aCaps.iChannels & KSoundStereoChannel) + buf.Append(KSndChanConfigStereo); + if (aCaps.iChannels & KSoundThreeChannel) + buf.Append(KSndChanConfig3Chan); + if (aCaps.iChannels & KSoundFourChannel) + buf.Append(KSndChanConfig4Chan); + if (aCaps.iChannels & KSoundFiveChannel) + buf.Append(KSndChanConfig5Chan); + if (aCaps.iChannels & KSoundSixChannel) + buf.Append(KSndChanConfig6Chan); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the supported sample rates + buf.Zero(); + buf.Append(KSndRateCapsTitle); + if (aCaps.iRates & KSoundRate7350Hz) + buf.Append(KSndRate7350Hz); + if (aCaps.iRates & KSoundRate8000Hz) + buf.Append(KSndRate8000Hz); + if (aCaps.iRates & KSoundRate8820Hz) + buf.Append(KSndRate8820Hz); + if (aCaps.iRates & KSoundRate9600Hz) + buf.Append(KSndRate9600Hz); + if (aCaps.iRates & KSoundRate11025Hz) + buf.Append(KSndRate11025Hz); + if (aCaps.iRates & KSoundRate12000Hz) + buf.Append(KSndRate12000Hz); + if (aCaps.iRates & KSoundRate14700Hz) + buf.Append(KSndRate14700Hz); + if (aCaps.iRates & KSoundRate16000Hz) + buf.Append(KSndRate16000Hz); + if (aCaps.iRates & KSoundRate22050Hz) + buf.Append(KSndRate22050Hz); + if (aCaps.iRates & KSoundRate24000Hz) + buf.Append(KSndRate24000Hz); + if (aCaps.iRates & KSoundRate29400Hz) + buf.Append(KSndRate29400Hz); + if (aCaps.iRates & KSoundRate32000Hz) + buf.Append(KSndRate32000Hz); + if (aCaps.iRates & KSoundRate44100Hz) + buf.Append(KSndRate44100Hz); + if (aCaps.iRates & KSoundRate48000Hz) + buf.Append(KSndRate48000Hz); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the sound encodings supported + buf.Zero(); + buf.Append(KSndEncodingCapsTitle); + if (aCaps.iEncodings & KSoundEncoding8BitPCM) + buf.Append(KSndEncoding8BitPCM); + if (aCaps.iEncodings & KSoundEncoding16BitPCM) + buf.Append(KSndEncoding16BitPCM); + if (aCaps.iEncodings & KSoundEncoding24BitPCM) + buf.Append(KSndEncoding24BitPCM); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the data formats supported + buf.Zero(); + buf.Append(KSndDataFormatCapsTitle); + if (aCaps.iDataFormats & KSoundDataFormatInterleaved) + buf.Append(KSndDataFormatInterleaved); + if (aCaps.iDataFormats & KSoundDataFormatNonInterleaved) + buf.Append(KSndDataFormatNonInterleaved); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the minimum request size and the request alignment factor. + aTest.Printf(_L("Min req size : %d\r\n"),aCaps.iRequestMinSize); + aTest.Printf(_L("Req alignment: %d\r\n"),aCaps.iRequestAlignment); + } + +GLDEF_C void PrintConfig(TCurrentSoundFormatV02& aConfig,RTest& aTest) + { + TBuf<80> buf; + + aTest.Printf(_L("**Sound configuration**\r\n")); + + // Display the current channel configuration + aTest.Printf(_L("Channels : %d\r\n"),aConfig.iChannels); + + // Display the current sample rate + buf.Zero(); + buf.Append(KSndRateConfigTitle); + if (aConfig.iRate==ESoundRate7350Hz) + buf.Append(KSndRate7350Hz); + else if (aConfig.iRate==ESoundRate8000Hz) + buf.Append(KSndRate8000Hz); + else if (aConfig.iRate==ESoundRate8820Hz) + buf.Append(KSndRate8820Hz); + else if (aConfig.iRate==ESoundRate9600Hz) + buf.Append(KSndRate9600Hz); + else if (aConfig.iRate==ESoundRate11025Hz) + buf.Append(KSndRate11025Hz); + else if (aConfig.iRate==ESoundRate12000Hz) + buf.Append(KSndRate12000Hz); + else if (aConfig.iRate==ESoundRate14700Hz) + buf.Append(KSndRate14700Hz); + else if (aConfig.iRate==ESoundRate16000Hz) + buf.Append(KSndRate16000Hz); + else if (aConfig.iRate==ESoundRate22050Hz) + buf.Append(KSndRate22050Hz); + else if (aConfig.iRate==ESoundRate24000Hz) + buf.Append(KSndRate24000Hz); + else if (aConfig.iRate==ESoundRate29400Hz) + buf.Append(KSndRate29400Hz); + else if (aConfig.iRate==ESoundRate32000Hz) + buf.Append(KSndRate32000Hz); + else if (aConfig.iRate==ESoundRate44100Hz) + buf.Append(KSndRate44100Hz); + else if (aConfig.iRate==ESoundRate48000Hz) + buf.Append(KSndRate48000Hz); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the current encoding + buf.Zero(); + buf.Append(KSndEncodingConfigTitle); + if (aConfig.iEncoding==ESoundEncoding8BitPCM) + buf.Append(KSndEncoding8BitPCM); + else if (aConfig.iEncoding==ESoundEncoding16BitPCM) + buf.Append(KSndEncoding16BitPCM); + else if (aConfig.iEncoding==ESoundEncoding24BitPCM) + buf.Append(KSndEncoding24BitPCM); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + + // Display the current data format + buf.Zero(); + buf.Append(KSndDataFormatConfigTitle); + if (aConfig.iDataFormat==ESoundDataFormatInterleaved) + buf.Append(KSndDataFormatInterleaved); + else if (aConfig.iDataFormat==ESoundDataFormatNonInterleaved) + buf.Append(KSndDataFormatNonInterleaved); + buf.Append(_L("\r\n")); + aTest.Printf(buf); + } + +GLDEF_C void PrintBufferConf(TTestSharedChunkBufConfig& aBufConf,RTest& aTest) + { + TBuf<80> buf(0); + + aTest.Printf(_L("**Buffer configuration**\r\n")); + + // Display the buffer configuration + buf.Format(_L("NumBufs:%d Size:%xH(%d)\r\n"),aBufConf.iNumBuffers,aBufConf.iBufferSizeInBytes,aBufConf.iBufferSizeInBytes); + aTest.Printf(buf); + if (aBufConf.iFlags & KScFlagBufOffsetListInUse) + { + buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),aBufConf.iBufferOffsetList[0],aBufConf.iBufferOffsetList[1],aBufConf.iBufferOffsetList[2],aBufConf.iBufferOffsetList[3]); + aTest.Printf(buf); + buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),aBufConf.iBufferOffsetList[4],aBufConf.iBufferOffsetList[5],aBufConf.iBufferOffsetList[6],aBufConf.iBufferOffsetList[7]); + aTest.Printf(buf); + } + }