Skip to content
Snippets Groups Projects
Commit 00eb3c1f authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Allow controlling sound output types with a global.

parent 7c614b63
Branches
Tags
No related merge requests found
...@@ -111,6 +111,7 @@ enum { ...@@ -111,6 +111,7 @@ enum {
static int handle_type = SOUND_DEVICE_CLOSED; static int handle_type = SOUND_DEVICE_CLOSED;
static int handle_rc; static int handle_rc;
uint32_t xpbeep_sound_devices_enabled = XPBEEP_DEVICE_DEFAULT;
#ifdef WITH_PULSEAUDIO #ifdef WITH_PULSEAUDIO
struct pulseaudio_api_struct { struct pulseaudio_api_struct {
...@@ -402,6 +403,7 @@ xptone_open_locked(void) ...@@ -402,6 +403,7 @@ xptone_open_locked(void)
} }
#ifdef WITH_PULSEAUDIO #ifdef WITH_PULSEAUDIO
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_PULSEAUDIO) {
if (!pulseaudio_device_open_failed) { if (!pulseaudio_device_open_failed) {
if (pu_api == NULL) { if (pu_api == NULL) {
const char *libnames[] = {"pulse-simple", NULL}; const char *libnames[] = {"pulse-simple", NULL};
...@@ -441,9 +443,11 @@ xptone_open_locked(void) ...@@ -441,9 +443,11 @@ xptone_open_locked(void)
} }
} }
} }
}
#endif #endif
#ifdef WITH_PORTAUDIO #ifdef WITH_PORTAUDIO
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_PORTAUDIO) {
if (!portaudio_device_open_failed) { if (!portaudio_device_open_failed) {
if (pa_api == NULL) { if (pa_api == NULL) {
const char *libnames[] = {"portaudio", NULL}; const char *libnames[] = {"portaudio", NULL};
...@@ -509,9 +513,11 @@ xptone_open_locked(void) ...@@ -509,9 +513,11 @@ xptone_open_locked(void)
} }
} }
} }
}
#endif #endif
#ifdef WITH_SDL_AUDIO #ifdef WITH_SDL_AUDIO
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_SDL) {
if (!sdl_device_open_failed) { if (!sdl_device_open_failed) {
if (init_sdl_audio() == -1) { if (init_sdl_audio() == -1) {
sdl_device_open_failed = true; sdl_device_open_failed = true;
...@@ -538,9 +544,11 @@ xptone_open_locked(void) ...@@ -538,9 +544,11 @@ xptone_open_locked(void)
} }
} }
} }
}
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_WIN32) {
if (!sound_device_open_failed) { if (!sound_device_open_failed) {
w.wFormatTag = WAVE_FORMAT_PCM; w.wFormatTag = WAVE_FORMAT_PCM;
w.nChannels = 1; w.nChannels = 1;
...@@ -562,9 +570,11 @@ xptone_open_locked(void) ...@@ -562,9 +570,11 @@ xptone_open_locked(void)
return true; return true;
} }
} }
}
#endif #endif
#ifdef USE_ALSA_SOUND #ifdef USE_ALSA_SOUND
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_ALSA) {
if (!alsa_device_open_failed) { if (!alsa_device_open_failed) {
if (alsa_api == NULL) { if (alsa_api == NULL) {
const char *libnames[] = {"asound", NULL}; const char *libnames[] = {"asound", NULL};
...@@ -620,9 +630,11 @@ xptone_open_locked(void) ...@@ -620,9 +630,11 @@ xptone_open_locked(void)
} }
} }
} }
}
#endif #endif
#ifdef AFMT_U8 #ifdef AFMT_U8
if (xpbeep_sound_devices_enabled & XPBEEP_DEVICE_OSS) {
if (!sound_device_open_failed) { if (!sound_device_open_failed) {
if ((dsp = open("/dev/dsp", O_WRONLY, 0)) < 0) { if ((dsp = open("/dev/dsp", O_WRONLY, 0)) < 0) {
sound_device_open_failed = true; sound_device_open_failed = true;
...@@ -651,6 +663,7 @@ xptone_open_locked(void) ...@@ -651,6 +663,7 @@ xptone_open_locked(void)
handle_rc++; handle_rc++;
return true; return true;
} }
}
#endif #endif
return false; return false;
......
...@@ -30,6 +30,14 @@ enum WAVE_SHAPE { ...@@ -30,6 +30,14 @@ enum WAVE_SHAPE {
,WAVE_SHAPE_SINE_SAW_HARM ,WAVE_SHAPE_SINE_SAW_HARM
}; };
#define XPBEEP_DEVICE_WIN32 (1U<<0)
#define XPBEEP_DEVICE_ALSA (1U<<1)
#define XPBEEP_DEVICE_OSS (1U<<2)
#define XPBEEP_DEVICE_SDL (1U<<3)
#define XPBEEP_DEVICE_PORTAUDIO (1U<<4)
#define XPBEEP_DEVICE_PULSEAUDIO (1U<<5)
#define XPBEEP_DEVICE_DEFAULT (XPBEEP_DEVICE_WIN32 | XPBEEP_DEVICE_ALSA | XPBEEP_DEVICE_OSS | XPBEEP_DEVICE_PORTAUDIO | XPBEEP_DEVICE_PULSEAUDIO)
extern uint32_t xpbeep_sound_devices_enabled;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment