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