Sound Issues on the Nokia 6288 Causing Crash

I have been working a lot with the Nokia 6288 this week, fixing bugs reported when using 6280 builds. Despite being very similar devices, the 6288 consistently reported crash bugs when running 6280 builds with sound enabled.

This is nothing unusual. Most manufactures seem to change there interpretation of the MMAPI regularly and is a constant source of irritation for developers. However a crash bug related to audio is very serious and required some investigation.

The application used a typical sound implementation that uses a single Player and a byte array of sound data. When a sound is required, the Player instance releases any previously loaded sound, loads the required sound and finally plays it.

QA reported that the crash would occur most frequently immediately before a sound was played and in particular if sounds were played very close together. Because the bug did not occur on every played sound, this immediately points the finger at either the prefetch phase or a failed deallocation, most likely due to time constraints.

I tested this theory by placing a minimum time gap between each time the player is called, with a delay longer than that of the sound being played. This seemed to work for a while but ended up only delaying how long it would take for the crash to appear, rather than remove it. Besides, this would hardly be a suitable fix!

After some investigation, it was found that the problem lay in the Player.stop() function. It seemed that calling Player.stop() immediately after Player.start() caused the crash, and the closer the two were the more likely the bug was to arise.

The fix is equally simple. By simply calling Player.setMediaTime(0) before Player.stop(), the Player is left in a suitable state to be deallocated and closed.

A simple example is shown below:

// Free up the player resources from previous play instance
if( player != null ) {
    player.setMediaTime(0);
    player.stop();
    player.deallocate();
    player.close();
    player = null;
}
// Then create the player as usual
player = Manager.createPlayer( ... );
player.realize();
player.prefetch();
player.start();

Since writing, it has been found that the following devices are also affected
Nokia 5300

- FIN -


About this entry