sl@0: // Copyright (c) 2006-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 the License "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: // e32test\multimedia\t_soundutils.cpp sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file Utilities used by the shared chunk sound driver test code. sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include "t_soundutils.h" sl@0: sl@0: const TInt SineAddressBits = 10; sl@0: const TInt SineAddressFractionBits = 32-SineAddressBits; sl@0: const TInt SineTableSize = 1<>SineAddressFractionBits]; sl@0: if (aPlayFormat.iChannels == 2) sl@0: *ptr++ = (TInt16)table[index>>SineAddressFractionBits]; sl@0: index += step; sl@0: } sl@0: } sl@0: break; sl@0: case ESoundEncoding8BitPCM: sl@0: { sl@0: TUint8* ptr = (TUint8*)aBuffer.Ptr(); sl@0: TUint8* end = ptr+aBuffer.Length(); sl@0: while(ptr>8]; sl@0: if (aPlayFormat.iChannels == 2) sl@0: *ptr++ = (TInt8)table[index>>8]; sl@0: index += step; sl@0: } sl@0: } sl@0: break; sl@0: case ESoundEncoding24BitPCM: sl@0: { sl@0: TUint8* ptr = (TUint8*)aBuffer.Ptr(); sl@0: TUint8* end = ptr+aBuffer.Length(); sl@0: while(ptr>24]; sl@0: if (aPlayFormat.iChannels == 2) sl@0: *ptr++ = (TInt8)table[index>>24]; sl@0: index += step; sl@0: } sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: break; sl@0: } sl@0: sl@0: ToneIndex = index; sl@0: } sl@0: sl@0: GLDEF_C void Cleanup() sl@0: { sl@0: delete SineTable; sl@0: } sl@0: sl@0: GLDEF_C void PrintCaps(TSoundFormatsSupportedV02& aCaps,RTest& aTest) sl@0: { sl@0: TBuf<128> buf; sl@0: sl@0: aTest.Printf(_L("**Sound Capabilities**\r\n")); sl@0: sl@0: // Display the data transfer direction sl@0: buf.Zero(); sl@0: buf.Append(KSndDirCapsTitle); sl@0: if (aCaps.iDirection==ESoundDirRecord) sl@0: buf.Append(KSndDirRecord); sl@0: else sl@0: buf.Append(KSndDirPlay); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the channel configuration sl@0: buf.Zero(); sl@0: buf.Append(KSndChanConfigCapsTitle); sl@0: if (aCaps.iChannels & KSoundMonoChannel) sl@0: buf.Append(KSndChanConfigMono); sl@0: if (aCaps.iChannels & KSoundStereoChannel) sl@0: buf.Append(KSndChanConfigStereo); sl@0: if (aCaps.iChannels & KSoundThreeChannel) sl@0: buf.Append(KSndChanConfig3Chan); sl@0: if (aCaps.iChannels & KSoundFourChannel) sl@0: buf.Append(KSndChanConfig4Chan); sl@0: if (aCaps.iChannels & KSoundFiveChannel) sl@0: buf.Append(KSndChanConfig5Chan); sl@0: if (aCaps.iChannels & KSoundSixChannel) sl@0: buf.Append(KSndChanConfig6Chan); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the supported sample rates sl@0: buf.Zero(); sl@0: buf.Append(KSndRateCapsTitle); sl@0: if (aCaps.iRates & KSoundRate7350Hz) sl@0: buf.Append(KSndRate7350Hz); sl@0: if (aCaps.iRates & KSoundRate8000Hz) sl@0: buf.Append(KSndRate8000Hz); sl@0: if (aCaps.iRates & KSoundRate8820Hz) sl@0: buf.Append(KSndRate8820Hz); sl@0: if (aCaps.iRates & KSoundRate9600Hz) sl@0: buf.Append(KSndRate9600Hz); sl@0: if (aCaps.iRates & KSoundRate11025Hz) sl@0: buf.Append(KSndRate11025Hz); sl@0: if (aCaps.iRates & KSoundRate12000Hz) sl@0: buf.Append(KSndRate12000Hz); sl@0: if (aCaps.iRates & KSoundRate14700Hz) sl@0: buf.Append(KSndRate14700Hz); sl@0: if (aCaps.iRates & KSoundRate16000Hz) sl@0: buf.Append(KSndRate16000Hz); sl@0: if (aCaps.iRates & KSoundRate22050Hz) sl@0: buf.Append(KSndRate22050Hz); sl@0: if (aCaps.iRates & KSoundRate24000Hz) sl@0: buf.Append(KSndRate24000Hz); sl@0: if (aCaps.iRates & KSoundRate29400Hz) sl@0: buf.Append(KSndRate29400Hz); sl@0: if (aCaps.iRates & KSoundRate32000Hz) sl@0: buf.Append(KSndRate32000Hz); sl@0: if (aCaps.iRates & KSoundRate44100Hz) sl@0: buf.Append(KSndRate44100Hz); sl@0: if (aCaps.iRates & KSoundRate48000Hz) sl@0: buf.Append(KSndRate48000Hz); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the sound encodings supported sl@0: buf.Zero(); sl@0: buf.Append(KSndEncodingCapsTitle); sl@0: if (aCaps.iEncodings & KSoundEncoding8BitPCM) sl@0: buf.Append(KSndEncoding8BitPCM); sl@0: if (aCaps.iEncodings & KSoundEncoding16BitPCM) sl@0: buf.Append(KSndEncoding16BitPCM); sl@0: if (aCaps.iEncodings & KSoundEncoding24BitPCM) sl@0: buf.Append(KSndEncoding24BitPCM); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the data formats supported sl@0: buf.Zero(); sl@0: buf.Append(KSndDataFormatCapsTitle); sl@0: if (aCaps.iDataFormats & KSoundDataFormatInterleaved) sl@0: buf.Append(KSndDataFormatInterleaved); sl@0: if (aCaps.iDataFormats & KSoundDataFormatNonInterleaved) sl@0: buf.Append(KSndDataFormatNonInterleaved); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the minimum request size and the request alignment factor. sl@0: aTest.Printf(_L("Min req size : %d\r\n"),aCaps.iRequestMinSize); sl@0: aTest.Printf(_L("Req alignment: %d\r\n"),aCaps.iRequestAlignment); sl@0: } sl@0: sl@0: GLDEF_C void PrintConfig(TCurrentSoundFormatV02& aConfig,RTest& aTest) sl@0: { sl@0: TBuf<80> buf; sl@0: sl@0: aTest.Printf(_L("**Sound configuration**\r\n")); sl@0: sl@0: // Display the current channel configuration sl@0: aTest.Printf(_L("Channels : %d\r\n"),aConfig.iChannels); sl@0: sl@0: // Display the current sample rate sl@0: buf.Zero(); sl@0: buf.Append(KSndRateConfigTitle); sl@0: if (aConfig.iRate==ESoundRate7350Hz) sl@0: buf.Append(KSndRate7350Hz); sl@0: else if (aConfig.iRate==ESoundRate8000Hz) sl@0: buf.Append(KSndRate8000Hz); sl@0: else if (aConfig.iRate==ESoundRate8820Hz) sl@0: buf.Append(KSndRate8820Hz); sl@0: else if (aConfig.iRate==ESoundRate9600Hz) sl@0: buf.Append(KSndRate9600Hz); sl@0: else if (aConfig.iRate==ESoundRate11025Hz) sl@0: buf.Append(KSndRate11025Hz); sl@0: else if (aConfig.iRate==ESoundRate12000Hz) sl@0: buf.Append(KSndRate12000Hz); sl@0: else if (aConfig.iRate==ESoundRate14700Hz) sl@0: buf.Append(KSndRate14700Hz); sl@0: else if (aConfig.iRate==ESoundRate16000Hz) sl@0: buf.Append(KSndRate16000Hz); sl@0: else if (aConfig.iRate==ESoundRate22050Hz) sl@0: buf.Append(KSndRate22050Hz); sl@0: else if (aConfig.iRate==ESoundRate24000Hz) sl@0: buf.Append(KSndRate24000Hz); sl@0: else if (aConfig.iRate==ESoundRate29400Hz) sl@0: buf.Append(KSndRate29400Hz); sl@0: else if (aConfig.iRate==ESoundRate32000Hz) sl@0: buf.Append(KSndRate32000Hz); sl@0: else if (aConfig.iRate==ESoundRate44100Hz) sl@0: buf.Append(KSndRate44100Hz); sl@0: else if (aConfig.iRate==ESoundRate48000Hz) sl@0: buf.Append(KSndRate48000Hz); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the current encoding sl@0: buf.Zero(); sl@0: buf.Append(KSndEncodingConfigTitle); sl@0: if (aConfig.iEncoding==ESoundEncoding8BitPCM) sl@0: buf.Append(KSndEncoding8BitPCM); sl@0: else if (aConfig.iEncoding==ESoundEncoding16BitPCM) sl@0: buf.Append(KSndEncoding16BitPCM); sl@0: else if (aConfig.iEncoding==ESoundEncoding24BitPCM) sl@0: buf.Append(KSndEncoding24BitPCM); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: sl@0: // Display the current data format sl@0: buf.Zero(); sl@0: buf.Append(KSndDataFormatConfigTitle); sl@0: if (aConfig.iDataFormat==ESoundDataFormatInterleaved) sl@0: buf.Append(KSndDataFormatInterleaved); sl@0: else if (aConfig.iDataFormat==ESoundDataFormatNonInterleaved) sl@0: buf.Append(KSndDataFormatNonInterleaved); sl@0: buf.Append(_L("\r\n")); sl@0: aTest.Printf(buf); sl@0: } sl@0: sl@0: GLDEF_C void PrintBufferConf(TTestSharedChunkBufConfig& aBufConf,RTest& aTest) sl@0: { sl@0: TBuf<80> buf(0); sl@0: sl@0: aTest.Printf(_L("**Buffer configuration**\r\n")); sl@0: sl@0: // Display the buffer configuration sl@0: buf.Format(_L("NumBufs:%d Size:%xH(%d)\r\n"),aBufConf.iNumBuffers,aBufConf.iBufferSizeInBytes,aBufConf.iBufferSizeInBytes); sl@0: aTest.Printf(buf); sl@0: if (aBufConf.iFlags & KScFlagBufOffsetListInUse) sl@0: { sl@0: buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),aBufConf.iBufferOffsetList[0],aBufConf.iBufferOffsetList[1],aBufConf.iBufferOffsetList[2],aBufConf.iBufferOffsetList[3]); sl@0: aTest.Printf(buf); sl@0: buf.Format(_L(" Offsets[%08xH,%08xH,%08xH,%08xH]\r\n"),aBufConf.iBufferOffsetList[4],aBufConf.iBufferOffsetList[5],aBufConf.iBufferOffsetList[6],aBufConf.iBufferOffsetList[7]); sl@0: aTest.Printf(buf); sl@0: } sl@0: }