Custom audio DataSource/SourceStream on Sony-Ericsson K700
posted 12 years ago
Hi there. I posted this question on SE's developer's forum a month ago and have got no response so I'm trying my luck here. The question is for K700 because that's the only phone I've tried, but I wonder if anybody out there doing similar things have similar problem on other phones. TKS in advance!
I need to play an unsupported audio compression format on K700, so I`m using a custom DataSource/SourceStream to decode the compressed audio into a standard wave file for playback. I find that on K700 the player keeps calling SourceStream.read() until read() returns -1 to indicate that the source has been exhausted. It happens during player.realize(), or player.prefetch(), or player.start() if I don't call realize() and prefetch(). The result is that no audio is played until the complete source has been decoded. By looking at memory and storage consumption it seems like all decoded wave samples are saved in the storage.
The emulator works differently: it first calls read() a few times to get wave header data, then AFTER player.start() returns it calls read() to get the wave samples. This is the desired behavior for playing frame-delimited source. MMAPI documentation does say that "DataSource/SourceStream supports the concept of transfer size that is more suited for frame-delimited data, e.g. video." However SourceStream.getTransferSize() isn't being called on either emulator or K700.
So my question is how can I get the K700 to play audio frame by frame?
One more piece of information. I implemented the PlayerListener interface, and I`m only getting STARTED and END_OF_MEDIA events, no BUFFERING_STARTED and BUFFERING_STOPPED. On emulator, END_OF_MEDIA comes with the right media time (duration of the clip), but on K700 the media time is -1000.
FYI I'm using Sony Ericsson WTK 2.1.4 on JBuilder Mobile Edition 10.1.26.0.