os/mm/devsound/sounddevbt/src/SoundDevice/BtDevSoundUtility.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// MMF\SoundDev\src\SoundDevice\BtDevSoundUtility.cpp
sl@0
    15
// File:		BtDevSoundUtility.cpp
sl@0
    16
// Author:		Vasudevan Ramachandraiah
sl@0
    17
// Date:		July 16, 2002
sl@0
    18
// Class that provides API to list ECOM plugin implementation IDs
sl@0
    19
// (c) Nokia Inc.
sl@0
    20
// Revisions:
sl@0
    21
// Date:			Author			Description
sl@0
    22
// 
sl@0
    23
//
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <barsc.h>
sl@0
    27
#include <barsread.h>
sl@0
    28
#include <mmfbase.h>
sl@0
    29
#include <mmfplugininterfaceuids.hrh>
sl@0
    30
#include <mmf/plugin/mmfbthwdeviceimplementationuids.hrh>
sl@0
    31
#include <fixedsequence.rsg>
sl@0
    32
#include "BtDevSoundUtility.h"
sl@0
    33
#include <mmf/common/mmfcontroller.h> //needed for CleanupResetAndDestroyPushL()
sl@0
    34
sl@0
    35
_LIT(KFixedSequenceResourceFile, "Z:\\Resource\\DevSound\\FixedSequence.rsc"); 
sl@0
    36
sl@0
    37
inline TMMFRawPackage::TMMFRawPackage(TInt aDerivedSize)
sl@0
    38
#pragma warning( disable : 4355 )	// 'this' : used in base member initializer list
sl@0
    39
: iThis((TUint8*)this,aDerivedSize,aDerivedSize) 
sl@0
    40
#pragma warning( default : 4355 )
sl@0
    41
	{ 
sl@0
    42
	}
sl@0
    43
sl@0
    44
inline TPtr8& TMMFRawPackage::Package()
sl@0
    45
	{ 
sl@0
    46
	((TMMFRawPackage*)this)->iThis.Set((TUint8*)this,iThis.Length(),iThis.MaxLength()); 
sl@0
    47
	return iThis; 
sl@0
    48
	}
sl@0
    49
sl@0
    50
inline const TPtr8& TMMFRawPackage::Package() const
sl@0
    51
	{ 
sl@0
    52
	((TMMFRawPackage*)this)->iThis.Set((TUint8*)this,iThis.Length(),iThis.MaxLength()); 
sl@0
    53
	return iThis; 
sl@0
    54
	}
sl@0
    55
sl@0
    56
inline void TMMFRawPackage::SetSize(TInt aDerivedSize)
sl@0
    57
	{ 
sl@0
    58
	iThis.Set((TUint8*)this,aDerivedSize,aDerivedSize);
sl@0
    59
	}
sl@0
    60
sl@0
    61
inline TMMFToneFixedSequenceNames::TMMFToneFixedSequenceNames() :
sl@0
    62
TMMFRawPackage(sizeof(TMMFToneFixedSequenceNames)) {}
sl@0
    63
sl@0
    64
#ifdef _UNICODE
sl@0
    65
class TNameBuf : public TBufCBase16
sl@0
    66
#else
sl@0
    67
class TNameBuf : public TBufCBase8
sl@0
    68
#endif
sl@0
    69
	{
sl@0
    70
	friend class HMMFToneFixedSequenceNames;
sl@0
    71
	};
sl@0
    72
sl@0
    73
HMMFToneFixedSequenceNames::HMMFToneFixedSequenceNames()
sl@0
    74
	{
sl@0
    75
	iCount = 0;
sl@0
    76
	}
sl@0
    77
sl@0
    78
HMMFToneFixedSequenceNames* HMMFToneFixedSequenceNames::AddNameL(const TDesC& aName)
sl@0
    79
// Append a copy of the supplied descriptor to the end of the 
sl@0
    80
// current heap cell. This will involve a realloc that will normally
sl@0
    81
// result in the object moving
sl@0
    82
	{
sl@0
    83
	TInt size = Package().Length();
sl@0
    84
	TInt desSize = aName.Size() + sizeof(TInt);
sl@0
    85
	if (desSize&3) 
sl@0
    86
		desSize = ((desSize+4)&(~3)); // Must round up to word boundary to keep aligned
sl@0
    87
	HMMFToneFixedSequenceNames* self = REINTERPRET_CAST(HMMFToneFixedSequenceNames*,User::ReAllocL(STATIC_CAST(TAny*,this),size + desSize));
sl@0
    88
	TUint8* newDesPtr = REINTERPRET_CAST(TUint8*,self) + size;
sl@0
    89
	Mem::FillZ(newDesPtr,desSize);
sl@0
    90
	TNameBuf* newDes = REINTERPRET_CAST(TNameBuf*,newDesPtr);
sl@0
    91
	newDes->Copy(aName,aName.Length());
sl@0
    92
	self->SetSize(size+desSize);
sl@0
    93
	self->iCount++;
sl@0
    94
	return self;
sl@0
    95
	}
sl@0
    96
sl@0
    97
sl@0
    98
/******************************************************************
sl@0
    99
 *				CMMFDevSoundUtility
sl@0
   100
 ******************************************************************/
sl@0
   101
CMMFDevSoundUtility::CMMFDevSoundUtility()
sl@0
   102
	{
sl@0
   103
	// No default implementation
sl@0
   104
	}
sl@0
   105
sl@0
   106
sl@0
   107
CMMFDevSoundUtility::~CMMFDevSoundUtility()
sl@0
   108
	{
sl@0
   109
	delete iInfo;
sl@0
   110
	delete iFixedSequenceNames;
sl@0
   111
	}
sl@0
   112
sl@0
   113
CMMFDevSoundUtility* CMMFDevSoundUtility::NewL()
sl@0
   114
	{
sl@0
   115
	CMMFDevSoundUtility* self = NewLC();
sl@0
   116
	CleanupStack::Pop();
sl@0
   117
	return self;
sl@0
   118
	}
sl@0
   119
sl@0
   120
CMMFDevSoundUtility* CMMFDevSoundUtility::NewLC()
sl@0
   121
	{
sl@0
   122
	CMMFDevSoundUtility* self = new(ELeave) CMMFDevSoundUtility();
sl@0
   123
	CleanupStack::PushL(self);
sl@0
   124
	self->ConstructL();
sl@0
   125
	// Leave it on Cleanupstack
sl@0
   126
	return self;
sl@0
   127
	}
sl@0
   128
sl@0
   129
void CMMFDevSoundUtility::ConstructL()
sl@0
   130
	{
sl@0
   131
	iFixedSequenceNames = new (ELeave) HMMFToneFixedSequenceNames;
sl@0
   132
	}
sl@0
   133
sl@0
   134
void CMMFDevSoundUtility::SeekUsingFourCCL(TUid aInterfaceUid, RImplInfoPtrArray& aPlugInArray, const TFourCC& aSrcDataType, const TFourCC& aDstDataType, const TDesC& aPreferredSupplier)
sl@0
   135
	{
sl@0
   136
sl@0
   137
	// Create a match string using the two FourCC codes.
sl@0
   138
	_LIT8(KEmptyFourCCString, "    ,    ");
sl@0
   139
	TBufC8<9> fourCCString(KEmptyFourCCString);
sl@0
   140
	TPtr8 fourCCPtr = fourCCString.Des();
sl@0
   141
	TPtr8 fourCCPtr1(&fourCCPtr[0], 4);
sl@0
   142
	TPtr8 fourCCPtr2(&fourCCPtr[5], 4 );
sl@0
   143
	aSrcDataType.FourCC(&fourCCPtr1);
sl@0
   144
	aDstDataType.FourCC(&fourCCPtr2);
sl@0
   145
sl@0
   146
	// Create a TEcomResolverParams structure.
sl@0
   147
	TEComResolverParams resolverParams;
sl@0
   148
	resolverParams.SetDataType(fourCCPtr);
sl@0
   149
	resolverParams.SetWildcardMatch(EFalse); 
sl@0
   150
sl@0
   151
	// ListImplementationsL leaves if it cannot find anything so trap the error and ignore it.
sl@0
   152
	TRAPD(err, REComSession::ListImplementationsL(aInterfaceUid, resolverParams, aPlugInArray));
sl@0
   153
sl@0
   154
	User::LeaveIfError(err); //The error above may not be KErrNotFound eg could be KErrNoMemory in which case leave
sl@0
   155
sl@0
   156
	// IF there are no plugins, return failure
sl@0
   157
	if(aPlugInArray.Count() == 0)
sl@0
   158
		User::Leave( KErrNotFound ) ; 
sl@0
   159
sl@0
   160
	// If more than one match.  Narrow the search by preferred supplier
sl@0
   161
	if((aPlugInArray.Count() > 1) && aPreferredSupplier.Length())
sl@0
   162
		SelectByPreference( aPlugInArray, aPreferredSupplier ) ;
sl@0
   163
sl@0
   164
	}
sl@0
   165
sl@0
   166
sl@0
   167
/*
sl@0
   168
 * local function to disable items which do not match the preferred supplier.
sl@0
   169
 * Note that at least one enabled item is returned (if there was an enabled item to begin with) which
sl@0
   170
 * may not match the preferred supplier.
sl@0
   171
 * 
sl@0
   172
 */
sl@0
   173
void CMMFDevSoundUtility::SelectByPreference( RImplInfoPtrArray& aPlugInArray, const TDesC& aPreferredSupplier ) 
sl@0
   174
	{
sl@0
   175
sl@0
   176
	// Use the Disabled flag to eliminated all currently enabled matches that
sl@0
   177
	// do not match the preferred supplier.
sl@0
   178
	TInt firstEnabled = -1 ; // to ensure that we return something valid
sl@0
   179
	TInt matchCount = 0 ;
sl@0
   180
	for ( TInt ii = 0 ; ii < aPlugInArray.Count() ; ii++ )
sl@0
   181
		{
sl@0
   182
		if ( !( aPlugInArray[ii]->Disabled() ) )
sl@0
   183
			{
sl@0
   184
			if ( firstEnabled == -1 )
sl@0
   185
				firstEnabled = ii ;
sl@0
   186
			if ( aPlugInArray[ii]->DisplayName().FindF( aPreferredSupplier ) == KErrNotFound )
sl@0
   187
				aPlugInArray[ii]->SetDisabled( ETrue ) ;
sl@0
   188
			else
sl@0
   189
				matchCount++ ;
sl@0
   190
			}
sl@0
   191
		}
sl@0
   192
sl@0
   193
	// If there are no matches then re-enable the first enabled
sl@0
   194
	if ( matchCount == 0 )
sl@0
   195
		aPlugInArray[firstEnabled]->SetDisabled( EFalse ) ;
sl@0
   196
	else if ( matchCount > 1 )
sl@0
   197
		{
sl@0
   198
		// find the latest version from more than one match
sl@0
   199
		TInt highestVersionIndex = -1 ;
sl@0
   200
		for ( TInt ii = 0 ; ii < aPlugInArray.Count() ; ii++ )
sl@0
   201
			{
sl@0
   202
			if ( !( aPlugInArray[ii]->Disabled() ) )  // only interested in enabled elements
sl@0
   203
				{
sl@0
   204
				if ( highestVersionIndex == -1 )
sl@0
   205
					{ // first match.  Store this.  Keep it enabled
sl@0
   206
					highestVersionIndex = ii ;
sl@0
   207
					}
sl@0
   208
				else if ( aPlugInArray[ii]->Version() > aPlugInArray[highestVersionIndex]->Version() )
sl@0
   209
					{ // a new leader.  Disable the previous leader.  Keep this one.
sl@0
   210
					aPlugInArray[highestVersionIndex]->SetDisabled( ETrue ) ;
sl@0
   211
					highestVersionIndex = ii ;
sl@0
   212
					}
sl@0
   213
				else  // we already have a higher version.
sl@0
   214
					aPlugInArray[ii]->SetDisabled( ETrue ) ;
sl@0
   215
				}
sl@0
   216
			}
sl@0
   217
		}
sl@0
   218
	}
sl@0
   219
sl@0
   220
sl@0
   221
/*
sl@0
   222
 *  SeekHwDevicePluginsL
sl@0
   223
 *  This method looks for hwDevicePlugins that support the state given in aState which
sl@0
   224
 *  must be either EMMFStatePlaying or EMMFStateRecording
sl@0
   225
 *  For each HwDevice plugin found the datatype as indicated by its fourCC code
sl@0
   226
 *  from the default_data field in the resource file is added to the array of aSupportedDataTypes
sl@0
   227
 *
sl@0
   228
 *  @internalComponent
sl@0
   229
 *
sl@0
   230
 *	@param	"RArray<TFourCC>& aSupportedDataTypes"
sl@0
   231
 *  an array of fourCC codes that has a fourCC code added to for each hardware device found
sl@0
   232
 *
sl@0
   233
 *	@param  "TMMFState aState"
sl@0
   234
 *  must be set to EMMFStatePlaying if seeking HwDevice plugins that support play and
sl@0
   235
 *  EMMFStateRecording if seeking HwDevice plugins that support record
sl@0
   236
 *	
sl@0
   237
 *  @leave KErrArgument if aState is not EMMFStatePlaying or EMMFStateRecording else leaves
sl@0
   238
 *  with standard symbian OS error code
sl@0
   239
 */
sl@0
   240
