os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/soundsc_tx.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/soundsc_tx.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,553 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// template\template_variant\specific\soundsc_tx.cpp
1.18 +// Implementation of the Template playback shared chunk sound physical device driver (PDD).
1.19 +// This file is part of the Template Base port
1.20 +//
1.21 +//
1.22 +
1.23 +/**
1.24 + @file
1.25 +*/
1.26 +
1.27 +#include "soundsc_plat.h"
1.28 +
1.29 +// TO DO: (mandatory)
1.30 +// Declare a name for this driver. The format of this name should be
1.31 +// "SoundSc.xxxx" where xxxx is the variant name.
1.32 +_LIT(KSoundScPddName,"SoundSc.Template");
1.33 +
1.34 +// Definitions for the kernel thread created for this sound driver.
1.35 +_LIT(KSoundScDriverThreadName,"SoundDriverThread");
1.36 +const TInt KSoundScDriverThreadPriority=26; // One less than DFC thread 0
1.37 +
1.38 +/**
1.39 +Define a function at ordinal 0 which returns a new instance of a DPhysicalDevice-derived factory class.
1.40 +*/
1.41 +DECLARE_STANDARD_PDD()
1.42 + {
1.43 + return new DTemplateSoundScPddFactory;
1.44 + }
1.45 +
1.46 +/**
1.47 +Constructor for the shared chunk sound PDD factory class.
1.48 +*/
1.49 +DTemplateSoundScPddFactory::DTemplateSoundScPddFactory()
1.50 + {
1.51 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::DTemplateSoundScPddFactory"));
1.52 +
1.53 +// iDfcQ=NULL;
1.54 +
1.55 + // Support units KSoundScTxUnit0 & KSoundScRxUnit0.
1.56 + iUnitsMask=(1<<KSoundScRxUnit0)|(1<<KSoundScTxUnit0);
1.57 +
1.58 + // Set version number for this device.
1.59 + iVersion=RSoundSc::VersionRequired();
1.60 + }
1.61 +
1.62 +/**
1.63 +Destructor for the shared chunk sound PDD factory class.
1.64 +*/
1.65 +DTemplateSoundScPddFactory::~DTemplateSoundScPddFactory()
1.66 + {
1.67 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::~DTemplateSoundScPddFactory"));
1.68 +
1.69 + // Destroy the kernel thread.
1.70 + if (iDfcQ)
1.71 + iDfcQ->Destroy();
1.72 + }
1.73 +
1.74 +/**
1.75 +Second stage constructor for the shared chunk sound PDD factory class.
1.76 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.77 +*/
1.78 +TInt DTemplateSoundScPddFactory::Install()
1.79 + {
1.80 + TInt r=KErrNone;
1.81 + if (iDfcQ==NULL)
1.82 + {
1.83 + // Create a new sound driver DFC queue (and associated kernel thread).
1.84 + r=Kern::DynamicDfcQCreate(iDfcQ,KSoundScDriverThreadPriority,KSoundScDriverThreadName);
1.85 + }
1.86 +
1.87 + if (r==KErrNone)
1.88 + {
1.89 + r=SetName(&KSoundScPddName); // Set the name of the driver object
1.90 + }
1.91 +
1.92 + __KTRACE_SND(Kern::Printf("<DTemplateSoundScPddFactory::Install - %d",r));
1.93 + return(r);
1.94 + }
1.95 +
1.96 +/**
1.97 +Returns the PDD's capabilities. This is not used by the Symbian OS device driver framework
1.98 +or by the LDD.
1.99 +@param aDes A descriptor to write capabilities information into
1.100 +*/
1.101 +void DTemplateSoundScPddFactory::GetCaps(TDes8& /*aDes*/) const
1.102 + {}
1.103 +
1.104 +/**
1.105 +Called by the kernel's device driver framework to check if this PDD is suitable for use
1.106 +with a logical channel.
1.107 +This is called in the context of the client thread which requested the creation of a logical
1.108 +channel - through a call to RBusLogicalChannel::DoCreate().
1.109 +The thread is in a critical section.
1.110 +@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
1.111 +@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate() - not used.
1.112 +@param aVer The version number of the logical channel which will use this physical channel.
1.113 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.114 +*/
1.115 +TInt DTemplateSoundScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
1.116 + {
1.117 + // Check that the version specified is compatible.
1.118 + if (!Kern::QueryVersionSupported(RSoundSc::VersionRequired(),aVer))
1.119 + return(KErrNotSupported);
1.120 +
1.121 + // Check the unit number is compatible
1.122 + if (aUnit!=KSoundScTxUnit0 && aUnit!=KSoundScRxUnit0)
1.123 + return(KErrNotSupported);
1.124 +
1.125 + return(KErrNone);
1.126 + }
1.127 +
1.128 +/**
1.129 +Called by the kernel's device driver framework to create a physical channel object.
1.130 +This is called in the context of the client thread which requested the creation of a logical
1.131 +channel - through a call to RBusLogicalChannel::DoCreate().
1.132 +The thread is in a critical section.
1.133 +@param aChannel Set by this function to point to the created physical channel object.
1.134 +@param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate().
1.135 +@param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate().
1.136 +@param aVer The version number of the logical channel which will use this physical channel.
1.137 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.138 +*/
1.139 +TInt DTemplateSoundScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
1.140 + {
1.141 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScPddFactory::Create"));
1.142 +
1.143 + // Create the appropriate PDD channel object.
1.144 + TInt r=KErrNoMemory;
1.145 + if (aUnit==KSoundScRxUnit0)
1.146 + {
1.147 + // Create a record PDD channel object
1.148 + DTemplateSoundScRxPdd* pD=new DTemplateSoundScRxPdd;
1.149 + aChannel=pD;
1.150 + if (pD)
1.151 + {
1.152 + pD->iPhysicalDevice=this;
1.153 + r=pD->DoCreate();
1.154 + }
1.155 + }
1.156 +
1.157 + else
1.158 + {
1.159 + // Create a playback PDD channel object
1.160 + DTemplateSoundScTxPdd* pD=new DTemplateSoundScTxPdd;
1.161 + aChannel=pD;
1.162 + if (pD)
1.163 + {
1.164 + pD->iPhysicalDevice=this;
1.165 + r=pD->DoCreate();
1.166 + }
1.167 + }
1.168 + return(r);
1.169 + }
1.170 +
1.171 +
1.172 +/**
1.173 +Constructor for the Template playback shared chunk sound driver physical device driver (PDD).
1.174 +*/
1.175 +DTemplateSoundScTxPdd::DTemplateSoundScTxPdd()
1.176 + {
1.177 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::DTemplateSoundScTxPdd"));
1.178 +
1.179 +// iDmaChan=NULL;
1.180 +// iPendingPlay=0;
1.181 +// iFlag=0;
1.182 + }
1.183 +
1.184 +/**
1.185 +Destructor for the Template playback shared chunk sound driver physical device driver (PDD).
1.186 +*/
1.187 +DTemplateSoundScTxPdd::~DTemplateSoundScTxPdd()
1.188 + {
1.189 + // Delete the DMA request objects
1.190 + for (TInt i=0; i<KTemplateMaxTxDmaRequests; i++)
1.191 + {
1.192 + if (iDmaRequest[i])
1.193 + delete iDmaRequest[i];
1.194 + }
1.195 +
1.196 + // Close the DMA channel.
1.197 + if (iDmaChannel)
1.198 + iDmaChannel->Close();
1.199 + }
1.200 +
1.201 +/**
1.202 +Second stage constructor for the Template playback shared chunk sound driver physical device driver (PDD).
1.203 +Note that this constructor is called before the second stage constructor for the LDD so it is not
1.204 +possible to call methods on the LDD here.
1.205 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.206 +*/
1.207 +TInt DTemplateSoundScTxPdd::DoCreate()
1.208 + {
1.209 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::DoCreate"));
1.210 +
1.211 + SetCaps(); // Setup the capabilities of this device.
1.212 +
1.213 + // Setup a DMA channel for playback
1.214 + // TO DO: (mandatory)
1.215 + // Setup the DMA channel information for this play device.
1.216 + TDmaChannel::SCreateInfo info;
1.217 +// info.iCookie=???
1.218 + info.iDfcQ=DfcQ(KSoundScTxUnit0);
1.219 +// info.iDfcPriority=???
1.220 + info.iDesCount=KTemplateMaxTxDmaRequests;
1.221 + // coverity[uninit_use_in_call]
1.222 + // The values info.iCookie and info.iDfcPriority are to be initialized when implemented
1.223 + TInt r=TDmaChannel::Open(info,iDmaChannel);
1.224 +
1.225 + // Create the DMA request objects for use with the DMA channel.
1.226 + if (r==KErrNone)
1.227 + {
1.228 + for (TInt i=0; i<KTemplateMaxTxDmaRequests; i++)
1.229 + {
1.230 + iDmaRequest[i] = new DTemplateSoundScTxDmaRequest(*iDmaChannel,this);
1.231 + if (iDmaRequest[i] == NULL)
1.232 + {
1.233 + r=KErrNoMemory;
1.234 + break;
1.235 + }
1.236 + }
1.237 + }
1.238 +
1.239 + __KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::DoCreate - %d",r));
1.240 + return(r);
1.241 + }
1.242 +
1.243 +/**
1.244 +Return the DFC queue to be used by this playback device.
1.245 +@return The DFC queue to use.
1.246 +*/
1.247 +TDfcQue* DTemplateSoundScTxPdd::DfcQ(TInt /*aUnit*/)
1.248 + {
1.249 + return(iPhysicalDevice->iDfcQ);
1.250 + }
1.251 +
1.252 +/**
1.253 +Called from the LDD to return the shared chunk create information to be used by this play device.
1.254 +@param aChunkCreateInfo A chunk create info. object to be to be filled with the settings
1.255 + required for this device.
1.256 +*/
1.257 +void DTemplateSoundScTxPdd::GetChunkCreateInfo(TChunkCreateInfo& aChunkCreateInfo)
1.258 + {
1.259 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::GetChunkCreateInfo"));
1.260 +
1.261 + // TO DO: (mandatory)
1.262 + // Setup the shared chunk create information in aChunkCreateInfo for this play device.
1.263 + aChunkCreateInfo.iType=TChunkCreateInfo::ESharedKernelMultiple;
1.264 +// aChunkCreateInfo.iMapAttr=???
1.265 + aChunkCreateInfo.iOwnsMemory=ETrue; // Using RAM pages.
1.266 + aChunkCreateInfo.iDestroyedDfc=NULL; // No chunk destroy DFC.
1.267 + }
1.268 +
1.269 +/**
1.270 +Called from the LDD to return the capabilities of this device.
1.271 +@param aCapsBuf A packaged TSoundFormatsSupportedV02 object to be filled with the play
1.272 + capabilities of this device. This descriptor is in kernel memory and can be accessed directly.
1.273 +@see TSoundFormatsSupportedV02.
1.274 +*/
1.275 +void DTemplateSoundScTxPdd::Caps(TDes8& aCapsBuf) const
1.276 + {
1.277 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::Caps"));
1.278 +
1.279 + // Copy iCaps back.
1.280 + TPtrC8 ptr((const TUint8*)&iCaps,sizeof(iCaps));
1.281 + aCapsBuf.FillZ(aCapsBuf.MaxLength());
1.282 + aCapsBuf=ptr.Left(Min(ptr.Length(),aCapsBuf.MaxLength()));
1.283 + }
1.284 +
1.285 +/**
1.286 +Called from the LDD to return the maximum transfer length in bytes that this device can support in a single data transfer.
1.287 +@return The maximum transfer length in bytes.
1.288 +*/
1.289 +TInt DTemplateSoundScTxPdd::MaxTransferLen() const
1.290 + {
1.291 + return(KTemplateMaxTxDmaTransferLen);
1.292 + }
1.293 +
1.294 +/**
1.295 +Called from the LDD to configure or reconfigure the device using the the configuration supplied.
1.296 +@param aConfigBuf A packaged TCurrentSoundFormatV02 object which contains the new configuration settings.
1.297 + This descriptor is in kernel memory and can be accessed directly.
1.298 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.299 +@see TCurrentSoundFormatV02.
1.300 +*/
1.301 +TInt DTemplateSoundScTxPdd::SetConfig(const TDesC8& aConfigBuf)
1.302 + {
1.303 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetConfig"));
1.304 +
1.305 + // Read the new configuration from the LDD.
1.306 + TCurrentSoundFormatV02 config;
1.307 + TPtr8 ptr((TUint8*)&config,sizeof(config));
1.308 + Kern::InfoCopy(ptr,aConfigBuf);
1.309 +
1.310 + // TO DO: (mandatory)
1.311 + // Apply the specified audio configuration to the audio device.
1.312 + TInt r=KErrNone;
1.313 +
1.314 + __KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::SetConfig - %d",r));
1.315 + return(r);
1.316 + }
1.317 +
1.318 +/**
1.319 +Called from the LDD to set the play volume.
1.320 +@param aVolume The play volume to be set - a value in the range 0 to 255. The value 255 equates
1.321 + to the maximum volume and each value below this equates to a 0.5dB step below it.
1.322 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.323 +*/
1.324 +TInt DTemplateSoundScTxPdd::SetVolume(TInt aVolume)
1.325 + {
1.326 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetVolume"));
1.327 +
1.328 + // TO DO: (mandatory)
1.329 + // Set the specified play volume on the audio device.
1.330 + TInt r=KErrNone;
1.331 +
1.332 + return(r);
1.333 + }
1.334 +
1.335 +/**
1.336 +Called from the LDD to prepare the audio device for playback.
1.337 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.338 +*/
1.339 +TInt DTemplateSoundScTxPdd::StartTransfer()
1.340 + {
1.341 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::StartTransfer"));
1.342 +
1.343 + // TO DO: (mandatory)
1.344 + // Prepare the audio device for playback.
1.345 + TInt r=KErrNone;
1.346 +
1.347 + __KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::StartTransfer - %d",r));
1.348 + return(r);
1.349 + }
1.350 +
1.351 +/**
1.352 +Called from the LDD to initiate the playback of a portion of data to the audio device.
1.353 +When the transfer is complete, the PDD signals this event using the LDD function PlayCallback().
1.354 +@param aTransferID A value assigned by the LDD to allow it to uniquely identify a particular transfer fragment.
1.355 +@param aLinAddr The linear address within the shared chunk of the start of the data to be played.
1.356 +@param aPhysAddr The physical address within the shared chunk of the start of the data to be played.
1.357 +@param aNumBytes The number of bytes to be played.
1.358 +@return KErrNone if the transfer has been initiated successfully;
1.359 + KErrNotReady if the device is unable to accept the transfer for the moment;
1.360 + otherwise one of the other system-wide error codes.
1.361 +*/
1.362 +TInt DTemplateSoundScTxPdd::TransferData(TUint aTransferID,TLinAddr aLinAddr,TPhysAddr /*aPhysAddr*/,TInt aNumBytes)
1.363 + {
1.364 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::TransferData(ID:%xH,Addr:%xH,Len:%d)",aLinAddr,aNumBytes));
1.365 +
1.366 + TInt r=KErrNone;
1.367 +
1.368 + // Check that we can accept the request
1.369 + if (iPendingPlay>=KTemplateMaxTxDmaRequests)
1.370 + r=KErrNotReady;
1.371 + else
1.372 + {
1.373 + // Start a DMA transfer.
1.374 + iDmaRequest[iFlag]->iTransferID=aTransferID;
1.375 + iDmaRequest[iFlag]->iTransferSize=aNumBytes;
1.376 + // TO DO: (mandatory)
1.377 + // Supply the DMA destination information.
1.378 + TUint32 dest=0; // ???
1.379 + r=iDmaRequest[iFlag]->Fragment(aLinAddr,dest,aNumBytes,KDmaMemSrc|KDmaIncSrc,0);
1.380 + if (r==KErrNone)
1.381 + {
1.382 + iDmaRequest[iFlag]->Queue();
1.383 + iPendingPlay++;
1.384 + if ((++iFlag)>=KTemplateMaxTxDmaRequests)
1.385 + iFlag=0;
1.386 +
1.387 + // TO DO: (mandatory)
1.388 + // Start the audio device transfering data.
1.389 + }
1.390 + }
1.391 +
1.392 + __KTRACE_SND(Kern::Printf("<DTemplateSoundScTxPdd::TransferData - %d",r));
1.393 + return(r);
1.394 + }
1.395 +
1.396 +/**
1.397 +Called from the LDD to terminate the playback of a data to the device and to release any resources necessary for playback.
1.398 +This is called soon after the last pending play request from the client has been completed. Once this function had been
1.399 +called, the LDD will not issue any further TransferData() commands without first issueing a StartTransfer() command.
1.400 +*/
1.401 +void DTemplateSoundScTxPdd::StopTransfer()
1.402 + {
1.403 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::StopTransfer"));
1.404 +
1.405 + // Stop the DMA channel.
1.406 + iDmaChannel->CancelAll();
1.407 + iFlag=0;
1.408 + iPendingPlay=0;
1.409 +
1.410 + // TO DO: (mandatory)
1.411 + // Stop the audio device transfering data.
1.412 + }
1.413 +
1.414 +/**
1.415 +Called from the LDD to halt the playback of data to the sound device but not to release any resources necessary for
1.416 +playback.
1.417 +If possible, any active transfer should be suspended in such a way that it can be resumed later - starting from next
1.418 +sample following the one last played.
1.419 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.420 +*/
1.421 +TInt DTemplateSoundScTxPdd::PauseTransfer()
1.422 + {
1.423 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::PauseTransfer"));
1.424 +
1.425 + // TO DO: (mandatory)
1.426 + // Halt playback on the audio device.
1.427 + TInt r=KErrNone;
1.428 +
1.429 + return(r);
1.430 + }
1.431 +
1.432 +/**
1.433 +Called from the LDD to resume the playback of data to the sound device following a request to halt playback.
1.434 +If possible, any transfer which was active when the device was halted should be resumed - starting from next sample
1.435 +following the one last played. Once complete, it should be reported using PlayCallback()
1.436 +as normal.
1.437 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.438 +*/
1.439 +TInt DTemplateSoundScTxPdd::ResumeTransfer()
1.440 + {
1.441 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::ResumeTransfer"));
1.442 +
1.443 + // TO DO: (mandatory)
1.444 + // Resume playback on the audio device.
1.445 + TInt r=KErrNone;
1.446 +
1.447 + return(r);
1.448 + }
1.449 +
1.450 +/**
1.451 +Called from the LDD to power up the sound device when the channel is first opened and if ever the phone is brought out
1.452 +of standby mode.
1.453 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.454 +*/
1.455 +TInt DTemplateSoundScTxPdd::PowerUp()
1.456 + {
1.457 + // TO DO: (mandatory)
1.458 + // Power up the audio device.
1.459 +
1.460 + return(KErrNone);
1.461 + }
1.462 +
1.463 +/**
1.464 +Called from the LDD to power down the sound device when the channel is closed and just before the phone powers down when
1.465 +being turned off or going into standby.
1.466 +*/
1.467 +void DTemplateSoundScTxPdd::PowerDown()
1.468 + {
1.469 + // TO DO: (mandatory)
1.470 + // Power down the audio device.
1.471 + }
1.472 +
1.473 +/**
1.474 +Called from the LDD to handle a custom configuration request.
1.475 +@param aFunction A number identifying the request.
1.476 +@param aParam A 32-bit value passed to the driver. Its meaning depends on the request.
1.477 +@return KErrNone if successful, otherwise one of the other system wide error codes.
1.478 +*/
1.479 +TInt DTemplateSoundScTxPdd::CustomConfig(TInt /*aFunction*/,TAny* /*aParam*/)
1.480 + {
1.481 + return(KErrNotSupported);
1.482 + }
1.483 +
1.484 +/**
1.485 +Called from the LDD to find out how many microseconds of data have been played. This is called
1.486 +in the context of the DFC thread.
1.487 +@param aTimeTransferred A reference to a variable into which to place the number of microseconds of audio.
1.488 +@param aStatus The current status of this channel
1.489 +@return KErrNone if time is valid or KErrNotSupported.
1.490 +*/
1.491 +TInt DTemplateSoundScTxPdd::TimeTransferred(TInt64& aTimeTransferred, TInt aStatus)
1.492 + {
1.493 + return(KErrNotSupported);
1.494 + }
1.495 +
1.496 +/**
1.497 +Called each time a playback DMA transfer completes - from the DMA callback function in the sound thread's DFC context.
1.498 +@param aTransferID The transfer ID of the DMA transfer.
1.499 +@param aTransferResult The result of the DMA transfer.
1.500 +@param aBytesTransferred The number of bytes transferred.
1.501 +*/
1.502 +void DTemplateSoundScTxPdd::PlayCallback(TUint aTransferID,TInt aTransferResult,TInt aBytesTransferred)
1.503 + {
1.504 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::PlayCallback"));
1.505 +
1.506 + iPendingPlay--;
1.507 +
1.508 + Ldd()->PlayCallback(aTransferID,aTransferResult,aBytesTransferred);
1.509 + }
1.510 +
1.511 +/**
1.512 +Initialise the data member DTemplateSoundScTxPdd::iCaps with the play capabilities of this audio playback device.
1.513 +*/
1.514 +void DTemplateSoundScTxPdd::SetCaps()
1.515 + {
1.516 + __KTRACE_SND(Kern::Printf(">DTemplateSoundScTxPdd::SetCaps"));
1.517 +
1.518 + // The data transfer direction for this unit is play.
1.519 + iCaps.iDirection=ESoundDirPlayback;
1.520 +
1.521 + // TO DO: (mandatory)
1.522 + // Setup the rest of the capabilities structure DTemplateSoundScTxPdd::iCaps with the capabilities of this
1.523 + // audio playback device.
1.524 + }
1.525 +
1.526 +/**
1.527 +Constructor for a shared chunk sound driver playback DMA request.
1.528 +*/
1.529 +DTemplateSoundScTxDmaRequest::DTemplateSoundScTxDmaRequest(TDmaChannel& aChannel,DTemplateSoundScTxPdd* aPdd,TInt aMaxTransferSize)
1.530 + : DDmaRequest(aChannel,DTemplateSoundScTxDmaRequest::DmaService,this,aMaxTransferSize),
1.531 + iPdd(aPdd)
1.532 + {}
1.533 +
1.534 +/**
1.535 +DMA tx service routine. Called in the sound thread's DFC context by the s/w DMA controller.
1.536 +@param aResult Status of DMA transfer.
1.537 +@param aArg Argument passed to DMA controller.
1.538 +*/
1.539 +void DTemplateSoundScTxDmaRequest::DmaService(TResult aResult, TAny* aArg)
1.540 + {
1.541 + __KTRACE_SND(Kern::Printf(">SndTxDmaService - %d",aResult));
1.542 + DTemplateSoundScTxDmaRequest& req=*(DTemplateSoundScTxDmaRequest*)aArg;
1.543 +
1.544 + TInt res=KErrNone;
1.545 + TInt bytesTransferred=req.iTransferSize;
1.546 + if (aResult!=DDmaRequest::EOk)
1.547 + {
1.548 + res=KErrCorrupt;
1.549 + bytesTransferred=0;
1.550 + }
1.551 +
1.552 + // Inform the LDD of the result of the transfer.
1.553 + req.iPdd->PlayCallback(req.iTransferID,res,bytesTransferred);
1.554 + return;
1.555 + }
1.556 +