Rewrite of the sound driver plugin code.

- Renamed OSS sound driver files from soundlnx.cc/.h to soundoss.cc/.h.
- Removed "pseudo device plugin" containing common code and specific drivers.
- Moved common sound code, base classes of sound drivers and the dummy driver
  to the Bochs core. Now loading sound driver plugins in soundmod.cc.
- Created separate plugins for the platform/library specific drivers and the
  "file" driver.
- Modified Bochs plugin system to support now plugin type PLUGTYPE_SOUND.
This commit is contained in:
Volker Ruppert 2017-02-20 18:21:19 +00:00
parent ff43979e08
commit 60d24943c6
21 changed files with 804 additions and 203 deletions

20
bochs/configure vendored

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 13036 2017-01-13 15:57:36Z vruppert .
# From configure.in Id: configure.in 13061 2017-02-08 18:48:49Z vruppert .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
@ -24010,7 +24010,7 @@ if test "$soundcard_present" = 1; then
;;
*-linux* | *-freebsd*)
SOUNDLOW_OBJS='soundlnx.o'
SOUNDLOW_OBJS='soundoss.o'
soundlow_drivers="oss"
soundlow_default="oss"
$as_echo "#define BX_HAVE_SOUND_OSS 1" >>confdefs.h
@ -24108,11 +24108,7 @@ fi
if test "$bx_have_libsamplerate" = 1; then
if test "$bx_plugins" = 1; then
SOUND_LINK_OPTS="$SOUND_LINK_OPTS -lsamplerate"
else
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsamplerate"
fi
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsamplerate"
$as_echo "#define BX_HAVE_LIBSAMPLERATE 1" >>confdefs.h
else
@ -24123,19 +24119,13 @@ fi
if test "$bx_have_soxr_lsr" = 1; then
if test "$bx_plugins" = 1; then
SOUND_LINK_OPTS="$SOUND_LINK_OPTS -lsoxr-lsr"
else
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsoxr-lsr"
fi
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsoxr-lsr"
$as_echo "#define BX_HAVE_SOXR_LSR 1" >>confdefs.h
fi
fi
if test "$bx_plugins" = 0; then
SOUND_LIB_VAR='iodev/sound/libsound.a'
SOUND_LIB_VAR='iodev/sound/libsound.a'
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sound lowlevel modules" >&5
$as_echo_n "checking for sound lowlevel modules... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $soundlow_drivers" >&5

@ -1976,7 +1976,7 @@ if test "$soundcard_present" = 1; then
AC_DEFINE(BX_HAVE_SOUND_SDL, 1)
;;
*-linux* | *-freebsd*)
SOUNDLOW_OBJS='soundlnx.o'
SOUNDLOW_OBJS='soundoss.o'
soundlow_drivers="oss"
soundlow_default="oss"
AC_DEFINE(BX_HAVE_SOUND_OSS, 1)
@ -2056,27 +2056,17 @@ if test "$soundcard_present" = 1; then
fi
AC_CHECK_HEADER([samplerate.h], [bx_have_libsamplerate=1])
if test "$bx_have_libsamplerate" = 1; then
if test "$bx_plugins" = 1; then
SOUND_LINK_OPTS="$SOUND_LINK_OPTS -lsamplerate"
else
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsamplerate"
fi
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsamplerate"
AC_DEFINE(BX_HAVE_LIBSAMPLERATE, 1)
else
AC_CHECK_HEADER([soxr-lsr.h], [bx_have_soxr_lsr=1])
if test "$bx_have_soxr_lsr" = 1; then
if test "$bx_plugins" = 1; then
SOUND_LINK_OPTS="$SOUND_LINK_OPTS -lsoxr-lsr"
else
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsoxr-lsr"
fi
DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsoxr-lsr"
AC_DEFINE(BX_HAVE_SOXR_LSR, 1)
fi
fi
if test "$bx_plugins" = 0; then
SOUND_LIB_VAR='iodev/sound/libsound.a'
AC_SUBST(SOUND_LIB_VAR)
fi
SOUND_LIB_VAR='iodev/sound/libsound.a'
AC_SUBST(SOUND_LIB_VAR)
AC_MSG_CHECKING(for sound lowlevel modules)
AC_MSG_RESULT($soundlow_drivers)
AC_MSG_CHECKING(for default sound lowlevel module)

@ -32,6 +32,7 @@ enum plugintype_t {
PLUGTYPE_CORE,
PLUGTYPE_STANDARD,
PLUGTYPE_OPTIONAL,
PLUGTYPE_SOUND,
PLUGTYPE_USER
};

@ -27,6 +27,7 @@
#include "iodev/virt_timer.h"
#include "iodev/slowdown_timer.h"
#include "iodev/sound/soundmod.h"
#define LOG_THIS bx_devices.
@ -91,9 +92,6 @@ void bx_devices_c::init_stubs()
#if BX_SUPPORT_PCIUSB
pluginUsbDevCtl = &stubUsbDevCtl;
#endif
#if BX_SUPPORT_SOUNDLOW
pluginSoundModCtl = &stubSoundModCtl;
#endif
#if BX_NETWORKING
pluginNetModCtl = &stubNetModCtl;
#endif
@ -168,8 +166,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
#if BX_SUPPORT_SOUNDLOW
sound_enabled = is_sound_enabled();
if (sound_enabled) {
PLUG_load_plugin(soundmod, PLUGTYPE_CORE);
pluginSoundModCtl->init();
bx_soundmod_ctl.init();
}
#endif
// PCI logic (i440FX)
@ -397,7 +394,7 @@ void bx_devices_c::exit()
#endif
#if BX_SUPPORT_SOUNDLOW
if (sound_enabled)
PLUG_unload_plugin(soundmod);
bx_soundmod_ctl.exit();
#endif
#if BX_SUPPORT_PCIUSB
if (usb_enabled)

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2015 The Bochs Project
// Copyright (C) 2001-2017 The Bochs Project
//
// I/O port handlers API Copyright (C) 2003 by Frank Cornelis
//
@ -81,9 +81,6 @@ class BOCHSAPI bx_devmodel_c : public logfunctions {
class bx_list_c;
class device_image_t;
class cdrom_base_c;
class bx_soundlow_waveout_c;
class bx_soundlow_wavein_c;
class bx_soundlow_midiout_c;
//////////////////////////////////////////////////////////////////////
// declare stubs for PCI devices
@ -346,21 +343,6 @@ public:
}
};
#if BX_SUPPORT_SOUNDLOW
class BOCHSAPI bx_soundmod_ctl_stub_c : public bx_devmodel_c {
public:
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() {
STUBFUNC(soundmod_ctl, get_wavein); return NULL;
}
virtual bx_soundlow_midiout_c* get_midiout(bx_bool using_file) {
STUBFUNC(soundmod_ctl, get_midiout); return NULL;
}
};
#endif
#if BX_NETWORKING
class BOCHSAPI bx_netmod_ctl_stub_c : public bx_devmodel_c {
public:
@ -465,9 +447,6 @@ public:
#if BX_SUPPORT_PCIUSB
bx_usb_devctl_stub_c *pluginUsbDevCtl;
#endif
#if BX_SUPPORT_SOUNDLOW
bx_soundmod_ctl_stub_c *pluginSoundModCtl;
#endif
#if BX_NETWORKING
bx_netmod_ctl_stub_c *pluginNetModCtl;
#endif
@ -500,9 +479,6 @@ public:
#if BX_SUPPORT_PCIUSB
bx_usb_devctl_stub_c stubUsbDevCtl;
#endif
#if BX_SUPPORT_SOUNDLOW
bx_soundmod_ctl_stub_c stubSoundModCtl;
#endif
#if BX_NETWORKING
bx_netmod_ctl_stub_c stubNetModCtl;
#endif

@ -1,4 +1,4 @@
# Copyright (C) 2012-2015 The Bochs Project
# Copyright (C) 2012-2017 The Bochs Project
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -49,7 +49,7 @@ top_builddir = ../..
LIBTOOL=@LIBTOOL@
WIN32_DLL_IMPORT_LIBRARY=../../@WIN32_DLL_IMPORT_LIB@
SOUNDLOW_OBJS = soundlow.o soundfile.o @SOUNDLOW_OBJS@
SOUNDLOW_OBJS = soundfile.o @SOUNDLOW_OBJS@
SOUNDMOD_LINK_OPTS = -lwinmm
SOUNDMOD_LINK_OPTS_VCPP = winmm.lib
@ -57,11 +57,15 @@ SOUNDMOD_LINK_OPTS_VCPP = winmm.lib
BX_INCDIRS = -I.. -I../.. -I$(srcdir)/.. -I$(srcdir)/../.. -I../../@INSTRUMENT_DIR@ -I$(srcdir)/../../@INSTRUMENT_DIR@
LOCAL_CXXFLAGS = $(MCH_CFLAGS)
OBJS_THAT_CANNOT_BE_PLUGINS = \
soundmod.o \
soundlow.o
OBJS_THAT_CAN_BE_PLUGINS = \
@SOUNDHW_OBJS@ \
soundmod.o
$(SOUNDLOW_OBJS)
OBJS_THAT_SUPPORT_OTHER_PLUGINS = opl.o $(SOUNDLOW_OBJS)
OBJS_THAT_SUPPORT_OTHER_PLUGINS = opl.o
NONPLUGIN_OBJS = @IODEV_EXT_NON_PLUGIN_OBJS@
PLUGIN_OBJS = @IODEV_EXT_PLUGIN_OBJS@
@ -93,26 +97,29 @@ libbx_%.la: %.lo
$(LIBTOOL) --mode=link --tag CXX $(CXX) -module $< -o $@ -rpath $(PLUGIN_PATH)
# special link rules for plugins that require more than one object file
libbx_soundmod.la: soundmod.lo $(SOUNDLOW_OBJS:.o=.lo)
$(LIBTOOL) --mode=link --tag CXX $(CXX) -module soundmod.lo $(SOUNDLOW_OBJS:.o=.lo) -o libbx_soundmod.la -rpath $(PLUGIN_PATH) $(SOUND_LINK_OPTS)
libbx_sb16.la: sb16.lo opl.lo
$(LIBTOOL) --mode=link --tag CXX $(CXX) -module sb16.lo opl.lo -o libbx_sb16.la -rpath $(PLUGIN_PATH)
libbx_soundalsa.la: soundalsa.lo
$(LIBTOOL) --mode=link --tag CXX $(CXX) -module soundalsa.lo -o libbx_soundalsa.la -rpath $(PLUGIN_PATH) $(SOUND_LINK_OPTS)
libbx_soundsdl.la: soundsdl.lo
$(LIBTOOL) --mode=link --tag CXX $(CXX) -module soundsdl.lo -o libbx_soundsdl.la -rpath $(PLUGIN_PATH) $(SOUND_LINK_OPTS)
#### building DLLs for win32 (Cygwin and MinGW/MSYS)
bx_%.dll: %.o
$(CXX) $(CXXFLAGS) -shared -o $@ $< $(WIN32_DLL_IMPORT_LIBRARY)
# special link rules for plugins with Cygwin, MinGW/MSYS and MSVC nmake
bx_soundmod.dll: soundmod.o $(SOUNDLOW_OBJS)
@LINK_DLL@ soundmod.o $(SOUNDLOW_OBJS) $(WIN32_DLL_IMPORT_LIBRARY) $(SOUNDMOD_LINK_OPTS@LINK_VAR@)
bx_sb16.dll: sb16.o opl.o
@LINK_DLL@ sb16.o opl.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_es1370.dll: es1370.o
@LINK_DLL@ es1370.o $(WIN32_DLL_IMPORT_LIBRARY)
bx_soundwin.dll: soundwin.o
@LINK_DLL@ soundwin.o $(WIN32_DLL_IMPORT_LIBRARY) $(SOUNDMOD_LINK_OPTS@LINK_VAR@)
##### end DLL section
clean:
@ -136,7 +143,7 @@ es1370.o: es1370.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osde
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h ../pci.h es1370.h soundlow.h
../../param_names.h soundlow.h soundmod.h ../pci.h es1370.h
opl.o: opl.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
@ -148,25 +155,19 @@ sb16.o: sb16.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osdep.h
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h sb16.h opl.h
../../param_names.h soundlow.h soundmod.h sb16.h opl.h
soundalsa.o: soundalsa.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundalsa.h
../../param_names.h soundlow.h soundmod.h soundalsa.h
soundfile.o: soundfile.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundfile.h
soundlnx.o: soundlnx.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundlnx.h
../../param_names.h soundlow.h soundmod.h soundfile.h
soundlow.o: soundlow.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
@ -178,32 +179,37 @@ soundmod.o: soundmod.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundmod.h soundlow.h soundlnx.h soundosx.h \
soundwin.h soundsdl.h soundalsa.h soundfile.h
../../param_names.h soundmod.h soundlow.h
soundoss.o: soundoss.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundmod.h soundoss.h
soundosx.o: soundosx.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundosx.h
../../param_names.h soundlow.h soundmod.h soundosx.h
soundsdl.o: soundsdl.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundsdl.h
../../param_names.h soundlow.h soundmod.h soundsdl.h
soundwin.o: soundwin.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundwin.h
../../param_names.h soundlow.h soundmod.h soundwin.h
es1370.lo: es1370.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h ../pci.h es1370.h soundlow.h
../../param_names.h soundlow.h soundmod.h ../pci.h es1370.h
opl.lo: opl.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
@ -215,25 +221,19 @@ sb16.lo: sb16.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h ../../osdep.h
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h sb16.h opl.h
../../param_names.h soundlow.h soundmod.h sb16.h opl.h
soundalsa.lo: soundalsa.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundalsa.h
../../param_names.h soundlow.h soundmod.h soundalsa.h
soundfile.lo: soundfile.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundfile.h
soundlnx.lo: soundlnx.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundlnx.h
../../param_names.h soundlow.h soundmod.h soundfile.h
soundlow.lo: soundlow.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
@ -245,23 +245,28 @@ soundmod.lo: soundmod.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundmod.h soundlow.h soundlnx.h soundosx.h \
soundwin.h soundsdl.h soundalsa.h soundfile.h
../../param_names.h soundmod.h soundlow.h
soundoss.lo: soundoss.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundmod.h soundoss.h
soundosx.lo: soundosx.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundosx.h
../../param_names.h soundlow.h soundmod.h soundosx.h
soundsdl.lo: soundsdl.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundsdl.h
../../param_names.h soundlow.h soundmod.h soundsdl.h
soundwin.lo: soundwin.@CPP_SUFFIX@ ../iodev.h ../../bochs.h ../../config.h \
../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
../../memory/memory-bochs.h ../../pc_system.h ../../gui/gui.h \
../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
../../param_names.h soundlow.h soundwin.h
../../param_names.h soundlow.h soundmod.h soundwin.h

@ -35,6 +35,7 @@
#if BX_SUPPORT_PCI && BX_SUPPORT_ES1370
#include "soundlow.h"
#include "soundmod.h"
#include "pci.h"
#include "es1370.h"

@ -32,6 +32,7 @@
#if BX_SUPPORT_SB16
#include "soundlow.h"
#include "soundmod.h"
#include "sb16.h"
#include "opl.h"

@ -21,14 +21,36 @@
// ALSA PCM input/output and MIDI output support written by Volker Ruppert
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundalsa.h"
#if BX_HAVE_SOUND_ALSA && BX_SUPPORT_SOUNDLOW
#define LOG_THIS log->
bx_sound_alsa_c* alsaSoundDriver = NULL;
// sound driver plugin entry points
int CDECL libalsa_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
alsaSoundDriver = new bx_sound_alsa_c();
DEV_sound_register_driver(alsaSoundDriver, BX_SOUNDDRV_ALSA);
return 0; // Success
}
void CDECL libalsa_sound_plugin_fini(void)
{
delete alsaSoundDriver;
}
// helper function for wavein / waveout
int alsa_pcm_open(bx_bool mode, alsa_pcm_t *alsa_pcm, bx_pcm_param_t *param, logfunctions *log)

@ -28,6 +28,7 @@
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundfile.h"
#if BX_SUPPORT_SOUNDLOW
@ -39,6 +40,22 @@
#define LOG_THIS
bx_sound_file_c* fileSoundDriver = NULL;
// sound driver plugin entry points
int CDECL libfile_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
fileSoundDriver = new bx_sound_file_c();
DEV_sound_register_driver(fileSoundDriver, BX_SOUNDDRV_FILE);
return 0; // Success
}
void CDECL libfile_sound_plugin_fini(void)
{
delete fileSoundDriver;
}
// bx_soundlow_waveout_file_c class implemenzation
bx_soundlow_waveout_file_c::bx_soundlow_waveout_file_c()

@ -18,12 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Common sound module code and dummy sound lowlevel functions
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
// Common sound module code and base classes for sound lowlevel functions
#include "iodev.h"

@ -183,7 +183,7 @@ protected:
bx_soundlow_midiout_c *midiout;
};
// the dummy sound driver contains stubs for all features
// The dummy sound driver contains stubs for all features
class bx_sound_dummy_c : public bx_sound_lowlevel_c {
public:

@ -18,12 +18,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Common sound module code and dummy sound lowlevel functions
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
// Sound driver loader code
#include "iodev.h"
@ -31,36 +26,15 @@
#include "soundmod.h"
#include "soundlow.h"
#include "soundlnx.h"
#include "soundosx.h"
#include "soundwin.h"
#include "soundsdl.h"
#include "soundalsa.h"
#include "soundfile.h"
#if BX_WITH_SDL || BX_WITH_SDL2
#include <SDL.h>
#endif
#define LOG_THIS theSoundModCtl->
#define LOG_THIS bx_soundmod_ctl.
bx_soundmod_ctl_c* theSoundModCtl = NULL;
bx_soundmod_ctl_c bx_soundmod_ctl;
int CDECL libsoundmod_LTX_plugin_init(plugin_t *plugin, plugintype_t type)
{
if (type == PLUGTYPE_CORE) {
theSoundModCtl = new bx_soundmod_ctl_c;
bx_devices.pluginSoundModCtl = theSoundModCtl;
return 0; // Success
} else {
return -1;
}
}
void CDECL libsoundmod_LTX_plugin_fini(void)
{
delete theSoundModCtl;
}
bx_soundmod_ctl_c::bx_soundmod_ctl_c()
{
@ -70,13 +44,6 @@ bx_soundmod_ctl_c::bx_soundmod_ctl_c()
waveout = NULL;
}
bx_soundmod_ctl_c::~bx_soundmod_ctl_c()
{
for (unsigned i = 0; i < n_sound_drivers; i++) {
delete soundmod[i].module;
}
}
void bx_soundmod_ctl_c::init()
{
const char *pwaveout = SIM->get_param_string(BXPN_SOUND_WAVEOUT)->getptr();
@ -97,55 +64,64 @@ void bx_soundmod_ctl_c::init()
}
}
bx_sound_lowlevel_c* bx_soundmod_ctl_c::get_driver(int driver_id)
void bx_soundmod_ctl_c::exit()
{
bx_sound_lowlevel_c *driver = NULL;
unsigned i;
unsigned i, driver_id;
for (i = 0; i < n_sound_drivers; i++) {
if (driver_id == soundmod[i].drv_id) {
return soundmod[i].module;
while (n_sound_drivers > 0) {
i = --n_sound_drivers;
driver_id = soundmod[i].drv_id;
if (driver_id == BX_SOUNDDRV_DUMMY) {
delete soundmod[i].module;
} else {
PLUG_unload_sound_plugin(sound_driver_names[driver_id]);
}
}
}
bx_bool bx_soundmod_ctl_c::register_driver(bx_sound_lowlevel_c *module, int driver_id)
{
unsigned i = n_sound_drivers;
if (i == BX_MAX_SOUND_DRIVERS) {
BX_PANIC(("Too many sound drivers!"));
return NULL;
return 0;
}
if (driver_id == BX_SOUNDDRV_DUMMY) {
driver = new bx_sound_dummy_c();
} else if (driver_id == BX_SOUNDDRV_FILE) {
driver = new bx_sound_file_c();
#if BX_HAVE_SOUND_ALSA
} else if (driver_id == BX_SOUNDDRV_ALSA) {
driver = new bx_sound_alsa_c();
#endif
#if BX_HAVE_SOUND_SDL
} else if (driver_id == BX_SOUNDDRV_SDL) {
driver = new bx_sound_sdl_c();
#endif
#if BX_HAVE_SOUND_OSS
} else if (driver_id == BX_SOUNDDRV_OSS) {
driver = new bx_sound_oss_c();
#endif
#if BX_HAVE_SOUND_OSX
} else if (driver_id == BX_SOUNDDRV_OSX) {
driver = new bx_sound_osx_c();
#endif
#if BX_HAVE_SOUND_WIN
} else if (driver_id == BX_SOUNDDRV_WIN) {
driver = new bx_sound_windows_c();
#endif
} else {
BX_PANIC(("unknown lowlevel sound driver id %d", driver_id));
}
if (driver != NULL) {
if (module != NULL) {
BX_INFO(("Installed sound driver '%s' at index #%d",
sound_driver_names[driver_id], i));
soundmod[i].drv_id = driver_id;
soundmod[i].module = driver;
soundmod[i].module = module;
n_sound_drivers++;
return 1;
}
return driver;
return 0;
}
bx_sound_lowlevel_c* bx_soundmod_ctl_c::get_driver(int driver_id)
{
unsigned i, loaded = 0;
do {
for (i = 0; i < n_sound_drivers; i++) {
if (driver_id == soundmod[i].drv_id) {
return soundmod[i].module;
}
}
if (loaded) return NULL;
if (i == BX_MAX_SOUND_DRIVERS) {
BX_PANIC(("Too many sound drivers!"));
return NULL;
}
if (driver_id == BX_SOUNDDRV_DUMMY) {
bx_sound_lowlevel_c *driver = new bx_sound_dummy_c();
register_driver(driver, driver_id);
} else {
PLUG_load_sound_plugin(sound_driver_names[driver_id]);
}
loaded = 1;
} while (1);
return NULL;
}
bx_soundlow_waveout_c* bx_soundmod_ctl_c::get_waveout(bx_bool using_file)

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2015 The Bochs Project
// Copyright (C) 2011-2017 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -18,22 +18,26 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// Common code for sound lowlevel modules
// Sound driver loader code
#define BX_MAX_SOUND_DRIVERS 4
class bx_sound_lowlevel_c;
class bx_soundlow_waveout_c;
class bx_soundlow_wavein_c;
class bx_soundlow_midiout_c;
// Pseudo device that loads the lowlevel sound module
class bx_soundmod_ctl_c : public bx_soundmod_ctl_stub_c {
class BOCHSAPI bx_soundmod_ctl_c : public logfunctions {
public:
bx_soundmod_ctl_c();
virtual ~bx_soundmod_ctl_c();
virtual void init(void);
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);
~bx_soundmod_ctl_c() {}
void init(void);
void exit(void);
bx_bool register_driver(bx_sound_lowlevel_c *module, int driver_id);
bx_soundlow_waveout_c* get_waveout(bx_bool using_file);
bx_soundlow_wavein_c* get_wavein();
bx_soundlow_midiout_c* get_midiout(bx_bool using_file);
private:
bx_sound_lowlevel_c* get_driver(int driver_id);
@ -46,3 +50,5 @@ private:
bx_soundlow_waveout_c *waveout;
};
BOCHSAPI extern bx_soundmod_ctl_c bx_soundmod_ctl;

@ -0,0 +1,396 @@
/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2017 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/////////////////////////////////////////////////////////////////////////
// Josef Drexler coded the original version of the lowlevel sound support
// for Linux using OSS. The current version also supports OSS on FreeBSD.
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundoss.h"
#if BX_HAVE_SOUND_OSS && BX_SUPPORT_SOUNDLOW
#define LOG_THIS
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
bx_sound_oss_c* ossSoundDriver = NULL;
// sound driver plugin entry points
int CDECL liboss_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
ossSoundDriver = new bx_sound_oss_c();
DEV_sound_register_driver(ossSoundDriver, BX_SOUNDDRV_OSS);
return 0; // Success
}
void CDECL liboss_sound_plugin_fini(void)
{
delete ossSoundDriver;
}
// bx_soundlow_waveout_oss_c class implemenzation
bx_soundlow_waveout_oss_c::bx_soundlow_waveout_oss_c()
:bx_soundlow_waveout_c()
{
waveout_fd = -1;
}
bx_soundlow_waveout_oss_c::~bx_soundlow_waveout_oss_c()
{
if (waveout_fd != -1) {
close(waveout_fd);
waveout_fd = -1;
}
}
int bx_soundlow_waveout_oss_c::openwaveoutput(const char *wavedev)
{
if (waveout_fd == -1) {
waveout_fd = open(wavedev, O_WRONLY);
if (waveout_fd == -1) {
return BX_SOUNDLOW_ERR;
} else {
BX_INFO(("OSS: opened output device %s", wavedev));
}
}
set_pcm_params(&real_pcm_param);
pcm_callback_id = register_wave_callback(this, pcm_callback);
start_resampler_thread();
start_mixer_thread();
return BX_SOUNDLOW_OK;
}
int bx_soundlow_waveout_oss_c::set_pcm_params(bx_pcm_param_t *param)
{
int fmt, ret;
int frequency = param->samplerate;
int channels = param->channels;
int signeddata = param->format & 1;
BX_DEBUG(("set_pcm_params(): %u, %u, %u, %02x", param->samplerate, param->bits,
param->channels, param->format));
if (waveout_fd == -1) {
return BX_SOUNDLOW_ERR;
}
if (param->bits == 16) {
if (signeddata == 1) {
fmt = AFMT_S16_LE;
} else {
fmt = AFMT_U16_LE;
}
} else if (param->bits == 8) {
if (signeddata == 1) {
fmt = AFMT_S8;
} else {
fmt = AFMT_U8;
}
} else {
return BX_SOUNDLOW_ERR;
}
// set frequency etc.
ret = ioctl(waveout_fd, SNDCTL_DSP_RESET);
if (ret != 0)
BX_ERROR(("ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)));
/*
ret = ioctl(waveout_fd], SNDCTL_DSP_SETFRAGMENT, &fragment);
if (ret != 0)
BX_DEBUG(("ioctl(SNDCTL_DSP_SETFRAGMENT, %d): %s",
fragment, strerror(errno)));
*/
ret = ioctl(waveout_fd, SNDCTL_DSP_SETFMT, &fmt);
if (ret != 0) { // abort if the format is unknown, to avoid playing noise
BX_ERROR(("ioctl(SNDCTL_DSP_SETFMT, %d): %s",
fmt, strerror(errno)));
return BX_SOUNDLOW_ERR;
}
ret = ioctl(waveout_fd, SNDCTL_DSP_CHANNELS, &channels);
if (ret != 0)
BX_ERROR(("ioctl(SNDCTL_DSP_CHANNELS, %d): %s",
channels, strerror(errno)));
ret = ioctl(waveout_fd, SNDCTL_DSP_SPEED, &frequency);
if (ret != 0)
BX_ERROR(("ioctl(SNDCTL_DSP_SPEED, %d): %s",
frequency, strerror(errno)));
// ioctl(wave_fd[0], SNDCTL_DSP_GETBLKSIZE, &fragment);
// BX_DEBUG(("current output block size is %d", fragment));
return BX_SOUNDLOW_OK;
}
int bx_soundlow_waveout_oss_c::output(int length, Bit8u data[])
{
int odelay, delay;
if (waveout_fd == -1) {
return BX_SOUNDLOW_ERR;
}
if (write(waveout_fd, data, length) == length) {
ioctl(waveout_fd, SNDCTL_DSP_GETODELAY, &odelay);
delay = odelay * 1000 / (real_pcm_param.samplerate * 4);
BX_MSLEEP(delay);
return BX_SOUNDLOW_OK;
} else {
return BX_SOUNDLOW_ERR;
}
}
// bx_soundlow_wavein_oss_c class implemenzation
bx_soundlow_wavein_oss_c::bx_soundlow_wavein_oss_c()
:bx_soundlow_wavein_c()
{
wavein_fd = -1;
}
bx_soundlow_wavein_oss_c::~bx_soundlow_wavein_oss_c()
{
if (wavein_fd != -1) {
close(wavein_fd);
wavein_fd = -1;
}
}
int bx_soundlow_wavein_oss_c::openwaveinput(const char *wavedev, sound_record_handler_t rh)
{
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundlnx");
// record timer: inactive, continuous, frequency variable
}
if (wavein_fd == -1) {
wavein_fd = open(wavedev, O_RDONLY);
if (wavein_fd == -1) {
return BX_SOUNDLOW_ERR;
} else {
BX_INFO(("OSS: opened input device %s", wavedev));
}
}
wavein_param.samplerate = 0;
return BX_SOUNDLOW_OK;
}
int bx_soundlow_wavein_oss_c::startwaverecord(bx_pcm_param_t *param)
{
Bit64u timer_val;
Bit8u shift = 0;
int fmt, ret;
int frequency = param->samplerate;
int channels = param->channels;
int signeddata = param->format & 1;
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
if (param->bits == 16) shift++;
if (param->channels == 2) shift++;
record_packet_size = (param->samplerate / 10) << shift; // 0.1 sec
if (record_packet_size > BX_SOUNDLOW_WAVEPACKETSIZE) {
record_packet_size = BX_SOUNDLOW_WAVEPACKETSIZE;
}
timer_val = (Bit64u)record_packet_size * 1000000 / (param->samplerate << shift);
bx_pc_system.activate_timer(record_timer_index, (Bit32u)timer_val, 1);
}
if (wavein_fd == -1) {
return BX_SOUNDLOW_ERR;
} else {
if (memcmp(param, &wavein_param, sizeof(bx_pcm_param_t)) == 0) {
return BX_SOUNDLOW_OK; // nothing to do
}
wavein_param = *param;
}
if (param->bits == 16) {
if (signeddata == 1) {
fmt = AFMT_S16_LE;
} else {
fmt = AFMT_U16_LE;
}
} else if (param->bits == 8) {
if (signeddata == 1) {
fmt = AFMT_S8;
} else {
fmt = AFMT_U8;
}
} else {
return BX_SOUNDLOW_ERR;
}
// set frequency etc.
ret = ioctl(wavein_fd, SNDCTL_DSP_RESET);
if (ret != 0)
BX_ERROR(("ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)));
ret = ioctl(wavein_fd, SNDCTL_DSP_SETFMT, &fmt);
if (ret != 0) { // abort if the format is unknown, to avoid playing noise
BX_ERROR(("ioctl(SNDCTL_DSP_SETFMT, %d): %s",
fmt, strerror(errno)));
return BX_SOUNDLOW_ERR;
}
ret = ioctl(wavein_fd, SNDCTL_DSP_CHANNELS, &channels);
if (ret != 0) {
BX_ERROR(("ioctl(SNDCTL_DSP_CHANNELS, %d): %s",
channels, strerror(errno)));
return BX_SOUNDLOW_ERR;
}
ret = ioctl(wavein_fd, SNDCTL_DSP_SPEED, &frequency);
if (ret != 0) {
BX_ERROR(("ioctl(SNDCTL_DSP_SPEED, %d): %s",
frequency, strerror(errno)));
return BX_SOUNDLOW_ERR;
}
return BX_SOUNDLOW_OK;
}
int bx_soundlow_wavein_oss_c::getwavepacket(int length, Bit8u data[])
{
int ret;
ret = read(wavein_fd, data, length);
if (ret == length) {
return BX_SOUNDLOW_OK;
} else {
BX_ERROR(("OSS: write error"));
return BX_SOUNDLOW_ERR;
}
}
int bx_soundlow_wavein_oss_c::stopwaverecord()
{
if (record_timer_index != BX_NULL_TIMER_HANDLE) {
bx_pc_system.deactivate_timer(record_timer_index);
}
return BX_SOUNDLOW_OK;
}
void bx_soundlow_wavein_oss_c::record_timer_handler(void *this_ptr)
{
bx_soundlow_wavein_oss_c *class_ptr = (bx_soundlow_wavein_oss_c *) this_ptr;
class_ptr->record_timer();
}
void bx_soundlow_wavein_oss_c::record_timer(void)
{
record_handler(this, record_packet_size);
}
// bx_soundlow_midiout_oss_c class implemenzation
bx_soundlow_midiout_oss_c::bx_soundlow_midiout_oss_c()
:bx_soundlow_midiout_c()
{
midi = NULL;
}
bx_soundlow_midiout_oss_c::~bx_soundlow_midiout_oss_c()
{
closemidioutput();
}
int bx_soundlow_midiout_oss_c::openmidioutput(const char *mididev)
{
if ((mididev == NULL) || (strlen(mididev) < 1))
return BX_SOUNDLOW_ERR;
midi = fopen(mididev,"w");
if (midi == NULL) {
BX_ERROR(("Couldn't open midi output device %s: %s",
mididev, strerror(errno)));
return BX_SOUNDLOW_ERR;
}
return BX_SOUNDLOW_OK;
}
int bx_soundlow_midiout_oss_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
UNUSED(delta);
fputc(command, midi);
fwrite(data, 1, length, midi);
fflush(midi); // to start playing immediately
return BX_SOUNDLOW_OK;
}
int bx_soundlow_midiout_oss_c::closemidioutput()
{
if (midi != NULL) {
fclose(midi);
midi = NULL;
}
return BX_SOUNDLOW_OK;
}
// bx_sound_oss_c class implemenzation
bx_sound_oss_c::bx_sound_oss_c()
:bx_sound_lowlevel_c()
{
BX_INFO(("Sound lowlevel module 'oss' initialized"));
}
bx_soundlow_waveout_c* bx_sound_oss_c::get_waveout()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_oss_c();
}
return waveout;
}
bx_soundlow_wavein_c* bx_sound_oss_c::get_wavein()
{
if (wavein == NULL) {
wavein = new bx_soundlow_wavein_oss_c();
}
return wavein;
}
bx_soundlow_midiout_c* bx_sound_oss_c::get_midiout()
{
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_oss_c();
}
return midiout;
}
#endif

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2017 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/////////////////////////////////////////////////////////////////////////
// Josef Drexler coded the original version of the lowlevel sound support
// for Linux using OSS. The current version also supports OSS on FreeBSD.
#if BX_HAVE_SOUND_OSS
class bx_soundlow_waveout_oss_c : public bx_soundlow_waveout_c {
public:
bx_soundlow_waveout_oss_c();
virtual ~bx_soundlow_waveout_oss_c();
virtual int openwaveoutput(const char *wavedev);
virtual int set_pcm_params(bx_pcm_param_t *param);
virtual int output(int length, Bit8u data[]);
private:
int waveout_fd;
};
class bx_soundlow_wavein_oss_c : public bx_soundlow_wavein_c {
public:
bx_soundlow_wavein_oss_c();
virtual ~bx_soundlow_wavein_oss_c();
virtual int openwaveinput(const char *wavedev, sound_record_handler_t rh);
virtual int startwaverecord(bx_pcm_param_t *param);
virtual int getwavepacket(int length, Bit8u data[]);
virtual int stopwaverecord();
static void record_timer_handler(void *);
void record_timer(void);
private:
int wavein_fd;
bx_pcm_param_t wavein_param;
};
class bx_soundlow_midiout_oss_c : public bx_soundlow_midiout_c {
public:
bx_soundlow_midiout_oss_c();
virtual ~bx_soundlow_midiout_oss_c();
virtual int openmidioutput(const char *mididev);
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
private:
FILE *midi;
};
class bx_sound_oss_c : public bx_sound_lowlevel_c {
public:
bx_sound_oss_c();
virtual ~bx_sound_oss_c() {}
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
virtual bx_soundlow_midiout_c* get_midiout();
};
#endif

