Multiple buffer PCM stream playback | developer.brewmp.com Multiple buffer PCM stream playback | developer.brewmp.com

Developer

Multiple buffer PCM stream playback

Forums:

Hi there,

I am trying to get multiple buffer playback using PCM stream. My goal is to stream real-time generated sound data. I have two IMedia classes with class ID: AEECLSID_MEDIAPCM, and sources created with ISOURCEUTIL_SourceFromMemory.

I want to switch between two playback buffers during playing. However I cannot get IMedia multi-sequencing to work as in the example PDF => http://brew.qualcomm.com/brew_bnry/pdf/developer/resources/ds/IMediaMultiSequencing.pdf
Problem remains even if I set IMEDIA_EnableChannelShare() accordingly.

Is this a problem with the simulator, or a problem with PCM?

Is there a smarter way to do double buffer playback?

Thankful for any suggestions!
Johan

Are you using BREW 3.1.3? Starting with BREW 3.1.3, the simulator is capable of streaming PCM media files using ISource as an input to IMedia. [Note that the IMedia real-time PCM streaming support was added in BREW 3.1.2, but the simulator does not support it until 3.1.3]
In a related area, 2.1.3 also supports streaming of PCM and QCP formats but there is no support for this feature in the emulator.

Are you using BREW 3.1.3? Starting with BREW 3.1.3, the simulator is capable of streaming PCM media files using ISource as an input to IMedia. [Note that the IMedia real-time PCM streaming support was added in BREW 3.1.2, but the simulator does not support it until 3.1.3]
In a related area, 2.1.3 also supports streaming of PCM and QCP formats but there is no support for this feature in the emulator.

Hi aiyengar!
Thanks a lot for your reply :)
Yes, I got IMedia to stream sound successfully from ISource using v3.1.3 simulator. It works fine as long as I play once from single buffer.
The problem is if I want to do double-buffer playback. I want to play from one buffer, while generating new audio into the other, and switch between the buffers continously.
I however have all kinds of problems with playing from ISource buffers. I manage to play from a buffer the first time, but not the second, even if I create a new ISource object for the buffer. Also there is the problem of getting the timing right.
At any rate, it looks to me that it is hard to get real-time generated audio playback to work on BREW :-I
Do you know if it is possible to override the ISource interface, so I can provide IMedia with my own ISource implementation?
Regards,
Johan
PS I am sorry if I don't express clearly enough - if so please ask again.

Hi aiyengar!
Thanks a lot for your reply :)
Yes, I got IMedia to stream sound successfully from ISource using v3.1.3 simulator. It works fine as long as I play once from single buffer.
The problem is if I want to do double-buffer playback. I want to play from one buffer, while generating new audio into the other, and switch between the buffers continously.
I however have all kinds of problems with playing from ISource buffers. I manage to play from a buffer the first time, but not the second, even if I create a new ISource object for the buffer. Also there is the problem of getting the timing right.
At any rate, it looks to me that it is hard to get real-time generated audio playback to work on BREW :-I
Do you know if it is possible to override the ISource interface, so I can provide IMedia with my own ISource implementation?
Regards,
Johan
PS I am sorry if I don't express clearly enough - if so please ask again.

Multiple buffer playback was necessary when BREW did not support streaming (even then, there was a possibility of a small gap in audio in between buffer swaps). Now that streaming is supported, you should move away from the multiple buffer switching technique and instead look at providing a "source" (IMedia will take care of the buffers on its side). Try providing a source from IWeb to see the streaming in action. ;)
Regardless, you can only provide streaming info, if only a single media source is provided in AEEMediaDataEx
However, if you must use multiple buffers as your source, you need to write your own implementation of ISource (which will correctly switch between the buffers on the read operations). For more details on the functions you will need to implement for ISource, look at the ISource API in the BREW API reference doc. (Also check out AEERandomSource.h)

Multiple buffer playback was necessary when BREW did not support streaming (even then, there was a possibility of a small gap in audio in between buffer swaps). Now that streaming is supported, you should move away from the multiple buffer switching technique and instead look at providing a "source" (IMedia will take care of the buffers on its side). Try providing a source from IWeb to see the streaming in action. ;)
Regardless, you can only provide streaming info, if only a single media source is provided in AEEMediaDataEx
However, if you must use multiple buffers as your source, you need to write your own implementation of ISource (which will correctly switch between the buffers on the read operations). For more details on the functions you will need to implement for ISource, look at the ISource API in the BREW API reference doc. (Also check out AEERandomSource.h)

Hi aiyengar!
OK, thanks a lot for your help!
So it looks like I have to do my own implementation of ISource.
How should I do this in C? I spent the afternoon with it, but have problems understanding the vtable macros in Brew. I try doing as in the extension examples, but I can't get it to compile.
Are there any examples available for doing anything similar?
Regards,
Johan

Hi aiyengar!
OK, thanks a lot for your help!
So it looks like I have to do my own implementation of ISource.
How should I do this in C? I spent the afternoon with it, but have problems understanding the vtable macros in Brew. I try doing as in the extension examples, but I can't get it to compile.
Are there any examples available for doing anything similar?
Regards,
Johan

Sorry - I think I got it figured out now :P
I missed doing
typedef struct _IDemoExtension IDemoExtension;
at the beginning of the header file.
Regards,
Johan

Sorry - I think I got it figured out now :P
I missed doing
typedef struct _IDemoExtension IDemoExtension;
at the beginning of the header file.
Regards,
Johan

Hi there,
I have more questions about how to provide my own implementation of ISource.
Is there any simpler way of doing this than creating a new extension?
It seems kind of overkill because the class will only be used by one program anyway...
Regards,
Johan

Hi there,
I have more questions about how to provide my own implementation of ISource.
Is there any simpler way of doing this than creating a new extension?
It seems kind of overkill because the class will only be used by one program anyway...
Regards,
Johan

Well, you dont really need to implement a seperate extension. You can just implement all the ISource functions in your applet and cast your applet pointer to ISource and pass it to IMedia.

Well, you dont really need to implement a seperate extension. You can just implement all the ISource functions in your applet and cast your applet pointer to ISource and pass it to IMedia.