os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/soundsc_tx.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) 2006-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 the License "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
// template\template_variant\specific\soundsc_tx.cpp
sl@0
    15
// Implementation of the Template playback shared chunk sound physical device driver (PDD).
sl@0
    16
// This file is part of the Template Base port
sl@0
    17
// 
sl@0
    18
//
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include "soundsc_plat.h"
sl@0
    25
sl@0
    26
// TO DO: (mandatory)
sl@0
    27
// Declare a name for this driver. The format of this name should be
sl@0
    28
// "SoundSc.xxxx" where xxxx is the variant name.
sl@0
    29
_LIT(KSoundScPddName,"SoundSc.Template");
sl@0
    30
sl@0
    31
// Definitions for the kernel thread created for this sound driver.
sl@0
    32
_LIT(KSoundScDriverThreadName,"SoundDriverThread");
sl@0
    33
const TInt KSoundScDriverThreadPriority=26;				// One less than DFC thread 0
sl@0
    34
sl@0
    35
/**
sl@0
    36
Define a function at ordinal 0 which returns a new instance of a DPhysicalDevice-derived factory class.
sl@0
    37
*/
sl@0
    38
DECLARE_STANDARD_PDD()
sl@0
    39
	{
sl@0
    40
	return new DTemplateSoundScPddFactory;
sl@0
    41
	}
sl@0
    42
sl@0
    43
/**
sl@0
    44
Constructor for the shared chunk sound PDD factory class.
sl@0
    45
*/
sl@0
    46
DTemplateSoundScPddFactory::DTemplateSoundScPddFactory()
sl@0
    47
	{	
sl@0
    48
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::DTemplateSoundScPddFactory"));
sl@0
    49
sl@0
    50
//	iDfcQ=NULL;
sl@0
    51
	
sl@0
    52
	// Support units KSoundScTxUnit0 & KSoundScRxUnit0.
sl@0
    53
    iUnitsMask=(1<<KSoundScRxUnit0)|(1<<KSoundScTxUnit0);
sl@0
    54
sl@0
    55
    // Set version number for this device.
sl@0
    56
	iVersion=RSoundSc::VersionRequired();
sl@0
    57
	}
sl@0
    58
sl@0
    59
/**
sl@0
    60
Destructor for the shared chunk sound PDD factory class.
sl@0
    61
*/
sl@0
    62
DTemplateSoundScPddFactory::~DTemplateSoundScPddFactory()
sl@0
    63
	{
sl@0
    64
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::~DTemplateSoundScPddFactory"));
sl@0
    65
	
sl@0
    66
	// Destroy the kernel thread.
sl@0
    67
	if (iDfcQ)
sl@0
    68
		iDfcQ->Destroy();
sl@0
    69
	}
sl@0
    70
	
sl@0
    71
/**
sl@0
    72
Second stage constructor for the shared chunk sound PDD factory class.
sl@0
    73
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
    74
*/
sl@0
    75
TInt DTemplateSoundScPddFactory::Install()
sl@0
    76
	{
sl@0
    77
	TInt r=KErrNone;
sl@0
    78
	if (iDfcQ==NULL)
sl@0
    79
		{
sl@0
    80
		// Create a new sound driver DFC queue (and associated kernel thread). 
sl@0
    81
		r=Kern::DynamicDfcQCreate(iDfcQ,KSoundScDriverThreadPriority,KSoundScDriverThreadName);
sl@0
    82
		}
sl@0
    83
	
sl@0
    84
	if (r==KErrNone)
sl@0
    85
		{
sl@0
    86
		r=SetName(&KSoundScPddName); 				// Set the name of the driver object
sl@0
    87
		}
sl@0
    88
	
sl@0
    89
	__KTRACE_SND(Kern::Printf("<DTemplateSoundScPddFactory::Install - %d",r));
sl@0
    90
	return(r);
sl@0
    91
	}
sl@0
    92
	
sl@0
    93
/**
sl@0
    94
Returns the PDD's capabilities. This is not used by the Symbian OS device driver framework
sl@0
    95
or by the LDD.
sl@0
    96
@param aDes A descriptor to write capabilities information into
sl@0
    97
*/
sl@0
    98
void DTemplateSoundScPddFactory::GetCaps(TDes8& /*aDes*/) const
sl@0
    99
	{}
sl@0
   100
sl@0
   101
/**
sl@0
   102
Called by the kernel's device driver framework to check if this PDD is suitable for use
sl@0
   103
with a logical channel.
sl@0
   104
This is called in the context of the client thread which requested the creation of a logical
sl@0
   105
channel - through a call to RBusLogicalChannel::DoCreate().
sl@0
   106
The thread is in a critical section.
sl@0
   107
@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
sl@0
   108
@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate() - not used.
sl@0
   109
@param aVer The version number of the logical channel which will use this physical channel. 
sl@0
   110
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   111
*/
sl@0
   112
TInt DTemplateSoundScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
sl@0
   113
	{
sl@0
   114
	// Check that the version specified is compatible.
sl@0
   115
	if (!Kern::QueryVersionSupported(RSoundSc::VersionRequired(),aVer))
sl@0
   116
		return(KErrNotSupported);
sl@0
   117
	
sl@0
   118
	// Check the unit number is compatible
sl@0
   119
	if (aUnit!=KSoundScTxUnit0 && aUnit!=KSoundScRxUnit0)
sl@0
   120
		return(KErrNotSupported);
sl@0
   121
		
sl@0
   122
	return(KErrNone);
sl@0
   123
	}
sl@0
   124
sl@0
   125
/**
sl@0
   126
Called by the kernel's device driver framework to create a physical channel object.
sl@0
   127
This is called in the context of the client thread which requested the creation of a logical
sl@0
   128
channel - through a call to RBusLogicalChannel::DoCreate().
sl@0
   129
The thread is in a critical section.
sl@0
   130
@param aChannel Set by this function to point to the created physical channel object.
sl@0
   131
@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
sl@0
   132
@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate().
sl@0
   133
@param aVer The version number of the logical channel which will use this physical channel. 
sl@0
   134
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   135
*/
sl@0
   136
TInt DTemplateSoundScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
sl@0
   137
	{
sl@0
   138
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::Create"));
sl@0
   139
sl@0
   140
	// Create the appropriate PDD channel object.
sl@0
   141
	TInt r=KErrNoMemory;
sl@0
   142
	if (aUnit==KSoundScRxUnit0)
sl@0
   143
		{
sl@0
   144
		// Create a record PDD channel object
sl@0
   145
		DTemplateSoundScRxPdd* pD=new DTemplateSoundScRxPdd;
sl@0
   146
		aChannel=pD;
sl@0
   147
		if (pD)
sl@0
   148
			{
sl@0
   149
			pD->iPhysicalDevice=this;
sl@0
   150
			r=pD->DoCreate();
sl@0
   151
			}
sl@0
   152
		}
sl@0
   153
		
sl@0
   154
	else
sl@0
   155
		{
sl@0
   156
		// Create a playback PDD channel object
sl@0
   157
		DTemplateSoundScTxPdd* pD=new DTemplateSoundScTxPdd;
sl@0
   158
		aChannel=pD;
sl@0
   159
		if (pD)
sl@0
   160
			{
sl@0
   161
			pD->iPhysicalDevice=this;
sl@0
   162
			r=pD->DoCreate();
sl@0
   163
			}
sl@0
   164
		}
sl@0
   165
	return(r);
sl@0
   166
	}
sl@0
   167
sl@0
   168
sl@0
   169
/**
sl@0
   170
Constructor for the Template playback shared chunk sound driver physical device driver (PDD).
sl@0
   171
*/
sl@0
   172
DTemplateSoundScTxPdd::DTemplateSoundScTxPdd()
sl@0
   173
	{		
sl@0
   174
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::DTemplateSoundScTxPdd"));
sl@0
   175
	
sl@0
   176
//	iDmaChan=NULL;
sl@0
   177
//	iPendingPlay=0;
sl@0
   178
//	iFlag=0;
sl@0
   179
	}
sl@0
   180
	
sl@0
   181
/**
sl@0
   182
Destructor for the Template playback shared chunk sound driver physical device driver (PDD).
sl@0
   183
*/
sl@0
   184
DTemplateSoundScTxPdd::~DTemplateSoundScTxPdd()
sl@0
   185
	{
sl@0
   186
	// Delete the DMA request objects
sl@0
   187
	for (TInt i=0; i<KTemplateMaxTxDmaRequests; i++)
sl@0
   188
		{
sl@0
   189
		if (iDmaRequest[i])
sl@0
   190
			delete iDmaRequest[i];
sl@0
   191
		}
sl@0
   192
	
sl@0
   193
	// Close the DMA channel.
sl@0
   194
	if (iDmaChannel)
sl@0
   195
		iDmaChannel->Close();
sl@0
   196
	}
sl@0
   197
	
sl@0
   198
/**
sl@0
   199
Second stage constructor for the Template playback shared chunk sound driver physical device driver (PDD).
sl@0
   200
Note that this constructor is called before the second stage constructor for the LDD so it is not
sl@0
   201
possible to call methods on the LDD here.
sl@0
   202
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   203
*/	
sl@0
   204
TInt DTemplateSoundScTxPdd::DoCreate()
sl@0
   205
	{
sl@0
   206
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::DoCreate"));
sl@0
   207
		
sl@0
   208
	SetCaps();								// Setup the capabilities of this device.
sl@0
   209
	
sl@0
   210
	// Setup a DMA channel for playback
sl@0
   211
	// TO DO: (mandatory)
sl@0
   212
	// Setup the DMA channel information for this play device.
sl@0
   213
	TDmaChannel::SCreateInfo info;
sl@0
   214
//	info.iCookie=???
sl@0
   215
	info.iDfcQ=DfcQ(KSoundScTxUnit0);
sl@0
   216
//	info.iDfcPriority=???
sl@0
   217
	info.iDesCount=KTemplateMaxTxDmaRequests;
sl@0
   218
	// coverity[uninit_use_in_call]
sl@0
   219
	// The values info.iCookie and info.iDfcPriority are to be initialized when implemented
sl@0
   220
	TInt r=TDmaChannel::Open(info,iDmaChannel);
sl@0
   221
	
sl@0
   222
	// Create the DMA request objects for use with the DMA channel.
sl@0
   223
	if (r==KErrNone)
sl@0
   224
		{
sl@0
   225
		for (TInt i=0; i<KTemplateMaxTxDmaRequests; i++)
sl@0
   226
			{
sl@0
   227
			iDmaRequest[i] = new DTemplateSoundScTxDmaRequest(*iDmaChannel,this);
sl@0
   228
			if (iDmaRequest[i] == NULL)
sl@0
   229
				{
sl@0
   230
				r=KErrNoMemory;
sl@0
   231
				break;
sl@0
   232
				}
sl@0
   233
			}
sl@0
   234
		}
sl@0
   235
	
sl@0
   236
	__KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::DoCreate - %d",r));
sl@0
   237
	return(r);
sl@0
   238
	}
sl@0
   239
	
sl@0
   240
/**
sl@0
   241
Return the DFC queue to be used by this playback device.
sl@0
   242
@return The DFC queue to use.
sl@0
   243
*/	
sl@0
   244
TDfcQue* DTemplateSoundScTxPdd::DfcQ(TInt /*aUnit*/)
sl@0
   245
	{
sl@0
   246
	return(iPhysicalDevice->iDfcQ);
sl@0
   247
	}
sl@0
   248
		
sl@0
   249
/** 
sl@0
   250
Called from the LDD to return the shared chunk create information to be used by this play device.
sl@0
   251
@param aChunkCreateInfo A chunk create info. object to be to be filled with the settings
sl@0
   252
						required for this device.
sl@0
   253
*/		
sl@0
   254
void DTemplateSoundScTxPdd::GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)
sl@0
   255
	{
sl@0
   256
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::GetChunkCreateInfo"));
sl@0
   257
sl@0
   258
	// TO DO: (mandatory)
sl@0
   259
	// Setup the shared chunk create information in aChunkCreateInfo for this play device.
sl@0
   260
	aChunkCreateInfo.iType=TChunkCreateInfo::ESharedKernelMultiple;
sl@0
   261
//	aChunkCreateInfo.iMapAttr=???
sl@0
   262
	aChunkCreateInfo.iOwnsMemory=ETrue; 				// Using RAM pages.
sl@0
   263
	aChunkCreateInfo.iDestroyedDfc=NULL; 				// No chunk destroy DFC.
sl@0
   264
	}
sl@0
   265
sl@0
   266
/**
sl@0
   267
Called from the LDD to return the capabilities of this device.
sl@0
   268
@param aCapsBuf A packaged TSoundFormatsSupportedV02 object to be filled with the play
sl@0
   269
				capabilities of this device. This descriptor is in kernel memory and can be accessed directly.
sl@0
   270
@see TSoundFormatsSupportedV02.
sl@0
   271
*/
sl@0
   272
void DTemplateSoundScTxPdd::Caps(TDes8& aCapsBuf) const
sl@0
   273
	{
sl@0
   274
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::Caps"));
sl@0
   275
	
sl@0
   276
	// Copy iCaps back.
sl@0
   277
	TPtrC8 ptr((const TUint8*)&iCaps,sizeof(iCaps));
sl@0
   278
	aCapsBuf.FillZ(aCapsBuf.MaxLength());
sl@0
   279
	aCapsBuf=ptr.Left(Min(ptr.Length(),aCapsBuf.MaxLength()));		
sl@0
   280
	}
sl@0
   281
sl@0
   282
/**
sl@0
   283
Called from the LDD to return the maximum transfer length in bytes that this device can support in a single data transfer.
sl@0
   284
@return The maximum transfer length in bytes.
sl@0
   285
*/
sl@0
   286
TInt DTemplateSoundScTxPdd::MaxTransferLen() const
sl@0
   287
	{
sl@0
   288
	return(KTemplateMaxTxDmaTransferLen);
sl@0
   289
	}
sl@0
   290
sl@0
   291
/**
sl@0
   292
Called from the LDD to configure or reconfigure the device using the the configuration supplied.
sl@0
   293
@param aConfigBuf A packaged TCurrentSoundFormatV02 object which contains the new configuration settings.
sl@0
   294
				  This descriptor is in kernel memory and can be accessed directly.
sl@0
   295
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   296
@see TCurrentSoundFormatV02.
sl@0
   297
*/	
sl@0
   298
TInt DTemplateSoundScTxPdd::SetConfig(const TDesC8& aConfigBuf)
sl@0
   299
	{
sl@0
   300
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetConfig"));
sl@0
   301
	
sl@0
   302
	// Read the new configuration from the LDD.
sl@0
   303
	TCurrentSoundFormatV02 config;
sl@0
   304
	TPtr8 ptr((TUint8*)&config,sizeof(config));
sl@0
   305
	Kern::InfoCopy(ptr,aConfigBuf);
sl@0
   306
	
sl@0
   307
	// TO DO: (mandatory)
sl@0
   308
	// Apply the specified audio configuration to the audio device.
sl@0
   309
	TInt r=KErrNone;
sl@0
   310
	
sl@0
   311
	__KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::SetConfig - %d",r));
sl@0
   312
	return(r);
sl@0
   313
	}
sl@0
   314
	
sl@0
   315
/**
sl@0
   316
Called from the LDD to set the play volume.
sl@0
   317
@param aVolume The play volume to be set - a value in the range 0 to 255. The value 255 equates
sl@0
   318
	to the maximum volume and each value below this equates to a 0.5dB step below it.
sl@0
   319
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   320
*/
sl@0
   321
TInt DTemplateSoundScTxPdd::SetVolume(TInt aVolume)
sl@0
   322
	{
sl@0
   323
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetVolume"));
sl@0
   324
    
sl@0
   325
    // TO DO: (mandatory)
sl@0
   326
	// Set the specified play volume on the audio device.
sl@0
   327
	TInt r=KErrNone;
sl@0
   328
    
sl@0
   329
	return(r);
sl@0
   330
	}
sl@0
   331
		
sl@0
   332
/**
sl@0
   333
Called from the LDD to prepare the audio device for playback.
sl@0
   334
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   335
*/
sl@0
   336
TInt DTemplateSoundScTxPdd::StartTransfer()
sl@0
   337
	{
sl@0
   338
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::StartTransfer"));
sl@0
   339
	
sl@0
   340
	// TO DO: (mandatory)
sl@0
   341
	// Prepare the audio device for playback.
sl@0
   342
	TInt r=KErrNone;
sl@0
   343
    
sl@0
   344
    __KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::StartTransfer - %d",r));
sl@0
   345
    return(r);
sl@0
   346
	}
sl@0
   347
sl@0
   348
/**
sl@0
   349
Called from the LDD to initiate the playback of a portion of data to the audio device.
sl@0
   350
When the transfer is complete, the PDD signals this event using the LDD function PlayCallback().
sl@0
   351
@param aTransferID A value assigned by the LDD to allow it to uniquely identify a particular transfer fragment.
sl@0
   352
@param aLinAddr The linear address within the shared chunk of the start of the data to be played.
sl@0
   353
@param aPhysAddr The physical address within the shared chunk of the start of the data to be played.
sl@0
   354
@param aNumBytes The number of bytes to be played. 
sl@0
   355
@return KErrNone if the transfer has been initiated successfully;
sl@0
   356
  		KErrNotReady if the device is unable to accept the transfer for the moment;
sl@0
   357
		otherwise one of the other system-wide error codes.
sl@0
   358
*/
sl@0
   359
TInt DTemplateSoundScTxPdd::TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr /*aPhysAddr*/,TInt aNumBytes)
sl@0
   360
	{
sl@0
   361
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::TransferData(ID:%xH,Addr:%xH,Len:%d)",aLinAddr,aNumBytes));
sl@0
   362
		
sl@0
   363
	TInt r=KErrNone;
sl@0
   364
	
sl@0
   365
	// Check that we can accept the request
sl@0
   366
	if (iPendingPlay>=KTemplateMaxTxDmaRequests)
sl@0
   367
		r=KErrNotReady;
sl@0
   368
	else
sl@0
   369
		{
sl@0
   370
		// Start a DMA transfer.
sl@0
   371
		iDmaRequest[iFlag]->iTransferID=aTransferID;
sl@0
   372
		iDmaRequest[iFlag]->iTransferSize=aNumBytes;
sl@0
   373
		// TO DO: (mandatory)
sl@0
   374
		// Supply the DMA destination information.
sl@0
   375
		TUint32 dest=0; // ???
sl@0
   376
		r=iDmaRequest[iFlag]->Fragment(aLinAddr,dest,aNumBytes,KDmaMemSrc|KDmaIncSrc,0);
sl@0
   377
		if (r==KErrNone)
sl@0
   378
			{
sl@0
   379
			iDmaRequest[iFlag]->Queue();
sl@0
   380
			iPendingPlay++;
sl@0
   381
			if ((++iFlag)>=KTemplateMaxTxDmaRequests)
sl@0
   382
				iFlag=0;
sl@0
   383
			
sl@0
   384
			// TO DO: (mandatory)
sl@0
   385
			// Start the audio device transfering data.
sl@0
   386
			}
sl@0
   387
		}
sl@0
   388
											
sl@0
   389
	__KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::TransferData - %d",r));	
sl@0
   390
	return(r);
sl@0
   391
	}
sl@0
   392
sl@0
   393
/**
sl@0
   394
Called from the LDD to terminate the playback of a data to the device and to release any resources necessary for playback.
sl@0
   395
This is called soon after the last pending play request from the client has been completed. Once this function had been
sl@0
   396
called, the LDD will not issue any further TransferData() commands without first issueing a StartTransfer() command. 
sl@0
   397
*/
sl@0
   398
