Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_attach_mixer_to_voice failure

This thread is locked; no one can reply to it. rss feed Print
al_attach_mixer_to_voice failure
archlinka
Member #17,215
December 2019

Hi,

I am doing some testing of my game and some players have problem with audio. I was able to discover that the problem is function al_attach_mixer_to_voice which fails. But it only happen to only a small portion of testers.

I of course read the documentation but I am not exactly "drivers guy" so I do not know where the underlying problem could be and how to solve it. Do you have any idea? Thanks for the answers.

Code snipped of my audio initialization. It failed on line 33.

#SelectExpand
1bool N_Audio_Player::init() 2{ 3 // Create voice. 4 voice_ = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2); 5 if (! voice_) { 6 n_error() << "[N_Audio_Player::init] Cannot create voice."; 7 return false; 8 } 9 10 // Create mixers. 11 mixer_master_ = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); 12 if (! mixer_master_) { 13 n_error() << "[N_Audio_Player::init] Cannot create master mixer."; 14 return false; 15 } 16 mixer_music_ = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); 17 if (! mixer_music_) { 18 n_error() << "[N_Audio_Player::init] Cannot create music mixer."; 19 return false; 20 } 21 mixer_sounds_ = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); 22 if (! mixer_sounds_) { 23 n_error() << "[N_Audio_Player::init] Cannot create sounds mixer."; 24 return false; 25 } 26 mixer_ambient_ = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2); 27 if (! mixer_ambient_) { 28 n_error() << "[N_Audio_Player::init] Cannot create ambient mixer."; 29 return false; 30 } 31 32 // Attache mixers. 33 if (! al_attach_mixer_to_voice(mixer_master_, voice_)) { 34 n_error() << "[N_Audio_Player::init] Cannot attach master mixer."; 35 return false; 36 } 37 if (! al_attach_mixer_to_mixer(mixer_music_, mixer_master_)) { 38 n_error() << "[N_Audio_Player::init] Cannot attach music mixer."; 39 return false; 40 } 41 if (! al_attach_mixer_to_mixer(mixer_sounds_, mixer_master_)) { 42 n_error() << "[N_Audio_Player::init] Cannot attach sounds mixer."; 43 return false; 44 } 45 if (! al_attach_mixer_to_mixer(mixer_ambient_, mixer_master_)) { 46 n_error() << "[N_Audio_Player::init] Cannot attach ambient mixer."; 47 return false; 48 } 49 50 // Create sample instances. 51 for (int i = 0; i < 16; ++i) { 52 ALLEGRO_SAMPLE_INSTANCE *const instance = al_create_sample_instance(nullptr); 53 if (! instance) { 54 break; 55 } 56 57 instances_.push_back(instance); 58 instances_frames_.push_back(std::make_pair(nil(), nullptr)); 59 } 60 61 // Set gains. 62 update_mixers_gain(); 63 return true; 64}

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

First of all, what OS are you using, and what version of Allegro, and also the compiler version used to produce it.

The call to start_voice may be failing for some.

https://github.com/liballeg/allegro5/blob/master/addons/audio/kcm_voice.c#L298

It depends on the audio driver in use.

Can you do some debugging? Are you proficient with gdb or another debugger?

archlinka
Member #17,215
December 2019

Hi, I can debug. Problem is that on all of my PCs it's working fine. But some others have problems.

The user who has this problem uses Windows 10. I am using msvc (don't know version because I am not at work) and Allegro version is 5.2.6 from NuGet package.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You'll probably need your players to debug for you, with MSVS or gdb.

I don't know much about the audio drivers, maybe @Peter Hull could help?

EDIT
It can also fail if already attached to a stream.

Go to: