Hi,
I just figured out a problem with some code we have. We want to play some background music, and this music has two parts: an introduction that gets things going, and a loop part that should be repeated indefinitely, and that should be started when the first part finishes. I don't think the solution we have in place is ideal, but it looks like this:
introMusicTrack.addTrackStateListener(new TrackStateListener() {
public void trackFinishedFade(AudioTrack track) {
}
public void trackPaused(AudioTrack track) {
}
public void trackPlayed(AudioTrack track) {
}
public void trackStopped(AudioTrack track) {
if (introPlaying) {
startLoopingTrack();
}
}
});
The intention being that when the first part of the track is finished, the second should be triggered - if we still want to play that music track at all. The problem was that even though we could see that the 'trackStopped' listener method was being called, we never heard the looping part play, and there were no messages in any log. It turned out that the listener callback was executed by a different thread than the one that played the rest of the sounds, and when we changed that - making sure that both calls to AudioTrack.play() were done from the same thread - things started working again.
Is this the intended behaviour? If so, maybe there should be some checks in the OpenAL-related classes to ensure that users that make calls from 'the wrong thread' get notified about that?
Best,
Petter