@ -20,12 +20,18 @@
// This file (SOUNDOSX.CC) written and donated by Brian Huffman
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#ifdef PARANOID
#include <MacTypes.h>
#endif
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundosx.h"
#if BX_HAVE_SOUND_OSX && BX_SUPPORT_SOUNDLOW
@ -76,6 +82,22 @@ AudioUnit WaveOutputUnit = NULL;
AudioConverterRef WaveConverter = NULL;
#endif
bx_sound_osx_c* osxSoundDriver = NULL;
// sound driver plugin entry points
int CDECL libosx_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
osxSoundDriver = new bx_sound_osx_c();
DEV_sound_register_driver(osxSoundDriver, BX_SOUNDDRV_OSX);
return 0; // Success
}
void CDECL libosx_sound_plugin_fini(void)
{
delete osxSoundDriver;
}
// bx_soundlow_waveout_osx_c class implemenzation
bx_soundlow_waveout_osx_c::bx_soundlow_waveout_osx_c()

@ -20,8 +20,14 @@
// Lowlevel sound output support for SDL written by Volker Ruppert
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundsdl.h"
#if BX_HAVE_SOUND_SDL && BX_SUPPORT_SOUNDLOW
@ -30,6 +36,22 @@
#include <SDL.h>
bx_sound_sdl_c* sdlSoundDriver = NULL;
// sound driver plugin entry points
int CDECL libsdl_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
sdlSoundDriver = new bx_sound_sdl_c();
DEV_sound_register_driver(sdlSoundDriver, BX_SOUNDDRV_SDL);
return 0; // Success
}
void CDECL libsdl_sound_plugin_fini(void)
{
delete sdlSoundDriver;
}
// SDL audio callback
void sdl_callback(void *thisptr, Bit8u *stream, int len)

@ -28,6 +28,7 @@
#include "iodev.h"
#include "soundlow.h"
#include "soundmod.h"
#include "soundwin.h"
#if BX_HAVE_SOUND_WIN && BX_SUPPORT_SOUNDLOW
@ -50,6 +51,22 @@
HANDLE DataHandle; // returned by GlobalAlloc()
Bit8u *DataPointer; // returned by GlobalLock()
bx_sound_windows_c* winSoundDriver = NULL;
// sound driver plugin entry points
int CDECL libwin_sound_plugin_init(plugin_t *plugin, plugintype_t type)
{
winSoundDriver = new bx_sound_windows_c();
DEV_sound_register_driver(winSoundDriver, BX_SOUNDDRV_WIN);
return 0; // Success
}
void CDECL libwin_sound_plugin_fini(void)
{
delete winSoundDriver;
}
// helper function
Bit8u* newbuffer(unsigned blksize)
{

@ -36,16 +36,20 @@
#define LOG_THIS genlog->
#define PLUGIN_INIT_FMT_STRING "lib%s_LTX_plugin_init"
#define PLUGIN_FINI_FMT_STRING "lib%s_LTX_plugin_fini"
#define GUI_PLUGIN_INIT_FMT_STRING "lib%s_gui_plugin_init"
#define GUI_PLUGIN_FINI_FMT_STRING "lib%s_gui_plugin_fini"
#define PLUGIN_PATH ""
#define PLUGIN_INIT_FMT_STRING "lib%s_LTX_plugin_init"
#define PLUGIN_FINI_FMT_STRING "lib%s_LTX_plugin_fini"
#define GUI_PLUGIN_INIT_FMT_STRING "lib%s_gui_plugin_init"
#define GUI_PLUGIN_FINI_FMT_STRING "lib%s_gui_plugin_fini"
#define SOUND_PLUGIN_INIT_FMT_STRING "lib%s_sound_plugin_init"
#define SOUND_PLUGIN_FINI_FMT_STRING "lib%s_sound_plugin_fini"
#define PLUGIN_PATH ""
#ifndef WIN32
#define PLUGIN_FILENAME_FORMAT "libbx_%s.so"
#define PLUGIN_FILENAME_FORMAT "libbx_%s.so"
#define SOUND_PLUGIN_FILENAME_FORMAT "libbx_sound%s.so"
#else
#define PLUGIN_FILENAME_FORMAT "bx_%s.dll"
#define PLUGIN_FILENAME_FORMAT "bx_%s.dll"
#define SOUND_PLUGIN_FILENAME_FORMAT "bx_sound%s.dll"
#endif
logfunctions *pluginlog;
@ -330,7 +334,11 @@ void plugin_load(char *name, plugintype_t type)
plugin->initialized = 0;
char plugin_filename[BX_PATHNAME_LEN], tmpname[BX_PATHNAME_LEN];
sprintf(tmpname, PLUGIN_FILENAME_FORMAT, name);
if (type != PLUGTYPE_SOUND) {
sprintf(tmpname, PLUGIN_FILENAME_FORMAT, name);
} else {
sprintf(tmpname, SOUND_PLUGIN_FILENAME_FORMAT, name);
}
sprintf(plugin_filename, "%s%s", PLUGIN_PATH, tmpname);
// Set context so that any devices that the plugin registers will
@ -354,7 +362,8 @@ void plugin_load(char *name, plugintype_t type)
BX_INFO(("DLL handle is %p", plugin->handle));
if (!plugin->handle) {
current_plugin_context = NULL;
BX_PANIC(("LoadLibrary failed for module '%s': error=%d", name, GetLastError()));
BX_PANIC(("LoadLibrary failed for module '%s' (%s): error=%d", name,
plugin_filename, GetLastError()));
delete plugin;
return;
}
@ -363,7 +372,8 @@ void plugin_load(char *name, plugintype_t type)
BX_INFO(("lt_dlhandle is %p", plugin->handle));
if (!plugin->handle) {
current_plugin_context = NULL;
BX_PANIC(("dlopen failed for module '%s': %s", name, lt_dlerror()));
BX_PANIC(("dlopen failed for module '%s' (%s): %s", name, plugin_filename,
lt_dlerror()));
delete plugin;
return;
}
@ -371,6 +381,8 @@ void plugin_load(char *name, plugintype_t type)
if (type == PLUGTYPE_GUI) {
sprintf(tmpname, GUI_PLUGIN_INIT_FMT_STRING, name);
} else if (type == PLUGTYPE_SOUND) {
sprintf(tmpname, SOUND_PLUGIN_INIT_FMT_STRING, name);
} else if (type != PLUGTYPE_USER) {
sprintf(tmpname, PLUGIN_INIT_FMT_STRING, name);
} else {
@ -392,6 +404,8 @@ void plugin_load(char *name, plugintype_t type)
if (type == PLUGTYPE_GUI) {
sprintf(tmpname, GUI_PLUGIN_FINI_FMT_STRING, name);
} else if (type == PLUGTYPE_SOUND) {
sprintf(tmpname, SOUND_PLUGIN_FINI_FMT_STRING, name);
} else if (type != PLUGTYPE_USER) {
sprintf(tmpname, PLUGIN_FINI_FMT_STRING, name);
} else {
@ -930,6 +944,60 @@ int bx_unload_opt_plugin(const char *name, bx_bool devflag)
return 0;
}
#define BUILTIN_SOUND_PLUGIN_ENTRY(mod) {#mod, lib##mod##_sound_plugin_init, lib##mod##_sound_plugin_fini, 0}
static builtin_plugin_t builtin_sound_plugins[] = {
#if BX_HAVE_SOUND_ALSA
BUILTIN_SOUND_PLUGIN_ENTRY(alsa),
#endif
#if BX_HAVE_SOUND_OSS
BUILTIN_SOUND_PLUGIN_ENTRY(oss),
#endif
#if BX_HAVE_SOUND_OSX
BUILTIN_SOUND_PLUGIN_ENTRY(osx),
#endif
#if BX_HAVE_SOUND_SDL
BUILTIN_SOUND_PLUGIN_ENTRY(sdl),
#endif
#if BX_HAVE_SOUND_WIN
BUILTIN_SOUND_PLUGIN_ENTRY(win),
#endif
BUILTIN_SOUND_PLUGIN_ENTRY(file),
{"NULL", NULL, NULL, 0}
};
int bx_load_sound_plugin(const char *name)
{
int i = 0;
while (strcmp(builtin_sound_plugins[i].name, "NULL")) {
if (!strcmp(name, builtin_sound_plugins[i].name)) {
if (builtin_sound_plugins[i].status == 0) {
builtin_sound_plugins[i].plugin_init(NULL, PLUGTYPE_SOUND);
builtin_sound_plugins[i].status = 1;
}
return 1;
}
i++;
};
return 0;
}
int bx_unload_sound_plugin(const char *name)
{
int i = 0;
while (strcmp(builtin_sound_plugins[i].name, "NULL")) {
if (!strcmp(name, builtin_sound_plugins[i].name)) {
if (builtin_sound_plugins[i].status == 1) {
builtin_sound_plugins[i].plugin_fini();
builtin_sound_plugins[i].status = 0;
}
return 1;
}
i++;
};
return 0;
}
#endif
}

@ -57,7 +57,6 @@ extern "C" {
#define BX_PLUGIN_PCI "pci"
#define BX_PLUGIN_PCI2ISA "pci2isa"
#define BX_PLUGIN_PCI_IDE "pci_ide"
#define BX_PLUGIN_SOUNDMOD "soundmod"
#define BX_PLUGIN_SB16 "sb16"
#define BX_PLUGIN_ES1370 "es1370"
#define BX_PLUGIN_NETMOD "netmod"
@ -88,9 +87,11 @@ extern "C" {
#define PLUG_load_plugin(name,type) {bx_load_plugin(#name,type);}
#define PLUG_load_gui_plugin(name) bx_load_plugin(name,PLUGTYPE_GUI)
#define PLUG_load_opt_plugin(name) bx_load_plugin(name,PLUGTYPE_OPTIONAL)
#define PLUG_load_sound_plugin(name) bx_load_plugin(name,PLUGTYPE_SOUND)
#define PLUG_load_user_plugin(name) {bx_load_plugin(name,PLUGTYPE_USER);}
#define PLUG_unload_plugin(name) {bx_unload_plugin(#name,1);}
#define PLUG_unload_opt_plugin(name) bx_unload_plugin(name,1)
#define PLUG_unload_sound_plugin(name) bx_unload_plugin(name,1)
#define PLUG_unload_user_plugin(name) {bx_unload_plugin(name,1);}
#define DEV_register_ioread_handler(b,c,d,e,f) pluginRegisterIOReadHandler(b,c,d,e,f)
@ -114,8 +115,10 @@ extern "C" {
#define PLUG_load_plugin(name,type) {lib##name##_LTX_plugin_init(NULL,type);}
#define PLUG_load_gui_plugin(name) bx_load_gui_plugin(name)
#define PLUG_load_opt_plugin(name) bx_load_opt_plugin(name)
#define PLUG_load_sound_plugin(name) bx_load_sound_plugin(name)
#define PLUG_unload_plugin(name) {lib##name##_LTX_plugin_fini();}
#define PLUG_unload_opt_plugin(name) bx_unload_opt_plugin(name,1);
#define PLUG_unload_sound_plugin(name) bx_unload_sound_plugin(name);
#define DEV_register_ioread_handler(b,c,d,e,f) bx_devices.register_io_read_handler(b,c,d,e,f)
#define DEV_register_iowrite_handler(b,c,d,e,f) bx_devices.register_io_write_handler(b,c,d,e,f)
#define DEV_unregister_ioread_handler(b,c,d,e) bx_devices.unregister_io_read_handler(b,c,d,e)
@ -258,9 +261,10 @@ extern "C" {
#define DEV_usb_send_msg(a,b) bx_devices.pluginUsbDevCtl->usb_send_msg((void*)a,b)
///////// Sound module macros
#define DEV_sound_get_waveout(a) (bx_devices.pluginSoundModCtl->get_waveout(a))
#define DEV_sound_get_wavein() (bx_devices.pluginSoundModCtl->get_wavein())
#define DEV_sound_get_midiout(a) (bx_devices.pluginSoundModCtl->get_midiout(a))
#define DEV_sound_register_driver(a,b) (bx_soundmod_ctl.register_driver(a,b))
#define DEV_sound_get_waveout(a) (bx_soundmod_ctl.get_waveout(a))
#define DEV_sound_get_wavein() (bx_soundmod_ctl.get_wavein())
#define DEV_sound_get_midiout(a) (bx_soundmod_ctl.get_midiout(a))
///////// Networking module macro
#define DEV_net_init_module(a,b,c,d) \
@ -355,7 +359,9 @@ extern void bx_plugins_after_restore_state(void);
#if !BX_PLUGINS
int bx_load_gui_plugin(const char *name);
int bx_load_opt_plugin(const char *name);
int bx_load_sound_plugin(const char *name);
int bx_unload_opt_plugin(const char *name, bx_bool devflag);
int bx_unload_sound_plugin(const char *name);
#endif
// every plugin must define these, within the extern"C" block, so that
@ -371,6 +377,9 @@ int plugin_init(plugin_t *plugin, plugintype_t type);
#define DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_gui_plugin_init(plugin_t *plugin, plugintype_t type); \
extern "C" __declspec(dllexport) void __cdecl lib##mod##_gui_plugin_fini(void);
#define DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(mod) \
extern "C" __declspec(dllexport) int __cdecl lib##mod##_sound_plugin_init(plugin_t *plugin, plugintype_t type); \
extern "C" __declspec(dllexport) void __cdecl lib##mod##_sound_plugin_fini(void);
#else
#define DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(mod) \
int CDECL lib##mod##_LTX_plugin_init(plugin_t *plugin, plugintype_t type); \
@ -378,6 +387,9 @@ int plugin_init(plugin_t *plugin, plugintype_t type);
#define DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(mod) \
int CDECL lib##mod##_gui_plugin_init(plugin_t *plugin, plugintype_t type); \
void CDECL lib##mod##_gui_plugin_fini(void);
#define DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(mod) \
int CDECL lib##mod##_sound_plugin_init(plugin_t *plugin, plugintype_t type); \
void CDECL lib##mod##_sound_plugin_fini(void);
#endif
// device plugins
@ -434,6 +446,13 @@ DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(vncsrv)
DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(win32)
DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(wx)
DECLARE_PLUGIN_INIT_FINI_FOR_GUI_MODULE(x)
// sound driver plugins
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(alsa)
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(file)
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(oss)
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(osx)
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(sdl)
DECLARE_PLUGIN_INIT_FINI_FOR_SOUND_MODULE(win)
#ifdef __cplusplus