void DTemplateSoundScTxPdd::StopTransfer()
sl@0
   399
	{
sl@0
   400
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::StopTransfer"));
sl@0
   401
sl@0
   402
    // Stop the DMA channel.
sl@0
   403
    iDmaChannel->CancelAll();
sl@0
   404
	iFlag=0;
sl@0
   405
    iPendingPlay=0;
sl@0
   406
    
sl@0
   407
    // TO DO: (mandatory)
sl@0
   408
	// Stop the audio device transfering data.
sl@0
   409
	}
sl@0
   410
sl@0
   411
/**
sl@0
   412
Called from the LDD to halt the playback of data to the sound device but not to release any resources necessary for
sl@0
   413
playback.
sl@0
   414
If possible, any active transfer should be suspended in such a way that it can be resumed later - starting from next
sl@0
   415
sample following the one last played.
sl@0
   416
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   417
*/
sl@0
   418
TInt DTemplateSoundScTxPdd::PauseTransfer()
sl@0
   419
	{
sl@0
   420
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::PauseTransfer"));
sl@0
   421
	
sl@0
   422
	// TO DO: (mandatory)
sl@0
   423
	// Halt playback on the audio device.
sl@0
   424
	TInt r=KErrNone;
sl@0
   425
    
sl@0
   426
	return(r);
sl@0
   427
	}
sl@0
   428
	
sl@0
   429
/**
sl@0
   430
Called from the LDD to resume the playback of data to the sound device following a request to halt playback.
sl@0
   431
If possible, any transfer which was active when the device was halted should be resumed - starting from next sample
sl@0
   432
following the one last played. Once complete, it should be reported using PlayCallback()
sl@0
   433
as normal. 
sl@0
   434
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   435
*/
sl@0
   436
TInt DTemplateSoundScTxPdd::ResumeTransfer()
sl@0
   437
	{
sl@0
   438
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::ResumeTransfer"));
sl@0
   439
	
sl@0
   440
	// TO DO: (mandatory)
sl@0
   441
	// Resume playback on the audio device.
sl@0
   442
	TInt r=KErrNone;
sl@0
   443
			
sl@0
   444
	return(r);
sl@0
   445
	}
sl@0
   446
sl@0
   447
/**
sl@0
   448
Called from the LDD to power up the sound device when the channel is first opened and if ever the phone is brought out
sl@0
   449
of standby mode.
sl@0
   450
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   451
*/
sl@0
   452
TInt DTemplateSoundScTxPdd::PowerUp()
sl@0
   453
	{
sl@0
   454
	// TO DO: (mandatory)
sl@0
   455
	// Power up the audio device.
sl@0
   456
	
sl@0
   457
	return(KErrNone);
sl@0
   458
	}
sl@0
   459
sl@0
   460
/**
sl@0
   461
Called from the LDD to power down the sound device when the channel is closed and just before the phone powers down when
sl@0
   462
being turned off or going into standby.
sl@0
   463
*/
sl@0
   464
void DTemplateSoundScTxPdd::PowerDown()
sl@0
   465
	{
sl@0
   466
	// TO DO: (mandatory)
sl@0
   467
	// Power down the audio device.
sl@0
   468
	}
sl@0
   469
	
sl@0
   470
/**
sl@0
   471
Called from the LDD to handle a custom configuration request.
sl@0
   472
@param aFunction A number identifying the request.
sl@0
   473
@param aParam A 32-bit value passed to the driver. Its meaning depends on the request.
sl@0
   474
@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   475
*/
sl@0
   476
TInt DTemplateSoundScTxPdd::CustomConfig(TInt /*aFunction*/,TAny* /*aParam*/)
sl@0
   477
	{
sl@0
   478
	return(KErrNotSupported);
sl@0
   479
	}	
sl@0
   480
sl@0
   481
