GTK+: Strip out extra sound code.

No more Stereo, 16-bit or Reverse options.
This commit is contained in:
Brandon Wright 2019-02-06 19:41:33 -06:00
parent d8579ff9cb
commit 5b4ca50792
15 changed files with 320 additions and 380 deletions

View File

@ -285,9 +285,6 @@ int Snes9xConfig::save_config_file ()
outbool (cf, z"DynamicRateControl", Settings.DynamicRateControl); outbool (cf, z"DynamicRateControl", Settings.DynamicRateControl);
cf.SetInt (z"DynamicRateControlLimit", Settings.DynamicRateLimit); cf.SetInt (z"DynamicRateControlLimit", Settings.DynamicRateLimit);
outbool (cf, z"AutomaticInputRate", auto_input_rate, "Guess input rate by asking the monitor what its refresh rate is"); outbool (cf, z"AutomaticInputRate", auto_input_rate, "Guess input rate by asking the monitor what its refresh rate is");
outbool (cf, z"16bit", Settings.SixteenBitSound);
outbool (cf, z"Stereo", Settings.Stereo);
outbool (cf, z"ReverseStereo", Settings.ReverseStereo);
cf.SetInt (z"PlaybackRate", gui_config->sound_playback_rate, "1: 8000Hz, 2: 11025Hz, 3: 16000Hz, 4: 22050Hz, 5: 32000Hz, 6: 44100Hz, 7: 48000Hz"); cf.SetInt (z"PlaybackRate", gui_config->sound_playback_rate, "1: 8000Hz, 2: 11025Hz, 3: 16000Hz, 4: 22050Hz, 5: 32000Hz, 6: 44100Hz, 7: 48000Hz");
#undef z #undef z
@ -517,9 +514,6 @@ int Snes9xConfig::load_config_file ()
inbool (z"DynamicRateControl", Settings.DynamicRateControl); inbool (z"DynamicRateControl", Settings.DynamicRateControl);
inint (z"DynamicRateControlLimit", Settings.DynamicRateLimit); inint (z"DynamicRateControlLimit", Settings.DynamicRateLimit);
inbool (z"AutomaticInputRate", auto_input_rate); inbool (z"AutomaticInputRate", auto_input_rate);
inbool (z"16bit", Settings.SixteenBitSound);
inbool (z"Stereo", Settings.Stereo);
inbool (z"ReverseStereo", Settings.ReverseStereo);
inint (z"PlaybackRate", gui_config->sound_playback_rate); inint (z"PlaybackRate", gui_config->sound_playback_rate);
#undef z #undef z

View File

@ -633,7 +633,6 @@ Snes9xPreferences::move_settings_to_dialog ()
set_combo ("default_esc_behavior", config->default_esc_behavior); set_combo ("default_esc_behavior", config->default_esc_behavior);
set_check ("prevent_screensaver", config->prevent_screensaver); set_check ("prevent_screensaver", config->prevent_screensaver);
set_check ("force_inverted_byte_order", config->force_inverted_byte_order); set_check ("force_inverted_byte_order", config->force_inverted_byte_order);
set_check ("stereo_check", Settings.Stereo);
set_combo ("playback_combo", 7 - config->sound_playback_rate); set_combo ("playback_combo", 7 - config->sound_playback_rate);
set_combo ("hw_accel", combo_value (config->hw_accel)); set_combo ("hw_accel", combo_value (config->hw_accel));
set_check ("pause_emulation_on_switch", config->pause_emulation_on_switch); set_check ("pause_emulation_on_switch", config->pause_emulation_on_switch);
@ -748,7 +747,6 @@ Snes9xPreferences::get_settings_from_dialog ()
if ((config->sound_driver != get_combo ("sound_driver")) || if ((config->sound_driver != get_combo ("sound_driver")) ||
(config->mute_sound != get_check ("mute_sound_check")) || (config->mute_sound != get_check ("mute_sound_check")) ||
(config->sound_buffer_size != (int) get_spin ("sound_buffer_size")) || (config->sound_buffer_size != (int) get_spin ("sound_buffer_size")) ||
(Settings.Stereo != get_check ("stereo_check")) ||
(config->sound_playback_rate != (7 - (get_combo ("playback_combo")))) || (config->sound_playback_rate != (7 - (get_combo ("playback_combo")))) ||
(config->sound_input_rate != get_slider ("sound_input_rate")) || (config->sound_input_rate != get_slider ("sound_input_rate")) ||
(config->auto_input_rate != get_check ("auto_input_rate")) || (config->auto_input_rate != get_check ("auto_input_rate")) ||
@ -801,7 +799,6 @@ Snes9xPreferences::get_settings_from_dialog ()
Settings.UpAndDown = get_check ("upanddown"); Settings.UpAndDown = get_check ("upanddown");
Settings.SuperFXClockMultiplier = get_spin ("superfx_multiplier"); Settings.SuperFXClockMultiplier = get_spin ("superfx_multiplier");
config->sound_driver = get_combo ("sound_driver"); config->sound_driver = get_combo ("sound_driver");
Settings.Stereo = get_check ("stereo_check");
config->sound_playback_rate = 7 - (get_combo ("playback_combo")); config->sound_playback_rate = 7 - (get_combo ("playback_combo"));
config->sound_buffer_size = get_spin ("sound_buffer_size"); config->sound_buffer_size = get_spin ("sound_buffer_size");
config->sound_input_rate = get_slider ("sound_input_rate"); config->sound_input_rate = get_slider ("sound_input_rate");

View File

@ -12,7 +12,9 @@
class S9xSoundDriver class S9xSoundDriver
{ {
public: public:
virtual ~S9xSoundDriver () {} virtual ~S9xSoundDriver()
{
}
virtual void init() = 0; virtual void init() = 0;
virtual void terminate() = 0; virtual void terminate() = 0;
virtual bool open_device() = 0; virtual bool open_device() = 0;
@ -20,5 +22,4 @@ class S9xSoundDriver
virtual void stop() = 0; virtual void stop() = 0;
}; };
#endif /* __GTK_SOUND_DRIVER_H */ #endif /* __GTK_SOUND_DRIVER_H */

View File

@ -4,15 +4,14 @@
For further information, consult the LICENSE file in the root directory. For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/ \*****************************************************************************/
#include "gtk_s9x.h"
#include "gtk_sound_driver_alsa.h" #include "gtk_sound_driver_alsa.h"
#include "gtk_s9x.h"
#include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <fcntl.h>
static void static void alsa_samples_available(void *data)
alsa_samples_available (void *data)
{ {
((S9xAlsaSoundDriver *)data)->samples_available(); ((S9xAlsaSoundDriver *)data)->samples_available();
} }
@ -24,13 +23,11 @@ S9xAlsaSoundDriver::S9xAlsaSoundDriver ()
sound_buffer_size = 0; sound_buffer_size = 0;
} }
void void S9xAlsaSoundDriver::init()
S9xAlsaSoundDriver::init ()
{ {
} }
void void S9xAlsaSoundDriver::terminate()
S9xAlsaSoundDriver::terminate ()
{ {
stop(); stop();
@ -50,13 +47,11 @@ S9xAlsaSoundDriver::terminate ()
} }
} }
void void S9xAlsaSoundDriver::start()
S9xAlsaSoundDriver::start ()
{ {
} }
void void S9xAlsaSoundDriver::stop()
S9xAlsaSoundDriver::stop ()
{ {
} }
@ -84,9 +79,7 @@ bool S9xAlsaSoundDriver::open_device()
goto fail; goto fail;
} }
printf (" --> (%s, %s, %dhz, %d ms)...\n", printf(" --> (16-bit Stereo, %dhz, %d ms)...\n",
"16-bit",
"Stereo",
Settings.SoundPlaybackRate, Settings.SoundPlaybackRate,
gui_config->sound_buffer_size); gui_config->sound_buffer_size);
@ -164,8 +157,7 @@ fail:
return false; return false;
} }
void void S9xAlsaSoundDriver::samples_available()
S9xAlsaSoundDriver::samples_available ()
{ {
snd_pcm_sframes_t frames_written, frames; snd_pcm_sframes_t frames_written, frames;
int bytes; int bytes;

View File

@ -4,16 +4,15 @@
For further information, consult the LICENSE file in the root directory. For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/ \*****************************************************************************/
#include "gtk_s9x.h"
#include "gtk_sound_driver_oss.h" #include "gtk_sound_driver_oss.h"
#include "gtk_s9x.h"
#include <sys/soundcard.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/time.h>
static void static void oss_samples_available(void *data)
oss_samples_available (void *data)
{ {
((S9xOSSSoundDriver *)data)->samples_available(); ((S9xOSSSoundDriver *)data)->samples_available();
} }
@ -25,13 +24,11 @@ S9xOSSSoundDriver::S9xOSSSoundDriver ()
sound_buffer_size = 0; sound_buffer_size = 0;
} }
void void S9xOSSSoundDriver::init()
S9xOSSSoundDriver::init ()
{ {
} }
void void S9xOSSSoundDriver::terminate()
S9xOSSSoundDriver::terminate ()
{ {
stop(); stop();
@ -49,13 +46,11 @@ S9xOSSSoundDriver::terminate ()
} }
} }
void void S9xOSSSoundDriver::start()
S9xOSSSoundDriver::start ()
{ {
} }
void void S9xOSSSoundDriver::stop()
S9xOSSSoundDriver::stop ()
{ {
} }
@ -102,7 +97,6 @@ bool S9xOSSSoundDriver::open_device()
printf("OK\n"); printf("OK\n");
printf(" --> (Format: 16-bit)..."); printf(" --> (Format: 16-bit)...");
temp = AFMT_S16_LE; temp = AFMT_S16_LE;
@ -156,8 +150,7 @@ fail:
return false; return false;
} }
void void S9xOSSSoundDriver::samples_available()
S9xOSSSoundDriver::samples_available ()
{ {
audio_buf_info info; audio_buf_info info;
int samples_to_write; int samples_to_write;

View File

@ -28,6 +28,4 @@ class S9xOSSSoundDriver : public S9xSoundDriver
int output_buffer_size; int output_buffer_size;
}; };
#endif /* __GTK_SOUND_DRIVER_OSS_H */ #endif /* __GTK_SOUND_DRIVER_OSS_H */

