I am having a problem whereby calls to the WriteL function of the CMdaAudioOutputStream class are leaving with KErrInUse.
This is repeatedly happening in the following situation:
- start streaming a couple of buffers (8K in size) using WriteL
- call Stop to stop streaming
- start sending buffers again using WriteL
- almost immediately call Stop giving error codes -39 (KErrAbort)to MaoscBufferCopied and -3 (KErrCancel) to MaoscBufferComplete
- start sending buffers again using WriteL - and this call will then leave with -14 (KErrInUse)
There seems to be something about calling the Stop function so soon after sending just 1 buffer of data using WriteL
Once I get this leave I have tried closing the CMdaAudioOutputStream and re-opening it but I still get the same leave the next time I call WriteL.
Has anyone experienced any problems like this when using the CMdaAudioOutputStream class? Or is anyone able to offer any suggestions?
Before you call WriteL() again, compare the the pointer of the buffer u pass to WriteL() with the one that u get in MaoscBufferCopied. If it is same, then only call WriteL() with next buffer or apply the same buffer again.
Maintain a variable like say iWriteInProgress and set this to true, when u call WriteL(). You can reset when u get the MaoscBufferCopied() callback.
Before ur call AudioEngine calls WriteL(), make sure iWriteInProgress is false.
If it's true, you haven't received the MaoscBufferCopied() callback yet, so buffer the incoming play packets. Later u can call WriteL() from within MaoscBufferCopied() for these buffered packets.
Check out the Audio Streaming Example on forum.nokia.com