mirror of
https://github.com/0ldsk00l/nestopia.git
synced 2024-06-02 19:38:20 -04:00
Make libao an optional dependency
This commit is contained in:
parent
559212b827
commit
62d90b953a
|
@ -21,7 +21,6 @@ nestopia_CPPFLAGS = \
|
|||
nestopia_LDADD = \
|
||||
$(ZLIB_LIBS) \
|
||||
$(LIBARCHIVE_LIBS) \
|
||||
$(LIBAO_LIBS) \
|
||||
$(SDL2_LIBS) \
|
||||
$(LIBEPOXY_LIBS)
|
||||
|
||||
|
@ -30,6 +29,11 @@ nestopia_CPPFLAGS += -D_GTK $(GTK3_CFLAGS)
|
|||
nestopia_LDADD += $(GTK3_LIBS)
|
||||
endif
|
||||
|
||||
if ENABLE_LIBAO
|
||||
nestopia_CPPFLAGS += -D_LIBAO $(LIBAO_CFLAGS)
|
||||
nestopia_LDADD += $(LIBAO_LIBS)
|
||||
endif
|
||||
|
||||
if ENABLE_JACK
|
||||
nestopia_CPPFLAGS += -D_JACK $(JACK_CFLAGS)
|
||||
nestopia_LDADD += $(JACK_LIBS)
|
||||
|
|
11
configure.ac
11
configure.ac
|
@ -73,15 +73,20 @@ PKG_CHECK_MODULES([ZLIB], [zlib])
|
|||
dnl libarchive
|
||||
PKG_CHECK_MODULES([LIBARCHIVE], [libarchive])
|
||||
|
||||
dnl libao
|
||||
PKG_CHECK_MODULES([LIBAO], [ao])
|
||||
|
||||
dnl SDL2
|
||||
PKG_CHECK_MODULES([SDL2], [sdl2])
|
||||
|
||||
dnl LibEpoxy
|
||||
PKG_CHECK_MODULES([LIBEPOXY], [epoxy])
|
||||
|
||||
dnl libao
|
||||
AC_ARG_WITH([ao],
|
||||
AS_HELP_STRING([--with-ao], [Build with libao audio support]))
|
||||
AS_IF([test "x$with_ao" = "xyes"], [
|
||||
PKG_CHECK_MODULES([LIBAO],[ao])
|
||||
])
|
||||
AM_CONDITIONAL([ENABLE_LIBAO], [test "x$with_ao" = "xyes"])
|
||||
|
||||
dnl JACK audio
|
||||
AC_ARG_WITH([jack],
|
||||
AS_HELP_STRING([--with-jack], [Build with JACK audio support]))
|
||||
|
|
|
@ -449,7 +449,9 @@ GtkWidget *gtkui_config() {
|
|||
"margin-left", MARGIN_LR,
|
||||
NULL);
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_audio_api), "SDL");
|
||||
#ifdef _LIBAO
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_audio_api), "libao");
|
||||
#endif
|
||||
#ifdef _JACK
|
||||
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_audio_api), "jack");
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "config.h"
|
||||
#include "audio.h"
|
||||
|
||||
#ifndef _MINGW
|
||||
#ifdef _LIBAO
|
||||
#include <ao/ao.h>
|
||||
|
||||
static ao_device *aodevice;
|
||||
|
@ -72,22 +72,10 @@ void audio_output_sdl() {
|
|||
if (SDL_GetQueuedAudioSize(dev) > (Uint32)(bufsize * 3)) { SDL_ClearQueuedAudio(dev); }
|
||||
}
|
||||
|
||||
void audio_output_ao() {
|
||||
#ifndef _MINGW
|
||||
ao_play(aodevice, (char*)audiobuf, bufsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio_deinit_sdl() {
|
||||
if (dev) { SDL_CloseAudioDevice(dev); }
|
||||
}
|
||||
|
||||
void audio_deinit_ao() {
|
||||
#ifndef _MINGW
|
||||
if (aodevice) { ao_close(aodevice); ao_shutdown(); }
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio_play() {
|
||||
if (paused) { return; }
|
||||
bufsize = 2 * channels * (conf.audio_sample_rate / framerate);
|
||||
|
@ -123,8 +111,16 @@ void audio_init_sdl() {
|
|||
SDL_PauseAudioDevice(dev, 1); // Setting to 0 unpauses
|
||||
}
|
||||
|
||||
#ifdef _LIBAO
|
||||
void audio_output_ao() {
|
||||
ao_play(aodevice, (char*)audiobuf, bufsize);
|
||||
}
|
||||
|
||||
void audio_deinit_ao() {
|
||||
if (aodevice) { ao_close(aodevice); ao_shutdown(); }
|
||||
}
|
||||
|
||||
void audio_init_ao() {
|
||||
#ifndef _MINGW
|
||||
ao_initialize();
|
||||
|
||||
int default_driver = ao_default_driver_id();
|
||||
|
@ -143,8 +139,8 @@ void audio_init_ao() {
|
|||
else {
|
||||
fprintf(stderr, "Audio: libao - %dHz, %d-bit, %d channel(s)\n", format.rate, format.bits, format.channels);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _JACK
|
||||
int audio_cb_jack(jack_nframes_t nframes, void *arg) {
|
||||
|
@ -248,16 +244,22 @@ void audio_set_funcs() {
|
|||
audio_output = &audio_output_sdl;
|
||||
audio_deinit = &audio_deinit_sdl;
|
||||
}
|
||||
#ifdef _LIBAO
|
||||
else if (conf.audio_api == 1) { // libao
|
||||
audio_output = &audio_output_ao;
|
||||
audio_deinit = &audio_deinit_ao;
|
||||
}
|
||||
#endif
|
||||
#ifdef _JACK
|
||||
else if (conf.audio_api == 2) { //JACK
|
||||
audio_output = &audio_output_jack;
|
||||
audio_deinit = &audio_deinit_jack;
|
||||
}
|
||||
#endif
|
||||
else { // SDL
|
||||
audio_output = &audio_output_sdl;
|
||||
audio_deinit = &audio_deinit_sdl;
|
||||
}
|
||||
}
|
||||
|
||||
void audio_init() {
|
||||
|
@ -268,17 +270,16 @@ void audio_init() {
|
|||
channels = conf.audio_stereo ? 2 : 1;
|
||||
memset(audiobuf, 0, sizeof(audiobuf));
|
||||
|
||||
#ifdef _MINGW
|
||||
conf.audio_api = 0; // Set SDL audio for MinGW
|
||||
#endif
|
||||
|
||||
audio_set_funcs();
|
||||
|
||||
if (conf.audio_api == 0) { audio_init_sdl(); }
|
||||
#ifdef _LIBAO
|
||||
else if (conf.audio_api == 1) { audio_init_ao(); }
|
||||
#endif
|
||||
#ifdef _JACK
|
||||
else if (conf.audio_api == 2) { audio_init_jack(); }
|
||||
#endif
|
||||
else { conf.audio_api = 0; audio_init_sdl(); }
|
||||
|
||||
paused = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue