Audio fals to install sometimes
kovarex

Hello,
randomly, for me once per ~20 starts, but much more frequently for some other people, the audio addon just fails to install. When this error occurs and the application is started again, it works.

What can be the reason of this? Is there some workaround?
Does it make sense to do something like wait and try it again in the init function when it fails?

André Silva

Mightn't be a problem with the libraries, at least I never heard about this. What version of Allegro are you using? Have you tried other versions? What about compiling using the individual libraries or the monolith one? And what about compiling with the mt and md ones, and debug vs release?
In other words, try it compiling with other versions of the Allegro library, to see if the problem lies there. If it shows the problem with every other version, then shoot some code, might be something that's not being done right.

kovarex

Hello, thank you for your response,

we use allegro 5.1.5, we compile it our own way (statically).
This is very hard to debug, as it occurs just rarely and randomly.

This is our allegro init function, I don't think that something rare is there:

#SelectExpand
1 if (global->graphicsSettings->getFullScreen()) 2 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); 3 else 4 al_set_new_display_flags(ALLEGRO_RESIZABLE); 5 al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); 6 if (global->graphicsSettings->getMultisamplingLevel() != 0) 7 { 8 al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_VIDEO_BITMAP); 9 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); 10 al_set_new_display_option(ALLEGRO_SAMPLES, global->graphicsSettings->getMultisamplingLevel(), ALLEGRO_SUGGEST); 11 } 12 else 13 { 14 al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); 15 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 0, ALLEGRO_SUGGEST); 16 al_set_new_display_option(ALLEGRO_SAMPLES, 0, ALLEGRO_SUGGEST); 17 } 18 19 this->display = al_create_display(width, height); 20 21 if (!this->display) 22 throw std::runtime_error("failed to create display!"); 23 if (!al_init_image_addon()) 24 throw std::runtime_error("Failed to initialize al_init_image_addon!"); 25 26 boost::filesystem::path windowIconPath = global->paths->graphics / "factorio-icon.png"; 27 this->windowIcon = al_load_bitmap(windowIconPath.string().c_str()); 28 if (!this->windowIcon) 29 throw std::runtime_error(ssprintf("Failed to load window icon! Loading from: %s", windowIconPath.string().c_str())); 30 al_set_display_icon(this->display, this->windowIcon); 31 32 if (!al_install_keyboard()) 33 throw std::runtime_error("failed to initialize the keyboard!"); 34 if (!al_install_mouse()) 35 throw std::runtime_error("failed to initialize the mouse!"); 36 al_init_font_addon(); 37 if (!al_init_ttf_addon()) 38 throw std::runtime_error("failed to initialize the ttf addon!"); 39 if (!al_init_primitives_addon()) 40 throw std::runtime_error("failed to load primitives addon!"); 41 if (!al_install_audio()) 42 throw std::runtime_error("Failed to install audio!"); 43 if (!al_init_acodec_addon()) 44 throw std::runtime_error("Failed to initialize audio codecs!"); 45 if (!al_reserve_samples(50)) 46 throw std::runtime_error("Failed to reserve samples!"); 47 this->loadAllegroFonts();

André Silva

Nope, doesn't look like the code has anything wrong with it.
Maybe it's a problem with Allegro 5.1.5. The 5.1 branch changes a few things. Let's see if someone else who knows more about 5.1 can figure something out.

Edgar Reynaldo

Your best bet is to dig inside al_install_audio and set a breakpoint in there somewhere or follow it through the call. Keep running it until it fails to install again.

Yeah, try setting a breakpoint in do_install_audio in addons/audio/audio.c lines 173-330. Find out which driver it is using, and I think you can specify the audio driver used in the allegro.cfg file too, so it might not hurt to try some different ones and see if they work.

Thread #612493. Printed from Allegro.cc