void CMMFDevSoundUtility::SeekHwDevicePluginsL(RArray<TFourCC>& aSupportedDataTypes, TMMFState aState)
sl@0
   241
	{	
sl@0
   242
	//check argument precondition for aState
sl@0
   243
	if ((aState != EMMFStatePlaying) && (aState != EMMFStateRecording))
sl@0
   244
		User::Leave(KErrArgument);
sl@0
   245
sl@0
   246
	aSupportedDataTypes.Reset(); //clear any existing data in aSupportedDataTypes array
sl@0
   247
sl@0
   248
	RImplInfoPtrArray plugInArray ; // Array to return hw device plugin resource info(place on cleanupstack _after_ ListImplementationsL() )
sl@0
   249
	TUid KUidMmfHWPluginInterfaceCodec = {KMmfUidBtPluginInterfaceHwDevice};
sl@0
   250
sl@0
   251
	// ListImplementationsL leaves if it cannot find anything so trap the error
sl@0
   252
	TRAPD( err, REComSession::ListImplementationsL(KUidMmfHWPluginInterfaceCodec, plugInArray ) ) ;
sl@0
   253
	CleanupResetAndDestroyPushL(plugInArray);
sl@0
   254
sl@0
   255
	TUint numberOfHwDevicePlugins = plugInArray.Count();
sl@0
   256
sl@0
   257
	//if no errors and have hwdevice plugin resource entries then scan entries
sl@0
   258
	//matching on a datatype of pcm16 as the destination datatype for play and the 
sl@0
   259
	//source datatype for record
sl@0
   260
	//if a match is found and isn't already in list of supported data types
sl@0
   261
	//then add it to the list
sl@0
   262
	if ((err == KErrNone)&&(numberOfHwDevicePlugins))
sl@0
   263
		{					
sl@0
   264
		CImplementationInformation* hwDeviceResourceEntry = NULL;
sl@0
   265
		_LIT8(KPCM16FourCCString, " P16");
sl@0
   266
		TBufC8<KFourCCLength> fourCCStringPCM16(KPCM16FourCCString);
sl@0
   267
		TPtr8 fourCCPtrPCM16 = fourCCStringPCM16.Des();
sl@0
   268
		TUint entryNumber = 0;
sl@0
   269
sl@0
   270
		//check each resource entry for dst 4CC = P16 for play and src 4CC = P16 for record
sl@0
   271
		for (TUint hwDeviceEntry = 0; hwDeviceEntry < numberOfHwDevicePlugins; hwDeviceEntry++)
sl@0
   272
			{
sl@0
   273
			hwDeviceResourceEntry = plugInArray[hwDeviceEntry];
sl@0
   274
			if (IsDataTypeMatch(hwDeviceResourceEntry, fourCCPtrPCM16, aState))
sl@0
   275
				{//resource entry data field has dest/src datatype ' P16' ie pcm16 for play/record
sl@0
   276
				TPtrC8 fourCCPtr(0,0);
sl@0
   277
				if (aState == EMMFStatePlaying)//then datatype supported 4CC is left 4 chars
sl@0
   278
					fourCCPtr.Set(hwDeviceResourceEntry->DataType().Left(KFourCCLength));
sl@0
   279
				else if (aState == EMMFStateRecording) //then datatype supported 4CC is right 4 chars
sl@0
   280
					fourCCPtr.Set(hwDeviceResourceEntry->DataType().Right(KFourCCLength));
sl@0
   281
				TFourCC fourCCEntry(fourCCPtr);
sl@0
   282
				//need to check if entry already exists to prevent duplicate entries
sl@0
   283
				TBool alreadyExists = EFalse;
sl@0
   284
				for (TUint fourCCEntryNumber = 0; fourCCEntryNumber < entryNumber; fourCCEntryNumber++)
sl@0
   285
					{
sl@0
   286
					if (aSupportedDataTypes[fourCCEntryNumber]==fourCCEntry)
sl@0
   287
						{
sl@0
   288
						alreadyExists = ETrue;//we already have this 4CC in the supported data types
sl@0
   289
						break;
sl@0
   290
						}
sl@0
   291
					}
sl@0
   292
				if (!alreadyExists)
sl@0
   293
					{
sl@0
   294
					err = aSupportedDataTypes.Append(fourCCEntry);
sl@0
   295
					if (err)
sl@0
   296
						{//note we don't destroy array because we don't own it
sl@0
   297
						//but we do reset it as it is incomplete
sl@0
   298
						aSupportedDataTypes.Reset();
sl@0
   299
						User::Leave(err);
sl@0
   300
						}
sl@0
   301
					}
sl@0
   302
				}//if (IsDataTypeMatch(hwDeviceResourceEntry, fourCCPtrPCM16, aState))
sl@0
   303
			}//for (TUint hwDeviceEntry = 0; hwDeviceEntry < numberOfHwDevicePlugins; hwDeviceEntry++)
sl@0
   304
		}//if ((err == KErrNone)&&(numberOfHwDevicePlugins))
sl@0
   305
	else
sl@0
   306
		{//if an error occured and not KErrNotFound then must be a 'real' error eg KErrNoMemory
sl@0
   307
		if ((err != KErrNotFound)&&(err != KErrNone))
sl@0
   308
			User::Leave(err);
sl@0
   309
		}
sl@0
   310
	CleanupStack::PopAndDestroy(&plugInArray);
sl@0
   311
	}
sl@0
   312
sl@0
   313
sl@0
   314
/*
sl@0
   315
 *	IsDataTypeMatch
sl@0
   316
 *  This method takes a given resource entry from a hardware device and determines 
sl@0
   317
 *  whether the hwdevice plugin is a data type match for playing or recording
sl@0
   318
 *  depending on the setting of aState
sl@0
   319
 *  The method matchs the default_data field from the hw device resource entry matching
sl@0
   320
 *  it with the aHwMatchFourCC code.
sl@0
   321
 *
sl@0
   322
 *  @internalComponent
sl@0
   323
 *
sl@0
   324
 *	@param	"CImplementationInformation aHwDeviceResourceEntry"
sl@0
   325
 *  the hw device resource entry that is to be checked 
sl@0
   326
 *  whether it can be used to play or record
sl@0
   327
 *
sl@0
   328
 *	@param  "TDesC8& aHwMatchFourCC
sl@0
   329
 *	the data type fourCC code to match to that the hardware device that must convert to for
sl@0
   330
 *	playing and convert from for recording - for the reference DevSound this is always ' P16' ie pcm16
sl@0
   331
 *
sl@0
   332
 *  @param "TMMFState aState"
sl@0
   333
 *  this determines whether the match is for playing or recording and should take 
sl@0
   334
 *  either the values EMMFStatePlaying or EMMFStateRecording
sl@0
   335
 *
sl@0
   336
 *  @return ETrue if a match for play or record else EFalse
sl@0
   337
 */
sl@0
   338
TBool CMMFDevSoundUtility::IsDataTypeMatch(CImplementationInformation* aHwDeviceResourceEntry,const TDesC8& aHwMatchFourCC, TMMFState aState)
sl@0
   339
	{
sl@0
   340
	TBool match = EFalse;
sl@0
   341
	if (aState == EMMFStatePlaying)
sl@0
   342
		{//play need to match with the right four characters
sl@0
   343
		match =  (!(aHwMatchFourCC.Match(aHwDeviceResourceEntry->DataType().Right(KFourCCLength))==KErrNotFound));
sl@0
   344
		}
sl@0
   345
	else if (aState == EMMFStateRecording)
sl@0
   346
		{//record need to match with the left four characters
sl@0
   347
		match = (!(aHwMatchFourCC.Match(aHwDeviceResourceEntry->DataType().Left(KFourCCLength))==KErrNotFound));
sl@0
   348
		}
sl@0
   349
	return match;
sl@0
   350
	}
sl@0
   351
sl@0
   352
sl@0
   353
/**
sl@0
   354
 *	Populate fixed sequences
sl@0
   355
 *
sl@0
   356
 */
sl@0
   357
void CMMFDevSoundUtility::InitializeFixedSequenceL(CPtrC8Array** aFixedSequences)
sl@0
   358
	{
sl@0
   359
sl@0
   360
	RFs fsSession;
sl@0
   361
	User::LeaveIfError(fsSession.Connect());
sl@0
   362
	CleanupClosePushL(fsSession);
sl@0
   363
sl@0
   364
	// Open the resource file
sl@0
   365
	RResourceFile resourceFile;
sl@0
   366
	resourceFile.OpenL(fsSession, KFixedSequenceResourceFile);
sl@0
   367
	CleanupClosePushL(resourceFile);
sl@0
   368
sl@0
   369
	// Allocate buffer to hold resource data in binary format
sl@0
   370
	iInfo = resourceFile.AllocReadL(FIXED_TONE_SEQUENCE);
sl@0
   371
sl@0
   372
	TResourceReader reader;
sl@0
   373
	reader.SetBuffer(iInfo);
sl@0
   374
sl@0
   375
	// Create array to hold fixed sequences data
sl@0
   376
	CPtrC8Array* tempSequences = new(ELeave) CPtrC8Array(8); //  granularity
sl@0
   377
	CleanupStack::PushL(tempSequences);
sl@0
   378
sl@0
   379
	// First word gives number of entries
sl@0
   380
	TInt numberOfEntries = reader.ReadUint16(); 
sl@0
   381
	ASSERT(!(numberOfEntries&1)); // Should have atleast one entry
sl@0
   382
sl@0
   383
	// There must be an even number entries as each sequence structure
sl@0
   384
	// is made of a name string and a data string (SEQUENCE_NAME and SEQUENCE_DATA)
sl@0
   385
sl@0
   386
	HMMFToneFixedSequenceNames* names = new (ELeave) HMMFToneFixedSequenceNames;
sl@0
   387
	CleanupStack::PushL(names);
sl@0
   388
	for (TInt i=0;i<numberOfEntries;i+=2)
sl@0
   389
		{
sl@0
   390
		// Copy name from resource array to returnable array
sl@0
   391
		HMMFToneFixedSequenceNames* newNames = names->AddNameL(reader.ReadTPtrC());
sl@0
   392
		if (names != newNames)
sl@0
   393
			{ // May have moved so fixup cleanupstack reference
sl@0
   394
			CleanupStack::Pop();
sl@0
   395
			names = newNames;
sl@0
   396
			CleanupStack::PushL(names);
sl@0
   397
			}
sl@0
   398
		TInt len = reader.ReadUint16();
sl@0
   399
		TPtrC8 tempTPtrC8(REINTERPRET_CAST(const TUint8*,reader.Ptr()),len<<1);
sl@0
   400
		tempSequences->AppendL(tempTPtrC8);
sl@0
   401
		reader.Advance(len<<1);
sl@0
   402
		}
sl@0
   403
	CleanupStack::Pop(); // names
sl@0
   404
sl@0
   405
	// Delete the old fixed sequence names
sl@0
   406
	delete iFixedSequenceNames;
sl@0
   407
	iFixedSequenceNames = NULL;
sl@0
   408
	iFixedSequenceNames = names;
sl@0
   409
sl@0
   410
	*aFixedSequences = tempSequences;
sl@0
   411
	CleanupStack::Pop(tempSequences);
sl@0
   412
	CleanupStack::PopAndDestroy(2);	// resourceFile, fsSession
sl@0
   413
	}
sl@0
   414
sl@0
   415
TBool CMMFDevSoundUtility::RecognizeSequence(const TDesC8& aData)
sl@0
   416
	{
sl@0
   417
	// Reference plug-in only supports its own sequence format
sl@0
   418
	_LIT8(KSequenceSignature,"SQNC");
sl@0
   419
	if (aData.Length() > 4)
sl@0
   420
		{
sl@0
   421
		if (aData.Left(4) == KSequenceSignature)
sl@0
   422
			return ETrue;
sl@0
   423
		}
sl@0
   424
	// Didn't recognise
sl@0
   425
	return EFalse;
sl@0
   426
	}
sl@0
   427
sl@0
   428
const TDesC& CMMFDevSoundUtility::FixedSequenceName(TInt aSequenceNumber)
sl@0
   429
	{
sl@0
   430
	ASSERT(iFixedSequenceNames); // Defect if this not true when previous was true
sl@0
   431
	ASSERT((aSequenceNumber>=0)&&(aSequenceNumber<iFixedSequenceNames->iCount));
sl@0
   432
sl@0
   433
	// Ptr to first descriptor
sl@0
   434
	TUint8* ptr = REINTERPRET_CAST(TUint8*,&(iFixedSequenceNames->iCount))+sizeof(TInt);
sl@0
   435
	TDesC* desPtr = REINTERPRET_CAST(TDesC*,ptr); // First des
sl@0
   436
	while (aSequenceNumber--)
sl@0
   437
		{
sl@0
   438
		TInt size = desPtr->Size();
sl@0
   439
		if (size&3)
sl@0
   440
			size = ((size+4)&(~3));
sl@0
   441
		ptr += sizeof(TInt) + size;
sl@0
   442
		desPtr = REINTERPRET_CAST(TDesC*,ptr); // Next des
sl@0
   443
		}
sl@0
   444
	return *desPtr;
sl@0
   445
	}