/**
sl@0
   482
Called from the LDD to find out how many microseconds of data have been played.  This is called
sl@0
   483
in the context of the DFC thread.
sl@0
   484
@param aTimeTransferred	A reference to a variable into which to place the number of microseconds of audio.
sl@0
   485
@param aStatus			The current status of this channel
sl@0
   486
@return KErrNone if time is valid or KErrNotSupported.
sl@0
   487
*/
sl@0
   488
TInt DTemplateSoundScTxPdd::TimeTransferred(TInt64& aTimeTransferred, TInt aStatus)
sl@0
   489
	{
sl@0
   490
	return(KErrNotSupported);
sl@0
   491
	}
sl@0
   492
sl@0
   493
/**
sl@0
   494
Called each time a playback DMA transfer completes - from the DMA callback function in the sound thread's DFC context.
sl@0
   495
@param aTransferID The transfer ID of the DMA transfer.
sl@0
   496
@param aTransferResult The result of the DMA transfer.
sl@0
   497
@param aBytesTransferred The number of bytes transferred.
sl@0
   498
*/	
sl@0
   499
void DTemplateSoundScTxPdd::PlayCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred)
sl@0
   500
	{
sl@0
   501
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::PlayCallback"));
sl@0
   502
	
sl@0
   503
	iPendingPlay--;
sl@0
   504
		
sl@0
   505
	Ldd()->PlayCallback(aTransferID,aTransferResult,aBytesTransferred);
sl@0
   506
	}
sl@0
   507
sl@0
   508
/**
sl@0
   509
Initialise the data member DTemplateSoundScTxPdd::iCaps with the play capabilities of this audio playback device.
sl@0
   510
*/	
sl@0
   511
void DTemplateSoundScTxPdd::SetCaps()
sl@0
   512
	{
sl@0
   513
	__KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetCaps"));
sl@0
   514
	
sl@0
   515
	// The data transfer direction for this unit is play.
sl@0
   516
	iCaps.iDirection=ESoundDirPlayback;
sl@0
   517
	
sl@0
   518
	// TO DO: (mandatory)
sl@0
   519
	// Setup the rest of the capabilities structure DTemplateSoundScTxPdd::iCaps with the capabilities of this
sl@0
   520
	// audio playback device.
sl@0
   521
	}	
sl@0
   522
sl@0
   523
/**
sl@0
   524
Constructor for a shared chunk sound driver playback DMA request.
sl@0
   525
*/
sl@0
   526
DTemplateSoundScTxDmaRequest::DTemplateSoundScTxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScTxPdd* aPdd,TInt aMaxTransferSize)
sl@0
   527
	: DDmaRequest(aChannel,DTemplateSoundScTxDmaRequest::DmaService,this,aMaxTransferSize),
sl@0
   528
	  iPdd(aPdd)
sl@0
   529
	{}
sl@0
   530
	
sl@0
   531
/**
sl@0
   532
DMA tx service routine. Called in the sound thread's DFC context by the s/w DMA controller.
sl@0
   533
@param aResult Status of DMA transfer.
sl@0
   534
@param aArg Argument passed to DMA controller.
sl@0
   535
*/	
sl@0
   536
void DTemplateSoundScTxDmaRequest::DmaService(TResult aResult, TAny* aArg)
sl@0
   537
	{
sl@0
   538
	__KTRACE_SND(Kern::Printf(">SndTxDmaService - %d",aResult));
sl@0
   539
	DTemplateSoundScTxDmaRequest& req=*(DTemplateSoundScTxDmaRequest*)aArg;
sl@0
   540
	
sl@0
   541
	TInt res=KErrNone;
sl@0
   542
	TInt bytesTransferred=req.iTransferSize;
sl@0
   543
	if (aResult!=DDmaRequest::EOk)
sl@0
   544
		{
sl@0
   545
		res=KErrCorrupt;
sl@0
   546
		bytesTransferred=0;
sl@0
   547
		}
sl@0
   548
		
sl@0
   549
	// Inform the LDD of the result of the transfer.
sl@0
   550
	req.iPdd->PlayCallback(req.iTransferID,res,bytesTransferred);	
sl@0
   551
	return;
sl@0
   552
	}
sl@0
   553