View File

@ -4,17 +4,15 @@
For further information, consult the LICENSE file in the root directory. For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/ \*****************************************************************************/
#include "gtk_s9x.h"
#include "gtk_sound_driver_portaudio.h" #include "gtk_sound_driver_portaudio.h"
#include "gtk_s9x.h"
static inline int static inline int frames_to_bytes(int frames)
frames_to_bytes (int frames)
{ {
return frames * 4; return frames * 4;
} }
static void static void port_audio_samples_available_callback(void *data)
port_audio_samples_available_callback (void *data)
{ {
((S9xPortAudioSoundDriver *)data)->samples_available(); ((S9xPortAudioSoundDriver *)data)->samples_available();
} }
@ -26,8 +24,7 @@ S9xPortAudioSoundDriver::S9xPortAudioSoundDriver()
sound_buffer_size = 0; sound_buffer_size = 0;
} }
void void S9xPortAudioSoundDriver::init()
S9xPortAudioSoundDriver::init ()
{ {
PaError err; PaError err;
@ -39,8 +36,7 @@ S9xPortAudioSoundDriver::init ()
Pa_GetErrorText(err)); Pa_GetErrorText(err));
} }
void void S9xPortAudioSoundDriver::terminate()
S9xPortAudioSoundDriver::terminate ()
{ {
stop(); stop();
@ -55,8 +51,7 @@ S9xPortAudioSoundDriver::terminate ()
} }
} }
void void S9xPortAudioSoundDriver::start()
S9xPortAudioSoundDriver::start ()
{ {
PaError err; PaError err;
@ -74,8 +69,7 @@ S9xPortAudioSoundDriver::start ()
} }
} }
void void S9xPortAudioSoundDriver::stop()
S9xPortAudioSoundDriver::stop ()
{ {
if (audio_stream != NULL) if (audio_stream != NULL)
{ {
@ -181,8 +175,7 @@ bool S9xPortAudioSoundDriver::open_device()
return true; return true;
} }
void void S9xPortAudioSoundDriver::samples_available()
S9xPortAudioSoundDriver::samples_available ()
{ {
int frames; int frames;
int bytes; int bytes;

View File

@ -7,8 +7,8 @@
#ifndef __GTK_SOUND_DRIVER_PORTAUDIO_H #ifndef __GTK_SOUND_DRIVER_PORTAUDIO_H
#define __GTK_SOUND_DRIVER_PORTAUDIO_H #define __GTK_SOUND_DRIVER_PORTAUDIO_H
#include <portaudio.h>
#include <errno.h> #include <errno.h>
#include <portaudio.h>
#include "gtk_sound.h" #include "gtk_sound.h"
#include "gtk_sound_driver.h" #include "gtk_sound_driver.h"
@ -31,5 +31,4 @@ class S9xPortAudioSoundDriver : public S9xSoundDriver
int output_buffer_size; int output_buffer_size;
}; };
#endif /* __GTK_SOUND_DRIVER_PORTAUDIO_H */ #endif /* __GTK_SOUND_DRIVER_PORTAUDIO_H */

View File

@ -4,12 +4,12 @@
For further information, consult the LICENSE file in the root directory. For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/ \*****************************************************************************/
#include "gtk_s9x.h"
#include "gtk_sound_driver_pulse.h" #include "gtk_sound_driver_pulse.h"
#include "gtk_s9x.h"
#include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/time.h> #include <sys/time.h>
#include <fcntl.h>
static void pulse_samples_available(void *data) static void pulse_samples_available(void *data)
{ {
@ -125,10 +125,8 @@ bool S9xPulseSoundDriver::open_device()
printf("PulseAudio sound driver initializing...\n"); printf("PulseAudio sound driver initializing...\n");
printf(" --> (%dhz, %s %s, %dms)...", printf(" --> (%dhz, 16-bit Stereo, %dms)...",
Settings.SoundPlaybackRate, Settings.SoundPlaybackRate,
"16-bit",
"Stereo",
gui_config->sound_buffer_size); gui_config->sound_buffer_size);
fflush(stdout); fflush(stdout);

View File

@ -31,7 +31,6 @@ class S9xPulseSoundDriver : public S9xSoundDriver
private: private:
int buffer_size; int buffer_size;
}; };
#endif /* __GTK_SOUND_DRIVER_PULSE_H */ #endif /* __GTK_SOUND_DRIVER_PULSE_H */

View File

@ -4,28 +4,25 @@
For further information, consult the LICENSE file in the root directory. For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/ \*****************************************************************************/
#include "gtk_s9x.h"
#include "gtk_sound_driver_sdl.h" #include "gtk_sound_driver_sdl.h"
#include "gtk_s9x.h"
static void static void sdl_audio_callback(void *userdata, Uint8 *stream, int len)
sdl_audio_callback (void *userdata, Uint8 *stream, int len)
{ {
((S9xSDLSoundDriver *)userdata)->mix((unsigned char *)stream, len); ((S9xSDLSoundDriver *)userdata)->mix((unsigned char *)stream, len);
} }
static void static void samples_available(void *data)
samples_available (void *data)
{ {
SDL_LockAudio(); SDL_LockAudio();
S9xFinalizeSamples(); S9xFinalizeSamples();
SDL_UnlockAudio(); SDL_UnlockAudio();
} }
void void S9xSDLSoundDriver::mix(unsigned char *output, int bytes)
S9xSDLSoundDriver::mix (unsigned char *output, int bytes)
{ {
SDL_LockAudio(); SDL_LockAudio();
S9xMixSamples (output, bytes >> (Settings.SixteenBitSound ? 1 : 0)); S9xMixSamples(output, bytes >> 1);
SDL_UnlockAudio(); SDL_UnlockAudio();
} }
@ -34,15 +31,13 @@ S9xSDLSoundDriver::S9xSDLSoundDriver ()
audiospec = NULL; audiospec = NULL;
} }
void void S9xSDLSoundDriver::init()
S9xSDLSoundDriver::init ()
{ {
SDL_InitSubSystem(SDL_INIT_AUDIO); SDL_InitSubSystem(SDL_INIT_AUDIO);
stop(); stop();
} }
void void S9xSDLSoundDriver::terminate()
S9xSDLSoundDriver::terminate ()
{ {
stop(); stop();
@ -56,8 +51,7 @@ S9xSDLSoundDriver::terminate ()
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
} }
void void S9xSDLSoundDriver::start()
S9xSDLSoundDriver::start ()
{ {
if (!gui_config->mute_sound) if (!gui_config->mute_sound)
{ {
@ -68,8 +62,7 @@ S9xSDLSoundDriver::start ()
} }
} }
void void S9xSDLSoundDriver::stop()
S9xSDLSoundDriver::stop ()
{ {
if (audiospec) if (audiospec)
{ {
@ -82,8 +75,8 @@ bool S9xSDLSoundDriver::open_device()
audiospec = (SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec)); audiospec = (SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
audiospec->freq = Settings.SoundPlaybackRate; audiospec->freq = Settings.SoundPlaybackRate;
audiospec->channels = Settings.Stereo ? 2 : 1; audiospec->channels = 2;
audiospec->format = Settings.SixteenBitSound ? AUDIO_S16SYS : AUDIO_U8; audiospec->format = AUDIO_S16SYS;
audiospec->samples = (gui_config->sound_buffer_size * audiospec->freq / 1000) >> 1; audiospec->samples = (gui_config->sound_buffer_size * audiospec->freq / 1000) >> 1;
audiospec->callback = sdl_audio_callback; audiospec->callback = sdl_audio_callback;
audiospec->userdata = this; audiospec->userdata = this;

View File

@ -27,5 +27,4 @@ class S9xSDLSoundDriver : public S9xSoundDriver
SDL_AudioSpec *audiospec; SDL_AudioSpec *audiospec;
}; };
#endif /* __GTK_SOUND_DRIVER_SDL_H */ #endif /* __GTK_SOUND_DRIVER_SDL_H */

View File

@ -4218,22 +4218,6 @@
<property name="position">4</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="stereo_check">
<property name="label" translatable="yes">Stereo</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Output two channels, left and right</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child> <child>
<object class="GtkTable" id="table7"> <object class="GtkTable" id="table7">
<property name="visible">True</property> <property name="visible">True</property>
@ -4451,7 +4435,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">6</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
</object> </object>