mirror of https://github.com/snes9xgit/snes9x.git
Gtk: Make sound driver check a little simpler.
This commit is contained in:
parent
ebe96e91de
commit
da4bd2a018
|
@ -127,6 +127,7 @@ class Snes9xConfig
|
||||||
bool netplay_server_up;
|
bool netplay_server_up;
|
||||||
|
|
||||||
/* Operational */
|
/* Operational */
|
||||||
|
std::vector<std::string> sound_drivers;
|
||||||
int sound_driver;
|
int sound_driver;
|
||||||
bool mute_sound;
|
bool mute_sound;
|
||||||
bool mute_sound_turbo;
|
bool mute_sound_turbo;
|
||||||
|
|
|
@ -151,19 +151,10 @@ Snes9xPreferences::Snes9xPreferences(Snes9xConfig *config)
|
||||||
combo_box_append("hw_accel",
|
combo_box_append("hw_accel",
|
||||||
_("XVideo - Use hardware video blitter"));
|
_("XVideo - Use hardware video blitter"));
|
||||||
|
|
||||||
#ifdef USE_PORTAUDIO
|
for (auto &name : config->sound_drivers)
|
||||||
combo_box_append("sound_driver", _("PortAudio"));
|
{
|
||||||
#endif
|
combo_box_append("sound_driver", name.c_str());
|
||||||
#ifdef USE_OSS
|
}
|
||||||
combo_box_append("sound_driver", _("Open Sound System"));
|
|
||||||
#endif
|
|
||||||
combo_box_append("sound_driver", _("SDL"));
|
|
||||||
#ifdef USE_ALSA
|
|
||||||
combo_box_append("sound_driver", _("ALSA"));
|
|
||||||
#endif
|
|
||||||
#ifdef USE_PULSEAUDIO
|
|
||||||
combo_box_append("sound_driver", _("PulseAudio"));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Snes9xPreferences::~Snes9xPreferences ()
|
Snes9xPreferences::~Snes9xPreferences ()
|
||||||
|
@ -463,24 +454,6 @@ void Snes9xPreferences::move_settings_to_dialog()
|
||||||
set_combo ("splash_background", config->splash_image);
|
set_combo ("splash_background", config->splash_image);
|
||||||
set_check ("force_enable_icons", config->enable_icons);
|
set_check ("force_enable_icons", config->enable_icons);
|
||||||
|
|
||||||
int num_sound_drivers = 0;
|
|
||||||
#ifdef USE_PORTAUDIO
|
|
||||||
num_sound_drivers++;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_OSS
|
|
||||||
num_sound_drivers++;
|
|
||||||
#endif
|
|
||||||
num_sound_drivers++; // SDL is automatically there.
|
|
||||||
#ifdef USE_ALSA
|
|
||||||
num_sound_drivers++;
|
|
||||||
#endif
|
|
||||||
#ifdef USE_PULSEAUDIO
|
|
||||||
num_sound_drivers++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (config->sound_driver >= num_sound_drivers)
|
|
||||||
config->sound_driver = 0;
|
|
||||||
|
|
||||||
set_combo ("sound_driver", config->sound_driver);
|
set_combo ("sound_driver", config->sound_driver);
|
||||||
|
|
||||||
show_widget("ntsc_alignment", config->scale_method == FILTER_NTSC);
|
show_widget("ntsc_alignment", config->scale_method == FILTER_NTSC);
|
||||||
|
@ -956,21 +929,20 @@ void Snes9xPreferences::clear_binding(const char *name)
|
||||||
|
|
||||||
void Snes9xPreferences::bindings_to_dialog(int joypad)
|
void Snes9xPreferences::bindings_to_dialog(int joypad)
|
||||||
{
|
{
|
||||||
char name[256];
|
|
||||||
Binding *bindings = (Binding *)&pad[joypad].data;
|
Binding *bindings = (Binding *)&pad[joypad].data;
|
||||||
|
|
||||||
set_combo("control_combo", joypad);
|
set_combo("control_combo", joypad);
|
||||||
|
|
||||||
for (int i = 0; i < NUM_JOYPAD_LINKS; i++)
|
for (int i = 0; i < NUM_JOYPAD_LINKS; i++)
|
||||||
{
|
{
|
||||||
bindings[i].to_string(name);
|
set_entry_text(b_links[i].button_name, bindings[i].as_string().c_str());
|
||||||
set_entry_text(b_links[i].button_name, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = NUM_JOYPAD_LINKS; b_links[i].button_name; i++)
|
auto shortcut_names = &b_links[NUM_JOYPAD_LINKS];
|
||||||
|
|
||||||
|
for (int i = 0; shortcut_names[i].button_name; i++)
|
||||||
{
|
{
|
||||||
shortcut[i - NUM_JOYPAD_LINKS].to_string(name);
|
set_entry_text(shortcut_names[i].button_name, shortcut[i].as_string().c_str());
|
||||||
set_entry_text(b_links[i].button_name, name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ int main(int argc, char *argv[])
|
||||||
S9xLoadConfigFiles(argv, argc);
|
S9xLoadConfigFiles(argv, argc);
|
||||||
|
|
||||||
gui_config = new Snes9xConfig();
|
gui_config = new Snes9xConfig();
|
||||||
|
gui_config->sound_drivers = S9xGetSoundDriverNames();
|
||||||
|
|
||||||
S9xInitInputDevices();
|
S9xInitInputDevices();
|
||||||
|
|
||||||
|
|
|
@ -54,75 +54,57 @@ int S9xSoundPowerof2(int num)
|
||||||
return (1 << num);
|
return (1 << num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> S9xGetSoundDriverNames()
|
||||||
|
{
|
||||||
|
std::vector<std::string> names;
|
||||||
|
|
||||||
|
#ifdef USE_PORTAUDIO
|
||||||
|
names.push_back("PortAudio");
|
||||||
|
#endif
|
||||||
|
#ifdef USE_OSS
|
||||||
|
names.push_back("OSS");
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ALSA
|
||||||
|
names.push_back("ALSA");
|
||||||
|
#endif
|
||||||
|
#ifdef USE_PULSEAUDIO
|
||||||
|
names.push_back("PulseAudio");
|
||||||
|
#endif
|
||||||
|
names.push_back("SDL");
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
void S9xPortSoundInit()
|
void S9xPortSoundInit()
|
||||||
{
|
{
|
||||||
int pao_driver = 0;
|
if (gui_config->sound_driver >= (int)gui_config->sound_drivers.size())
|
||||||
int sdl_driver = 0;
|
|
||||||
int oss_driver = 0;
|
|
||||||
int alsa_driver = 0;
|
|
||||||
int pulse_driver = 0;
|
|
||||||
int max_driver = 0;
|
|
||||||
|
|
||||||
driver = NULL;
|
|
||||||
|
|
||||||
#ifdef USE_PORTAUDIO
|
|
||||||
sdl_driver++;
|
|
||||||
oss_driver++;
|
|
||||||
alsa_driver++;
|
|
||||||
pulse_driver++;
|
|
||||||
|
|
||||||
max_driver++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_OSS
|
|
||||||
sdl_driver++;
|
|
||||||
alsa_driver++;
|
|
||||||
pulse_driver++;
|
|
||||||
|
|
||||||
max_driver++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* SDL */
|
|
||||||
alsa_driver++;
|
|
||||||
pulse_driver++;
|
|
||||||
|
|
||||||
max_driver++;
|
|
||||||
|
|
||||||
#ifdef USE_ALSA
|
|
||||||
max_driver++;
|
|
||||||
pulse_driver++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_PULSEAUDIO
|
|
||||||
max_driver++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gui_config->sound_driver >= max_driver)
|
|
||||||
gui_config->sound_driver = 0;
|
gui_config->sound_driver = 0;
|
||||||
|
|
||||||
|
auto &name = gui_config->sound_drivers[gui_config->sound_driver];
|
||||||
|
|
||||||
#ifdef USE_PORTAUDIO
|
#ifdef USE_PORTAUDIO
|
||||||
if (gui_config->sound_driver == pao_driver)
|
if (name == "PortAudio")
|
||||||
driver = new S9xPortAudioSoundDriver();
|
driver = new S9xPortAudioSoundDriver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OSS
|
#ifdef USE_OSS
|
||||||
if (gui_config->sound_driver == oss_driver)
|
if (name == "OSS")
|
||||||
driver = new S9xOSSSoundDriver();
|
driver = new S9xOSSSoundDriver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gui_config->sound_driver == sdl_driver)
|
|
||||||
driver = new S9xSDLSoundDriver();
|
|
||||||
|
|
||||||
#ifdef USE_ALSA
|
#ifdef USE_ALSA
|
||||||
if (gui_config->sound_driver == alsa_driver)
|
if (name == "ALSA")
|
||||||
driver = new S9xAlsaSoundDriver();
|
driver = new S9xAlsaSoundDriver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_PULSEAUDIO
|
#ifdef USE_PULSEAUDIO
|
||||||
if (gui_config->sound_driver == pulse_driver)
|
if (name == "PulseAudio")
|
||||||
driver = new S9xPulseSoundDriver();
|
driver = new S9xPulseSoundDriver();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (name == "SDL")
|
||||||
|
driver = new S9xSDLSoundDriver();
|
||||||
|
|
||||||
if (driver != NULL)
|
if (driver != NULL)
|
||||||
{
|
{
|
||||||
driver->init();
|
driver->init();
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#ifndef __GTK_SOUND_H
|
#ifndef __GTK_SOUND_H
|
||||||
#define __GTK_SOUND_H
|
#define __GTK_SOUND_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
void S9xPortSoundInit();
|
void S9xPortSoundInit();
|
||||||
void S9xPortSoundDeinit();
|
void S9xPortSoundDeinit();
|
||||||
void S9xPortSoundReinit();
|
void S9xPortSoundReinit();
|
||||||
|
@ -15,5 +18,6 @@ void S9xSoundStop();
|
||||||
|
|
||||||
int S9xSoundBase2log(int num);
|
int S9xSoundBase2log(int num);
|
||||||
int S9xSoundPowerof2(int num);
|
int S9xSoundPowerof2(int num);
|
||||||
|
std::vector<std::string> S9xGetSoundDriverNames();
|
||||||
|
|
||||||
#endif /* __GTK_SOUND_H */
|
#endif /* __GTK_SOUND_H */
|
||||||
|
|
Loading…
Reference in New Issue