- added method to return the type of the lowlevel sound module and use it to

check if a sleep / delay call is rquired in the beep generator
- preparing SDL sound support
This commit is contained in:
Volker Ruppert 2012-06-08 20:49:39 +00:00
parent 171d400bd8
commit 3a4c3e9d54
7 changed files with 44 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -33,10 +33,14 @@
#include "soundlnx.h"
#include "soundosx.h"
#include "soundwin.h"
//#include "soundsdl.h"
#ifndef WIN32
#include <pthread.h>
#endif
#if BX_WITH_SDL
#include <SDL.h>
#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);

View File

@ -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();

View File

@ -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();

View File

@ -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();