253 TRequestStatus stat[3]; |
253 TRequestStatus stat[3]; |
254 TPtr8* tPtr[3]; |
254 TPtr8* tPtr[3]; |
255 TInt i; |
255 TInt i; |
256 for (i=0;i<3;i++) |
256 for (i=0;i<3;i++) |
257 tPtr[i]=new TPtr8(NULL,0); |
257 tPtr[i]=new TPtr8(NULL,0); |
258 |
258 |
|
259 TTime startTime; |
|
260 startTime.HomeTime(); |
|
261 |
259 // Start off by issuing a play request for each buffer (assuming that the file is long enough). Use the full size |
262 // Start off by issuing a play request for each buffer (assuming that the file is long enough). Use the full size |
260 // of each buffer. |
263 // of each buffer. |
261 TInt stillToRead=bytesToPlay; |
264 TInt stillToRead=bytesToPlay; |
262 TInt stillNotPlayed=bytesToPlay; |
265 TInt stillNotPlayed=bytesToPlay; |
263 TUint flags; |
266 TUint flags; |
288 |
291 |
289 FOREVER |
292 FOREVER |
290 { |
293 { |
291 // Wait for any one of the outstanding play requests to complete. |
294 // Wait for any one of the outstanding play requests to complete. |
292 User::WaitForAnyRequest(); |
295 User::WaitForAnyRequest(); |
|
296 |
|
297 TTime currentTime; |
|
298 currentTime.HomeTime(); |
|
299 TInt64 elapsedTime = currentTime.Int64()-startTime.Int64(); // us |
|
300 TTimeIntervalMicroSecondsBuf timePlayedBuf; |
|
301 if(TxSoundDevice.TimePlayed(timePlayedBuf) == KErrNone) |
|
302 { |
|
303 // Compare TimePlayed with the actual elapsed time. They should be different, but not drift apart too badly... |
|
304 TInt32 offset = TInt32(elapsedTime - timePlayedBuf().Int64()); |
|
305 Test.Printf(_L("\telapsedTime - TimePlayed = %d ms\n"), offset/1000); |
|
306 } |
293 |
307 |
294 // Work out which buffer this applies to |
308 // Work out which buffer this applies to |
295 for (i=0 ; i<3 ; i++) |
309 for (i=0 ; i<3 ; i++) |
296 { |
310 { |
297 if (stat[i]!=KRequestPending) |
311 if (stat[i]!=KRequestPending) |
509 r = destination.Write(headerDes); |
523 r = destination.Write(headerDes); |
510 |
524 |
511 TRequestStatus stat; |
525 TRequestStatus stat; |
512 TInt length; |
526 TInt length; |
513 TPtrC8 buf; |
527 TPtrC8 buf; |
|
528 |
|
529 TTime startTime; |
|
530 startTime.HomeTime(); |
514 |
531 |
515 // Start off by issuing a record request. |
532 // Start off by issuing a record request. |
516 TTime starttime; |
533 TTime starttime; |
517 starttime.HomeTime(); |
534 starttime.HomeTime(); |
518 TInt bytesRecorded = 0; |
535 TInt bytesRecorded = 0; |
519 RxSoundDevice.RecordData(stat,length); |
536 RxSoundDevice.RecordData(stat,length); |
520 |
537 |
|
538 TInt pausesToDo = 10; |
|
539 pausesToDo = 0; |
521 FOREVER |
540 FOREVER |
522 { |
541 { |
523 // Wait for the outstanding record request to complete. |
542 // Wait for the outstanding record request to complete. |
|
543 User::After(6000); |
|
544 |
524 User::WaitForAnyRequest(); |
545 User::WaitForAnyRequest(); |
525 if (stat==KRequestPending) |
546 if (stat==KRequestPending) |
526 return(KErrGeneral); |
547 return(KErrGeneral); |
|
548 |
|
549 TTime currentTime; |
|
550 currentTime.HomeTime(); |
|
551 TInt64 elapsedTime = currentTime.Int64()-startTime.Int64(); // us |
|
552 TTimeIntervalMicroSecondsBuf timeRecordedBuf; |
|
553 if(RxSoundDevice.TimeRecorded(timeRecordedBuf) == KErrNone) |
|
554 { |
|
555 // Compare TimeRecorded with the actual elapsed time. They should be different, but not drift apart too badly... |
|
556 TInt32 offset = TInt32(elapsedTime - timeRecordedBuf().Int64()); |
|
557 Test.Printf(_L("\telapsedTime - TimeRecorded = %d ms\n"), offset/1000); |
|
558 } |
527 |
559 |
528 // Check whether the record request was succesful. |
560 // Check whether the record request was succesful. |
529 TInt retOffset=stat.Int(); |
561 TInt retOffset=stat.Int(); |
530 if (retOffset<0) |
562 if (retOffset<0) |
531 { |
563 { |
547 Test.Printf(_L("Release buffer failed(%d)\r\n"),r); |
579 Test.Printf(_L("Release buffer failed(%d)\r\n"),r); |
548 return(r); |
580 return(r); |
549 } |
581 } |
550 |
582 |
551 Test.Printf(_L("Recorded %d more bytes - %d\r\n"),length,retOffset); |
583 Test.Printf(_L("Recorded %d more bytes - %d\r\n"),length,retOffset); |
|
584 |
|
585 if((pausesToDo > 0) && (bytesRecorded > bytesToRecord/2)) |
|
586 { |
|
587 --pausesToDo; |
|
588 Test.Printf(_L("Pause\r\n")); |
|
589 RxSoundDevice.Pause(); |
|
590 Test.Printf(_L("Paused, sleeping for 0.5 seconds\r\n")); |
|
591 User::After(500*1000); |
|
592 Test.Printf(_L("Resume\r\n")); |
|
593 RxSoundDevice.Resume(); |
|
594 } |
552 |
595 |
553 // Check whether we have now recorded all the data. If more to record then queue a further request |
596 // Check whether we have now recorded all the data. If more to record then queue a further request |
554 bytesRecorded+=length; |
597 bytesRecorded+=length; |
555 if (bytesRecorded<bytesToRecord) |
598 if (bytesRecorded<bytesToRecord) |
|
599 { |
|
600 Test.Printf(_L("RecordData\r\n")); |
556 RxSoundDevice.RecordData(stat,length); |
601 RxSoundDevice.RecordData(stat,length); |
|
602 } |
557 else |
603 else |
558 break; |
604 break; |
559 } |
605 } |
560 |
606 |
561 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
607 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |