Added the capability to set up the sound driver per service. The global

sound option for setting up one driver for all services is still available.
This commit is contained in:
Volker Ruppert 2015-03-06 22:54:30 +00:00
parent e79185b0a0
commit 327f987a18
9 changed files with 74 additions and 49 deletions

View File

@ -1506,9 +1506,9 @@ void bx_init_options()
#if BX_SUPPORT_SOUNDLOW
bx_param_enum_c *driver = new bx_param_enum_c(soundlow,
"driver",
"Sound driver",
"This is the lowlevel driver to use for emulated sound devices",
"waveoutdrv",
"Waveout driver",
"This is the waveout driver to use for emulated sound devices",
sound_driver_names,
BX_SOUNDDRV_DUMMY,
BX_SOUNDDRV_DUMMY);
@ -1518,11 +1518,27 @@ void bx_init_options()
"Wave output device",
"This is the device where the wave output is sent to",
"", BX_PATHNAME_LEN);
driver = new bx_param_enum_c(soundlow,
"waveindrv",
"Wavein driver",
"This is the wavein driver to use for emulated sound devices",
sound_driver_names,
BX_SOUNDDRV_DUMMY,
BX_SOUNDDRV_DUMMY);
driver->set_by_name(BX_SOUND_LOWLEVEL_NAME);
new bx_param_filename_c(soundlow,
"wavein",
"Wave input device",
"This is the device to be used as the wave input source",
"", BX_PATHNAME_LEN);
driver = new bx_param_enum_c(soundlow,
"midioutdrv",
"Midiout driver",
"This is the midiout driver to use for emulated sound devices",
sound_driver_names,
BX_SOUNDDRV_DUMMY,
BX_SOUNDDRV_DUMMY);
driver->set_by_name(BX_SOUND_LOWLEVEL_NAME);
new bx_param_filename_c(soundlow,
"midiout",
"MIDI output device",
@ -2884,9 +2900,18 @@ static int parse_line_formatted(const char *context, int num_params, char *param
}
} else if (!strcmp(params[0], "sound")) {
#if BX_SUPPORT_SOUNDLOW
static const char default_drv[] = BX_SOUND_LOWLEVEL_NAME;
const char *driver;
for (i=1; i<num_params; i++) {
if (!strcmp(params[i], "driver=default")) {
SIM->get_param_enum(BXPN_SOUND_DRIVER)->set_by_name(BX_SOUND_LOWLEVEL_NAME);
if (!strncmp(params[i], "driver=", 7)) {
if (!strcmp(&params[i][7], "default")) {
driver = default_drv;
} else {
driver = &params[i][7];
}
SIM->get_param_enum(BXPN_SOUND_WAVEOUT_DRV)->set_by_name(driver);
SIM->get_param_enum(BXPN_SOUND_WAVEIN_DRV)->set_by_name(driver);
SIM->get_param_enum(BXPN_SOUND_MIDIOUT_DRV)->set_by_name(driver);
} else if (bx_parse_param_from_list(context, params[i], (bx_list_c*) SIM->get_param(BXPN_SOUNDLOW)) < 0) {
BX_ERROR(("%s: unknown parameter for sound ignored.", context));
}

View File

@ -354,13 +354,13 @@ public:
#if BX_SUPPORT_SOUNDLOW
class BOCHSAPI bx_soundmod_ctl_stub_c : public bx_devmodel_c {
public:
virtual bx_soundlow_waveout_c* get_waveout(const char *driver) {
virtual bx_soundlow_waveout_c* get_waveout(bx_bool using_file) {
STUBFUNC(soundmod_ctl, get_waveout); return NULL;
}
virtual bx_soundlow_wavein_c* get_wavein(const char *driver) {
virtual bx_soundlow_wavein_c* get_wavein() {
STUBFUNC(soundmod_ctl, get_wavein); return NULL;
}
virtual bx_soundlow_midiout_c* get_midiout(const char *driver) {
virtual bx_soundlow_midiout_c* get_midiout(bx_bool using_file) {
STUBFUNC(soundmod_ctl, get_midiout); return NULL;
}
};

View File

@ -229,17 +229,17 @@ void bx_es1370_c::init(void)
BX_ES1370_THIS wavemode = SIM->get_param_enum("wavemode", base)->get();
// always initialize lowlevel driver
BX_ES1370_WAVEOUT1 = DEV_sound_get_waveout("default");
BX_ES1370_WAVEOUT1 = DEV_sound_get_waveout(0);
if (BX_ES1370_WAVEOUT1 == NULL) {
BX_PANIC(("Couldn't initialize waveout driver"));
}
if (BX_ES1370_THIS wavemode & 2) {
BX_ES1370_WAVEOUT2 = DEV_sound_get_waveout("file");
BX_ES1370_WAVEOUT2 = DEV_sound_get_waveout(1);
if (BX_ES1370_WAVEOUT2 == NULL) {
BX_PANIC(("Couldn't initialize wave file driver"));
}
}
BX_ES1370_WAVEIN = DEV_sound_get_wavein("default");
BX_ES1370_WAVEIN = DEV_sound_get_wavein();
if (BX_ES1370_WAVEIN == NULL) {
BX_PANIC(("Couldn't initialize wavein driver"));
}
@ -382,7 +382,7 @@ void bx_es1370_c::runtime_config(void)
BX_ES1370_THIS wavemode = SIM->get_param_enum("wavemode", base)->get();
BX_ES1370_THIS s.dac_outputinit = (BX_ES1370_THIS wavemode & 1);
if (BX_ES1370_THIS wavemode & 2) {
BX_ES1370_WAVEOUT2 = DEV_sound_get_waveout("file");
BX_ES1370_WAVEOUT2 = DEV_sound_get_waveout(1);
if (BX_ES1370_WAVEOUT2 == NULL) {
BX_PANIC(("Couldn't initialize wave file driver"));
}

View File

@ -255,7 +255,7 @@ void bx_sb16_c::init(void)
BX_SB16_THIS loglevel = SIM->get_param_num("loglevel", base)->get();
// always initialize lowlevel driver
BX_SB16_WAVEOUT1 = DEV_sound_get_waveout("default");
BX_SB16_WAVEOUT1 = DEV_sound_get_waveout(0);
if (BX_SB16_WAVEOUT1 == NULL) {
BX_PANIC(("Couldn't initialize waveout driver"));
BX_SB16_THIS wavemode &= ~1;
@ -263,21 +263,21 @@ void bx_sb16_c::init(void)
BX_SB16_THIS fmopl_callback_id = BX_SB16_WAVEOUT1->register_wave_callback(BX_SB16_THISP, fmopl_callback);
}
if (BX_SB16_THIS wavemode & 2) {
BX_SB16_WAVEOUT2 = DEV_sound_get_waveout("file");
BX_SB16_WAVEOUT2 = DEV_sound_get_waveout(1);
if (BX_SB16_WAVEOUT2 == NULL) {
BX_PANIC(("Couldn't initialize wave file driver"));
}
}
BX_SB16_WAVEIN = DEV_sound_get_wavein("default");
BX_SB16_WAVEIN = DEV_sound_get_wavein();
if (BX_SB16_WAVEIN == NULL) {
BX_PANIC(("Couldn't initialize wavein driver"));
}
BX_SB16_MIDIOUT1 = DEV_sound_get_midiout("default");
BX_SB16_MIDIOUT1 = DEV_sound_get_midiout(0);
if (BX_SB16_MIDIOUT1 == NULL) {
BX_PANIC(("Couldn't initialize midiout driver"));
}
if (BX_SB16_THIS midimode & 2) {
BX_SB16_MIDIOUT2 = DEV_sound_get_midiout("file");
BX_SB16_MIDIOUT2 = DEV_sound_get_midiout(1);
if (BX_SB16_MIDIOUT2 == NULL) {
BX_PANIC(("Couldn't initialize midi file driver"));
}
@ -542,7 +542,7 @@ void bx_sb16_c::runtime_config(void)
if (BX_SB16_THIS midi_changed & 1) {
BX_SB16_THIS midimode = SIM->get_param_num("midimode", base)->get();
if (BX_SB16_THIS midimode & 2) {
BX_SB16_MIDIOUT2 = DEV_sound_get_midiout("file");
BX_SB16_MIDIOUT2 = DEV_sound_get_midiout(1);
if (BX_SB16_MIDIOUT2 == NULL) {
BX_PANIC(("Couldn't initialize midi file driver"));
}
@ -559,7 +559,7 @@ void bx_sb16_c::runtime_config(void)
BX_SB16_THIS wavemode = SIM->get_param_enum("wavemode", base)->get();
DSP.outputinit = (BX_SB16_THIS wavemode & 1);
if (BX_SB16_THIS wavemode & 2) {
BX_SB16_WAVEOUT2 = DEV_sound_get_waveout("file");
BX_SB16_WAVEOUT2 = DEV_sound_get_waveout(1);
if (BX_SB16_WAVEOUT2 == NULL) {
BX_PANIC(("Couldn't initialize wave file driver"));
}

View File

@ -79,24 +79,21 @@ bx_soundmod_ctl_c::~bx_soundmod_ctl_c()
void bx_soundmod_ctl_c::init()
{
bx_param_enum_c *driver = SIM->get_param_enum(BXPN_SOUND_DRIVER);
int ret;
const char *pwaveout = SIM->get_param_string(BXPN_SOUND_WAVEOUT)->getptr();
const char *pwavein = SIM->get_param_string(BXPN_SOUND_WAVEIN)->getptr();
int ret;
if (get_driver(driver->get()) != NULL) {
waveout = get_waveout(0);
if (waveout != NULL) {
if (!strlen(pwavein)) {
SIM->get_param_string(BXPN_SOUND_WAVEIN)->set(pwaveout);
}
waveout = soundmod[0].module->get_waveout();
if (waveout != NULL) {
ret = waveout->openwaveoutput(pwaveout);
if (ret != BX_SOUNDLOW_OK) {
BX_PANIC(("Could not open wave output device"));
}
} else {
BX_PANIC(("no waveout support in sound driver '%s'", driver->get_selected());
ret = waveout->openwaveoutput(pwaveout);
if (ret != BX_SOUNDLOW_OK) {
BX_PANIC(("Could not open wave output device"));
}
} else {
BX_PANIC(("no waveout support present"));
}
}
@ -106,7 +103,7 @@ bx_sound_lowlevel_c* bx_soundmod_ctl_c::get_driver(int driver_id)
unsigned i;
for (i = 0; i < n_sound_drivers; i++) {
if (driver_id == soundmod[i].drv_id)) {
if (driver_id == soundmod[i].drv_id) {
return soundmod[i].module;
}
}
@ -151,13 +148,14 @@ bx_sound_lowlevel_c* bx_soundmod_ctl_c::get_driver(int driver_id)
return driver;
}
bx_soundlow_waveout_c* bx_soundmod_ctl_c::get_waveout(const char *driver)
bx_soundlow_waveout_c* bx_soundmod_ctl_c::get_waveout(bx_bool using_file)
{
bx_sound_lowlevel_c *module = NULL;
if (!strcmp(driver, "default")) {
module = soundmod[0].module;
} else if (!strcmp(driver, "file")) {
if (!using_file) {
int driver_id = SIM->get_param_enum(BXPN_SOUND_WAVEOUT_DRV)->get();
module = get_driver(driver_id);
} else {
module = get_driver(BX_SOUNDDRV_FILE);
}
if (module != NULL) {
@ -167,13 +165,12 @@ bx_soundlow_waveout_c* bx_soundmod_ctl_c::get_waveout(const char *driver)
}
}
bx_soundlow_wavein_c* bx_soundmod_ctl_c::get_wavein(const char *driver)
bx_soundlow_wavein_c* bx_soundmod_ctl_c::get_wavein()
{
bx_sound_lowlevel_c *module = NULL;
if (!strcmp(driver, "default")) {
module = soundmod[0].module;
}
int driver_id = SIM->get_param_enum(BXPN_SOUND_WAVEIN_DRV)->get();
module = get_driver(driver_id);
if (module != NULL) {
return module->get_wavein();
} else {
@ -181,13 +178,14 @@ bx_soundlow_wavein_c* bx_soundmod_ctl_c::get_wavein(const char *driver)
}
}
bx_soundlow_midiout_c* bx_soundmod_ctl_c::get_midiout(const char *driver)
bx_soundlow_midiout_c* bx_soundmod_ctl_c::get_midiout(bx_bool using_file)
{
bx_sound_lowlevel_c *module = NULL;
if (!strcmp(driver, "default")) {
module = soundmod[0].module;
} else if (!strcmp(driver, "file")) {
if (!using_file) {
int driver_id = SIM->get_param_enum(BXPN_SOUND_MIDIOUT_DRV)->get();
module = get_driver(driver_id);
} else {
module = get_driver(BX_SOUNDDRV_FILE);
}
if (module != NULL) {

View File

@ -31,9 +31,9 @@ public:
bx_soundmod_ctl_c();
virtual ~bx_soundmod_ctl_c();
virtual void init(void);
virtual bx_soundlow_waveout_c* get_waveout(const char *driver);
virtual bx_soundlow_wavein_c* get_wavein(const char *driver);
virtual bx_soundlow_midiout_c* get_midiout(const char *driver);
virtual bx_soundlow_waveout_c* get_waveout(bx_bool using_file);
virtual bx_soundlow_wavein_c* get_wavein();
virtual bx_soundlow_midiout_c* get_midiout(bx_bool using_file);
private:
bx_sound_lowlevel_c* get_driver(int driver_id);

View File

@ -178,7 +178,7 @@ void bx_speaker_c::init(void)
if (!strcmp(mode, "sound")) {
output_mode = BX_SPK_MODE_SOUND;
#if BX_SUPPORT_SOUNDLOW
waveout = DEV_sound_get_waveout("default");
waveout = DEV_sound_get_waveout(0);
if (waveout != NULL) {
beep_active = 0;
BX_INIT_MUTEX(beep_mutex);

View File

@ -174,9 +174,11 @@
#define BXPN_E1000 "network.e1000"
#define BXPN_E1000_ENABLED "network.e1000.enabled"
#define BXPN_SOUNDLOW "sound.lowlevel"
#define BXPN_SOUND_DRIVER "sound.lowlevel.driver"
#define BXPN_SOUND_WAVEOUT_DRV "sound.lowlevel.waveoutdrv"
#define BXPN_SOUND_WAVEOUT "sound.lowlevel.waveout"
#define BXPN_SOUND_WAVEIN_DRV "sound.lowlevel.waveindrv"
#define BXPN_SOUND_WAVEIN "sound.lowlevel.wavein"
#define BXPN_SOUND_MIDIOUT_DRV "sound.lowlevel.midioutdrv"
#define BXPN_SOUND_MIDIOUT "sound.lowlevel.midiout"
#define BXPN_SOUND_SPEAKER "sound.speaker"
#define BXPN_SOUND_SB16 "sound.sb16"

View File

@ -256,7 +256,7 @@ extern "C" {
///////// Sound module macros
#define DEV_sound_get_waveout(a) (bx_devices.pluginSoundModCtl->get_waveout(a))
#define DEV_sound_get_wavein(a) (bx_devices.pluginSoundModCtl->get_wavein(a))
#define DEV_sound_get_wavein() (bx_devices.pluginSoundModCtl->get_wavein())
#define DEV_sound_get_midiout(a) (bx_devices.pluginSoundModCtl->get_midiout(a))
///////// Networking module macro