diff --git a/bochs/iodev/sound/es1370.cc b/bochs/iodev/sound/es1370.cc index e4b49a8c1..272a299f8 100644 --- a/bochs/iodev/sound/es1370.cc +++ b/bochs/iodev/sound/es1370.cc @@ -206,8 +206,13 @@ void bx_es1370_c::init(void) } BX_ES1370_THIS pci_base_address[0] = 0; - BX_ES1370_THIS soundmod = DEV_sound_init_module("default", BX_ES1370_THIS_PTR); - int ret = BX_ES1370_THIS soundmod->openwaveoutput(SIM->get_param_string(BXPN_ES1370_WAVEDEV)->getptr()); + char *wavedev = SIM->get_param_string(BXPN_ES1370_WAVEDEV)->getptr(); + if (!strcmp(wavedev, "sdl")) { + BX_ES1370_THIS soundmod = DEV_sound_init_module("sdl", BX_ES1370_THIS_PTR); + } else { + BX_ES1370_THIS soundmod = DEV_sound_init_module("default", BX_ES1370_THIS_PTR); + } + int ret = BX_ES1370_THIS soundmod->openwaveoutput(wavedev); if (ret != BX_SOUNDLOW_OK) { BX_ERROR(("could not open wave output device")); BX_ES1370_THIS s.dac_outputinit = 0; diff --git a/bochs/iodev/sound/sb16.cc b/bochs/iodev/sound/sb16.cc index 2b1886c8b..ff5ab86fa 100644 --- a/bochs/iodev/sound/sb16.cc +++ b/bochs/iodev/sound/sb16.cc @@ -301,10 +301,15 @@ void bx_sb16_c::init(void) BX_SB16_THIS wavemode = SIM->get_param_num("wavemode", base)->get(); BX_SB16_THIS dmatimer = SIM->get_param_num("dmatimer", base)->get(); BX_SB16_THIS loglevel = SIM->get_param_num("loglevel", base)->get(); + char *wavefile = SIM->get_param_string(BXPN_SB16_WAVEFILE)->getptr(); if ((BX_SB16_THIS wavemode == 1) || (BX_SB16_THIS midimode == 1)) { // let the output functions initialize - BX_SB16_OUTPUT = DEV_sound_init_module("default", BX_SB16_THISP); + if (!strcmp(wavefile, "sdl")) { + BX_SB16_OUTPUT = DEV_sound_init_module("sdl", BX_SB16_THISP); + } else { + BX_SB16_OUTPUT = DEV_sound_init_module("default", BX_SB16_THISP); + } if (BX_SB16_OUTPUT == NULL) { writelog(MIDILOG(2), "Couldn't initialize output devices. Output disabled."); @@ -316,7 +321,7 @@ void bx_sb16_c::init(void) DSP.dma.chunk = new Bit8u[BX_SOUNDLOW_WAVEPACKETSIZE]; DSP.dma.chunkindex = 0; if (BX_SB16_THIS wavemode == 1) { - int ret = BX_SB16_OUTPUT->openwaveoutput(SIM->get_param_string(BXPN_SB16_WAVEFILE)->getptr()); + int ret = BX_SB16_OUTPUT->openwaveoutput(wavefile); if (ret != BX_SOUNDLOW_OK) { writelog(WAVELOG(2), "Error: Could not open wave output device."); BX_SB16_THIS wavemode = 0; diff --git a/bochs/iodev/sound/soundlnx.h b/bochs/iodev/sound/soundlnx.h index 04a337e3f..b3365f8b5 100644 --- a/bochs/iodev/sound/soundlnx.h +++ b/bochs/iodev/sound/soundlnx.h @@ -38,6 +38,8 @@ public: bx_sound_linux_c(logfunctions *dev); virtual ~bx_sound_linux_c(); + virtual int get_type() {return BX_SOUNDLOW_LINUX;} + virtual int waveready(); virtual int midiready(); diff --git a/bochs/iodev/sound/soundmod.cc b/bochs/iodev/sound/soundmod.cc index 9d9fc0017..0bf2e31d4 100644 --- a/bochs/iodev/sound/soundmod.cc +++ b/bochs/iodev/sound/soundmod.cc @@ -33,10 +33,14 @@ #include "soundlnx.h" #include "soundosx.h" #include "soundwin.h" +//#include "soundsdl.h" #ifndef WIN32 #include #endif +#if BX_WITH_SDL +#include +#endif #define LOG_THIS theSoundModCtl-> @@ -68,6 +72,10 @@ void* bx_soundmod_ctl_c::init_module(const char *type, logfunctions *device) { if (!strcmp(type, "default")) { soundmod = new BX_SOUND_LOWLEVEL_C(device); +#if 0 + } else if (!strcmp(type, "sdl")) { + soundmod = new bx_sound_sdl_c(device); +#endif } else if (!strcmp(type, "dummy")) { soundmod = new bx_sound_lowlevel_c(device); } else { @@ -103,9 +111,15 @@ void beep_thread(void *indata) if ((++i % beep_bytes) == 0) level ^= 0x40; } while (j < beep_bufsize); soundmod->sendwavepacket(beep_bufsize, beep_buffer); + if (soundmod->get_type() == BX_SOUNDLOW_WIN) { #ifdef WIN32 - Sleep(100); + Sleep(100); #endif + } else if (soundmod->get_type() == BX_SOUNDLOW_SDL) { +#if BX_WITH_SDL + SDL_Delay(100); +#endif + } } soundmod->stopwaveplayback(); free(beep_buffer); diff --git a/bochs/iodev/sound/soundmod.h b/bochs/iodev/sound/soundmod.h index 8ec005049..bcdc2c125 100644 --- a/bochs/iodev/sound/soundmod.h +++ b/bochs/iodev/sound/soundmod.h @@ -29,6 +29,13 @@ #define BX_SOUNDLOW_OK 0 #define BX_SOUNDLOW_ERR 1 +// Lowlvel sound modules +#define BX_SOUNDLOW_DUMMY 0 +#define BX_SOUNDLOW_LINUX 1 +#define BX_SOUNDLOW_OSX 2 +#define BX_SOUNDLOW_WIN 3 +#define BX_SOUNDLOW_SDL 4 + typedef Bit32u (*sound_record_handler_t)(void *arg, Bit32u len); class bx_sound_lowlevel_c; @@ -59,6 +66,8 @@ public: bx_sound_lowlevel_c(logfunctions *dev); virtual ~bx_sound_lowlevel_c(); + virtual int get_type() {return BX_SOUNDLOW_DUMMY;} + virtual int waveready(); virtual int midiready(); diff --git a/bochs/iodev/sound/soundosx.h b/bochs/iodev/sound/soundosx.h index e82cb040f..9f3af8147 100644 --- a/bochs/iodev/sound/soundosx.h +++ b/bochs/iodev/sound/soundosx.h @@ -41,6 +41,8 @@ public: bx_sound_osx_c(logfunctions *dev); virtual ~bx_sound_osx_c(); + virtual int get_type() {return BX_SOUNDLOW_OSX;} + virtual int waveready(); virtual int midiready(); diff --git a/bochs/iodev/sound/soundwin.h b/bochs/iodev/sound/soundwin.h index fca973c2c..3629df1c6 100644 --- a/bochs/iodev/sound/soundwin.h +++ b/bochs/iodev/sound/soundwin.h @@ -169,6 +169,8 @@ public: bx_sound_windows_c(logfunctions *dev); virtual ~bx_sound_windows_c(); + virtual int get_type() {return BX_SOUNDLOW_WIN;} + virtual int waveready(); virtual int midiready();