Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro GTK3 and Mac

This thread is locked; no one can reply to it. rss feed Print
Allegro GTK3 and Mac
deepstar
Member #18,247
September 2020

I am trying to improve an OpenSource project called gpredict, I would like to add audio... and hence I ended up at your door.

But there is something unpleasant going on with the Mac and it's instance to run Allegro from the main thread - because this is what GTK3 also appears to want to do....

Enough talk - Please find 4 files attached....

This builds are runs wonderfully in Ubuntu, this crashes and after 4 hours of trying to trick Allegro into use a fake_main, calling main etc ... I am calling it quits for today.

Can anyone point me to the path of happiness with regards to Allegro and gtk3 on a mac ??

Build steps

mkdir build
cd build
cmake ..

There should be 3 files...

gtk
gtk2
gtk3

Trying to show that Gtk Works, works with a simple Dialog, and then Works with an Audio file ... (Sorry you will need to change the definition of this file in audio.h)

Many thanks for taking the time to read this.

Tim

Peter Hull
Member #1,136
March 2001

I've never used GTK and Allegro together on MacOS (the native dialogs use Cocoa) but did your investigations include al_run_main?

[edit] are you using Allegro just for audio in the app?

[edit2] actually the audio stuff is not so picky about the threads. For example this works on my Mac

#include <allegro5/allegro.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#undef main
int main() {
  al_install_audio();
  al_reserve_samples(1);
  al_init_acodec_addon();
  ALLEGRO_SAMPLE* s= al_load_sample("welcome.wav");
  al_play_sample(s, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
  sleep(10);
  return 0;
}

Note: #undef main to defeat Allegro's attempt to take over main. Don't specify the allegro_main addon. Don't call al_init
If you are using Allegro for graphics too, then we will have to think a bit harder.

(btw, doesn't GTK have decent audio functions of its own?)

deepstar
Member #18,247
September 2020

Peter - Thank u for the #undef main, it all now works correctly.

Yes I am just looking at adding an Audio output.

Gtk does have audio capability - gtk_beep !!! Which is now deprecated....

Many thanks, for the assistance.

Tim

Go to: