[AD] Deadlock in KCM audio

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I've experienced a number of "issues" with KCM audio, and tried to debug
them to no avail. I can't get my head around what's happening in that code.
Anyway, I post in hopes that someone may be able to help with a specific issue
of deadlock. My game tries to play an ogg:

void playMusic(std::string name, bool setLoopStart, unsigned int loopStart)
{
	if (!sound_inited) return;

	if (musicName == name)
		return;
	
	musicName = name;

	if (music) {
		al_detach_audio_stream(music);
		al_set_audio_stream_playing(music, false);
		al_destroy_audio_stream(music);
	}

	if (name == "") {
		music = 0;
		return;
	}

	music = al_load_audio_stream(getResource("music/%s", name.c_str()).c_str(), 4,
		1024*2);
	
	if (!music) {
		return;
	}
	
	al_set_audio_stream_playmode(music, ALLEGRO_PLAYMODE_LOOP);

	if (setLoopStart) {
		al_set_audio_stream_loop_secs(music, loopStart/1000.0,
			al_get_audio_stream_length_secs(music));
	}

	al_attach_audio_stream_to_mixer(music, al_get_default_mixer());

	setMusicVolume(1);
}

In some rare occurances, it deadlocks on line 880 in kcm_mixer.c. This is on OS X.
I spent the past few weekends testing the same code on Linux and never ran into
a deadlock once. However, the code is shared between both platforms. I also tested
very heavily on iPhone and thought my KCM woes were behind me. Any help, such as
advice on where to look for the coinciding lock would be MUCH appreciated.

And while on the topic, is it possible that it's an issue with the OpenAL driver?
That's the big variable between the other platforms I've tested (also/oss/aqueue).

Thanks
--
Trent Gamblin
Founder, Nooskewl
Web: http://www.nooskewl.com




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/