Move formerly Gtk sound drivers to common directory.

This commit is contained in:
BearOso 2023-06-07 16:06:55 -05:00
parent 8c5b6d012e
commit 81efc82f88
13 changed files with 62 additions and 47 deletions

View File

@ -4,8 +4,8 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __S9X_SOUND_DRIVER_H
#define __S9X_SOUND_DRIVER_H
#ifndef __S9X_SOUND_DRIVER_HPP
#define __S9X_SOUND_DRIVER_HPP
#include <cstdint>
#include <tuple>
@ -26,4 +26,4 @@ class S9xSoundDriver
virtual void stop() = 0;
};
#endif /* __GTK_SOUND_DRIVER_H */
#endif /* __S9X_SOUND_DRIVER_HPP */

View File

@ -4,7 +4,7 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#include "gtk_sound_driver_alsa.h"
#include "s9x_sound_driver_alsa.hpp"
#include <fcntl.h>
#include <sys/ioctl.h>

View File

@ -4,11 +4,10 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __GTK_SOUND_DRIVER_ALSA_H
#define __GTK_SOUND_DRIVER_ALSA_H
#ifndef __S9X_SOUND_DRIVER_ALSA_HPP
#define __S9X_SOUND_DRIVER_ALSA_HPP
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "s9x_sound_driver.hpp"
#include "alsa/asoundlib.h"
class S9xAlsaSoundDriver : public S9xSoundDriver
@ -29,4 +28,4 @@ class S9xAlsaSoundDriver : public S9xSoundDriver
int output_buffer_size_bytes;
};
#endif /* __GTK_SOUND_DRIVER_ALSA_H */
#endif /* __S9X_SOUND_DRIVER_ALSA_HPP */

View File

@ -4,13 +4,29 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#include "gtk_sound_driver_oss.h"
#include "s9x_sound_driver_oss.hpp"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/time.h>
#include <unistd.h>
#include <cstdio>
static inline int log2(int num)
{
int power;
if (num < 1)
return 0;
for (power = 0; num > 1; power++)
{
num >>= 1;
}
return power;
}
S9xOSSSoundDriver::S9xOSSSoundDriver()
{
@ -106,7 +122,7 @@ bool S9xOSSSoundDriver::open_device(int playback_rate, int buffer_size_ms)
/* OSS requires a power-of-two buffer size, first 16 bits are the number
* of fragments to generate, second 16 are the respective power-of-two. */
temp = (4 << 16) | (S9xSoundBase2log(output_buffer_size_bytes / 4));
temp = (4 << 16) | (log2(output_buffer_size_bytes / 4));
if (ioctl(filedes, SNDCTL_DSP_SETFRAGMENT, &temp) < 0)
goto close_fail;

View File

@ -4,11 +4,10 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __GTK_SOUND_DRIVER_OSS_H
#define __GTK_SOUND_DRIVER_OSS_H
#ifndef __S9X_SOUND_DRIVER_OSS_HPP
#define __S9X_SOUND_DRIVER_OSS_HPP
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "s9x_sound_driver.hpp"
class S9xOSSSoundDriver : public S9xSoundDriver
{
@ -28,4 +27,4 @@ class S9xOSSSoundDriver : public S9xSoundDriver
int output_buffer_size_bytes;
};
#endif /* __GTK_SOUND_DRIVER_OSS_H */
#endif /* __S9X_SOUND_DRIVER_OSS_HPP */

View File

@ -4,8 +4,11 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#include "gtk_sound_driver_portaudio.h"
#include "s9x_sound_driver_portaudio.hpp"
#include <cstring>
#include <cstdio>
#include <cstdint>
#include <vector>
S9xPortAudioSoundDriver::S9xPortAudioSoundDriver()
{

View File

@ -4,14 +4,13 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __GTK_SOUND_DRIVER_PORTAUDIO_H
#define __GTK_SOUND_DRIVER_PORTAUDIO_H
#ifndef __S9X_SOUND_DRIVER_PORTAUDIO_HPP
#define __S9X_SOUND_DRIVER_PORTAUDIO_HPP
#include <errno.h>
#include <portaudio.h>
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "s9x_sound_driver.hpp"
class S9xPortAudioSoundDriver : public S9xSoundDriver
{
@ -32,4 +31,4 @@ class S9xPortAudioSoundDriver : public S9xSoundDriver
int output_buffer_size;
};
#endif /* __GTK_SOUND_DRIVER_PORTAUDIO_H */
#endif /* __S9X_SOUND_DRIVER_PORTAUDIO_HPP */

View File

@ -4,9 +4,10 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#include "gtk_sound_driver_pulse.h"
#include "s9x_sound_driver_pulse.hpp"
#include <cstring>
#include <cstdio>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>

View File

@ -4,11 +4,10 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __GTK_SOUND_DRIVER_PULSE_H
#define __GTK_SOUND_DRIVER_PULSE_H
#ifndef __S9X_SOUND_DRIVER_PULSE_HPP
#define __S9X_SOUND_DRIVER_PULSE_HPP
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "s9x_sound_driver.hpp"
#include "pulse/pulseaudio.h"
class S9xPulseSoundDriver : public S9xSoundDriver
@ -35,4 +34,4 @@ class S9xPulseSoundDriver : public S9xSoundDriver
int buffer_size;
};
#endif /* __GTK_SOUND_DRIVER_PULSE_H */
#endif /* __S9X_SOUND_DRIVER_PULSE_HPP */

View File

@ -4,7 +4,7 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#include "gtk_sound_driver_sdl.h"
#include "s9x_sound_driver_sdl.hpp"
#include "SDL_audio.h"
void S9xSDLSoundDriver::write_samples(int16_t *data, int samples)

View File

@ -4,16 +4,15 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef __GTK_SOUND_DRIVER_SDL_H
#define __GTK_SOUND_DRIVER_SDL_H
#ifndef __S9X_SOUND_DRIVER_SDL_HPP
#define __S9X_SOUND_DRIVER_SDL_HPP
#include "SDL.h"
// SDL.h may include altivec.h which redefines vector and bool
#undef vector
#undef bool
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "s9x_sound_driver.hpp"
#include "../../apu/resampler.h"
#include <mutex>
@ -41,4 +40,4 @@ class S9xSDLSoundDriver : public S9xSoundDriver
int16_t temp[512];
};
#endif /* __GTK_SOUND_DRIVER_SDL_H */
#endif /* __S9X_SOUND_DRIVER_SDL_HPP */

View File

@ -175,7 +175,7 @@ endif()
if(USE_PULSEAUDIO)
pkg_check_modules(PULSEAUDIO REQUIRED libpulse)
list(APPEND DEFINES "USE_PULSEAUDIO")
list(APPEND SOURCES src/gtk_sound_driver_pulse.cpp)
list(APPEND SOURCES ../common/audio/s9x_sound_driver_pulse.cpp)
list(APPEND ARGS ${PULSEAUDIO_CFLAGS})
list(APPEND LIBS ${PULSEAUDIO_LIBRARIES})
endif()
@ -183,7 +183,7 @@ endif()
if(USE_PORTAUDIO)
pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
list(APPEND DEFINES "USE_PORTAUDIO")
list(APPEND SOURCES src/gtk_sound_driver_portaudio.cpp)
list(APPEND SOURCES ../common/audio/s9x_sound_driver_portaudio.cpp)
list(APPEND ARGS ${PORTAUDIO_CFLAGS})
list(APPEND LIBS ${PORTAUDIO_LIBRARIES})
endif()
@ -191,7 +191,7 @@ endif()
if(USE_ALSA)
pkg_check_modules(ALSA REQUIRED alsa)
list(APPEND DEFINES "USE_ALSA")
list(APPEND SOURCES src/gtk_sound_driver_alsa.cpp)
list(APPEND SOURCES ../common/audio/s9x_sound_driver_alsa.cpp)
list(APPEND ARGS ${ALSA_CFLAGS})
list(APPEND LIBS ${ALSA_LIBRARIES})
endif()
@ -199,7 +199,7 @@ endif()
if(USE_OSS)
CHECK_INCLUDE_FILE("sys/soundcard.h" OSS)
if(OSS)
list(APPEND SOURCES src/gtk_sound_driver_oss.cpp)
list(APPEND SOURCES ../common/audio/s9x_sound_driver_oss.cpp)
list(APPEND DEFINES "USE_OSS")
endif()
endif()
@ -238,7 +238,7 @@ if(DANGEROUS_HACKS)
endif()
list(APPEND SOURCES
src/gtk_sound_driver.h
../common/audio/s9x_sound_driver.hpp
../filter/2xsai.cpp
../filter/2xsai.h
../filter/epx.cpp
@ -279,8 +279,8 @@ list(APPEND SOURCES
../filter/snes_ntsc_impl.h
../filter/snes_ntsc.c
src/gtk_compat.h
src/gtk_sound_driver_sdl.h
src/gtk_sound_driver_sdl.cpp
../common/audio/s9x_sound_driver_sdl.hpp
../common/audio/s9x_sound_driver_sdl.cpp
../fxinst.cpp
../fxemu.cpp
../fxdbg.cpp

View File

@ -9,22 +9,22 @@
#include "gtk_s9x.h"
#include "gtk_sound.h"
#include "gtk_sound_driver.h"
#include "common/audio/s9x_sound_driver.hpp"
#include "snes9x.h"
#include "apu/apu.h"
#ifdef USE_PORTAUDIO
#include "gtk_sound_driver_portaudio.h"
#include "common/audio/s9x_sound_driver_portaudio.hpp"
#endif
#ifdef USE_OSS
#include "gtk_sound_driver_oss.h"
#include "common/audio/s9x_sound_driver_oss.hpp"
#endif
#include "gtk_sound_driver_sdl.h"
#include "common/audio/s9x_sound_driver_sdl.hpp"
#ifdef USE_ALSA
#include "gtk_sound_driver_alsa.h"
#include "common/audio/s9x_sound_driver_alsa.hpp"
#endif
#ifdef USE_PULSEAUDIO
#include "gtk_sound_driver_pulse.h"
#include "common/audio/s9x_sound_driver_pulse.hpp"
#endif
static int playback_rates[8] =