diff --git a/bochs/iodev/Makefile.in b/bochs/iodev/Makefile.in index 0cfccd15f..05cac6586 100644 --- a/bochs/iodev/Makefile.in +++ b/bochs/iodev/Makefile.in @@ -428,8 +428,8 @@ sb16.o: sb16.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h soundlnx.h \ - soundwin.h soundosx.h + ../instrument/stubs/instrument.h ../param_names.h sb16.h soundmod.h \ + soundlnx.h soundwin.h soundosx.h scancodes.o: scancodes.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ @@ -460,17 +460,17 @@ soundlnx.o: soundlnx.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h soundlnx.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundlnx.h soundosx.o: soundosx.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundosx.h soundwin.o: soundwin.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundwin.h speaker.o: speaker.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ @@ -759,8 +759,8 @@ sb16.lo: sb16.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h soundlnx.h \ - soundwin.h soundosx.h + ../instrument/stubs/instrument.h ../param_names.h sb16.h soundmod.h \ + soundlnx.h soundwin.h soundosx.h scancodes.lo: scancodes.@CPP_SUFFIX@ ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ @@ -791,17 +791,17 @@ soundlnx.lo: soundlnx.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h soundlnx.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundlnx.h soundosx.lo: soundosx.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundosx.h soundwin.lo: soundwin.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ ../pc_system.h ../plugin.h ../extplugin.h ../ltdl.h ../gui/gui.h \ - ../instrument/stubs/instrument.h ../param_names.h sb16.h + ../instrument/stubs/instrument.h ../param_names.h soundmod.h soundwin.h speaker.lo: speaker.@CPP_SUFFIX@ iodev.h ../bochs.h ../config.h ../osdep.h \ ../bx_debug/debug.h ../config.h ../osdep.h ../bxversion.h \ ../gui/siminterface.h ../gui/paramtree.h ../memory/memory.h \ diff --git a/bochs/iodev/sb16.cc b/bochs/iodev/sb16.cc index c469ba950..89f3eba9b 100644 --- a/bochs/iodev/sb16.cc +++ b/bochs/iodev/sb16.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: sb16.cc,v 1.71 2011-01-25 23:29:08 vruppert Exp $ +// $Id: sb16.cc,v 1.72 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -3669,7 +3669,7 @@ int bx_sb16_buffer::commandbytes(void) } // The dummy output functions. They don't do anything -bx_sound_output_c::bx_sound_output_c(bx_sb16_c *dev) +bx_sound_output_c::bx_sound_output_c(logfunctions *dev) { device = dev; } diff --git a/bochs/iodev/sb16.h b/bochs/iodev/sb16.h index 7ee81c911..f6c82fd54 100644 --- a/bochs/iodev/sb16.h +++ b/bochs/iodev/sb16.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: sb16.h,v 1.36 2011-01-25 23:29:08 vruppert Exp $ +// $Id: sb16.h,v 1.37 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -71,11 +71,6 @@ emulated at adresses 0x388..0x38b, or two separate OPL2's. */ -// this is the size of a DMA chunk sent to output -// it should not be too large to avoid lag, and not too -// small to avoid unnecessary overhead. -#define BX_SOUND_OUTPUT_WAVEPACKETSIZE 8192 - #define BX_SB16_MIX_REG 0x100 // total number of mixer registers // The array containing an instrument/bank remapping @@ -376,14 +371,8 @@ private: }; #define BOTHLOG(x) (x) -#ifndef BX_SOUNDLOW #define WRITELOG (BX_SB16_THIS writelog) #define MIDILOG(x) ((BX_SB16_THIS midimode>0?x:0x7f)) #define WAVELOG(x) ((BX_SB16_THIS wavemode>0?x:0x7f)) -#else -#define WRITELOG (device->writelog) -#define MIDILOG(x) ((device->get_midimode()>0?x:0x7f)) -#define WAVELOG(x) ((device->get_wavemode()>0?x:0x7f)) -#endif #endif diff --git a/bochs/iodev/soundlnx.cc b/bochs/iodev/soundlnx.cc index 65ed2beef..01cb267d9 100644 --- a/bochs/iodev/soundlnx.cc +++ b/bochs/iodev/soundlnx.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundlnx.cc,v 1.23 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundlnx.cc,v 1.24 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -23,22 +23,20 @@ // for Linux using OSS. The current version also supports OSS on FreeBSD and // ALSA PCM output on Linux. -#include "iodev.h" -#define BX_SOUNDLOW -#include "sb16.h" -#include "soundmod.h" +#include "bochs.h" #if (defined(linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && BX_SUPPORT_SB16 #define LOG_THIS device-> +#include "soundmod.h" #include "soundlnx.h" #include #include #include -bx_sound_linux_c::bx_sound_linux_c(bx_sb16_c *dev) +bx_sound_linux_c::bx_sound_linux_c(logfunctions *dev) :bx_sound_output_c(dev) { #if BX_HAVE_ALSASOUND @@ -83,13 +81,13 @@ int bx_sound_linux_c::alsa_seq_open(char *alsadev) strcpy(mididev, alsadev); ptr = strtok(mididev, ":"); if (ptr == NULL) { - WRITELOG(MIDILOG(2), "ALSA sequencer setup: missing client parameters"); + BX_ERROR(("ALSA sequencer setup: missing client parameters")); return BX_SOUND_OUTPUT_ERR; } client = atoi(ptr); ptr = strtok(NULL, ":"); if (ptr == NULL) { - WRITELOG(MIDILOG(2), "ALSA sequencer setup: missing port parameter"); + BX_ERROR(("ALSA sequencer setup: missing port parameter")); return BX_SOUND_OUTPUT_ERR; } port = atoi(ptr); @@ -97,7 +95,7 @@ int bx_sound_linux_c::alsa_seq_open(char *alsadev) delete(mididev); if (snd_seq_open(&alsa_seq.handle, "default", SND_SEQ_OPEN_OUTPUT, 0) < 0) { - WRITELOG(MIDILOG(2), "Couldn't open ALSA sequencer for midi output"); + BX_ERROR(("Couldn't open ALSA sequencer for midi output")); return BX_SOUND_OUTPUT_ERR; } ret = snd_seq_create_simple_port(alsa_seq.handle, NULL, @@ -106,12 +104,12 @@ int bx_sound_linux_c::alsa_seq_open(char *alsadev) SND_SEQ_PORT_CAP_READ, SND_SEQ_PORT_TYPE_MIDI_GENERIC); if (ret < 0) { - WRITELOG(MIDILOG(2), "ALSA sequencer: error creating port %s\n", snd_strerror(errno)); + BX_ERROR(("ALSA sequencer: error creating port %s", snd_strerror(errno))); } else { alsa_seq.source_port = ret; ret = snd_seq_connect_to(alsa_seq.handle, alsa_seq.source_port, client, port); if (ret < 0) { - WRITELOG(MIDILOG(2), "ALSA sequencer: could not connect to port %d:%d\n", client, port); + BX_ERROR(("ALSA sequencer: could not connect to port %d:%d", client, port)); } } if (ret < 0) { @@ -137,11 +135,10 @@ int bx_sound_linux_c::openmidioutput(char *mididev) midi = fopen(mididev,"w"); - if (midi == NULL) - { - WRITELOG(MIDILOG(2), "Couldn't open midi output device %s: %s.", - mididev, strerror(errno)); - return BX_SOUND_OUTPUT_ERR; + if (midi == NULL) { + BX_ERROR(("Couldn't open midi output device %s: %s", + mididev, strerror(errno))); + return BX_SOUND_OUTPUT_ERR; } return BX_SOUND_OUTPUT_OK; @@ -205,10 +202,10 @@ int bx_sound_linux_c::alsa_seq_output(int delta, int command, int length, Bit8u ev.data.control.value = value; break; case 0xf0: - WRITELOG(MIDILOG(3), "alsa_seq_output(): SYSEX not implemented, length=%d", length); + BX_ERROR(("alsa_seq_output(): SYSEX not implemented, length=%d", length)); return BX_SOUND_OUTPUT_ERR; default: - WRITELOG(MIDILOG(3), "alsa_seq_output(): unknown command 0x%02x, length=%d", command, length); + BX_ERROR(("alsa_seq_output(): unknown command 0x%02x, length=%d", command, length)); return BX_SOUND_OUTPUT_ERR; } snd_seq_event_output(alsa_seq.handle, &ev); @@ -288,7 +285,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for if (ret < 0) { return BX_SOUND_OUTPUT_ERR; } - WRITELOG(WAVELOG(1), "ALSA: opened default PCM output device"); + BX_ERROR(("ALSA: opened default PCM output device")); } snd_pcm_hw_params_alloca(¶ms); snd_pcm_hw_params_any(alsa_pcm.handle, params); @@ -337,7 +334,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for } snd_pcm_hw_params_get_period_size(params, &alsa_pcm.frames, &dir); alsa_bufsize = alsa_pcm.frames * size; - WRITELOG(WAVELOG(4), "ALSA: buffer size set to %d", alsa_bufsize); + BX_DEBUG(("ALSA: buffer size set to %d", alsa_bufsize)); if (alsa_buffer != NULL) { free(alsa_buffer); alsa_buffer = NULL; @@ -365,7 +362,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int if (wave == -1) { return BX_SOUND_OUTPUT_ERR; } else { - WRITELOG(WAVELOG(1), "OSS: opened output device %s", wavedevice); + BX_INFO(("OSS: opened output device %s", wavedevice)); } } else { if ((frequency == oldfreq) && @@ -395,7 +392,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int // set frequency etc. ret = ioctl(wave, SNDCTL_DSP_RESET); if (ret != 0) - WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)); + BX_DEBUG(("ioctl(SNDCTL_DSP_RESET): %s", strerror(errno))); /* ret = ioctl(wave, SNDCTL_DSP_SETFRAGMENT, &fragment); @@ -407,20 +404,20 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int ret = ioctl(wave, SNDCTL_DSP_SETFMT, &fmt); if (ret != 0) // abort if the format is unknown, to avoid playing noise { - WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_SETFMT, %d): %s", - fmt, strerror(errno)); + BX_DEBUG(("ioctl(SNDCTL_DSP_SETFMT, %d): %s", + fmt, strerror(errno))); return BX_SOUND_OUTPUT_ERR; } ret = ioctl(wave, SNDCTL_DSP_STEREO, &stereo); if (ret != 0) - WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_STEREO, %d): %s", - stereo, strerror(errno)); + BX_DEBUG(("ioctl(SNDCTL_DSP_STEREO, %d): %s", + stereo, strerror(errno))); ret = ioctl(wave, SNDCTL_DSP_SPEED, &frequency); if (ret != 0) - WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_SPEED, %d): %s", - frequency, strerror(errno)); + BX_DEBUG(("ioctl(SNDCTL_DSP_SPEED, %d): %s", + frequency, strerror(errno))); // ioctl(wave, SNDCTL_DSP_GETBLKSIZE, &fragment); // WRITELOG(WAVELOG(4), "current output block size is %d", fragment); @@ -441,12 +438,12 @@ int bx_sound_linux_c::alsa_pcm_write() ret = snd_pcm_writei(alsa_pcm.handle, alsa_buffer, alsa_pcm.frames); if (ret == -EPIPE) { /* EPIPE means underrun */ - WRITELOG(WAVELOG(3), "ALSA: underrun occurred"); + BX_ERROR(("ALSA: underrun occurred")); snd_pcm_prepare(alsa_pcm.handle); } else if (ret < 0) { - WRITELOG(WAVELOG(3), "ALSA: error from writei: %s", snd_strerror(ret)); + BX_ERROR(("ALSA: error from writei: %s", snd_strerror(ret))); } else if (ret != (int)alsa_pcm.frames) { - WRITELOG(WAVELOG(3), "ALSA: short write, write %d frames", ret); + BX_ERROR(("ALSA: short write, write %d frames", ret)); } audio_bufsize -= alsa_bufsize; memcpy(audio_buffer, audio_buffer+alsa_bufsize, audio_bufsize); @@ -468,7 +465,7 @@ int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[]) memcpy(audio_buffer+audio_bufsize, data, length); audio_bufsize += length; } else { - WRITELOG(WAVELOG(3), "ALSA: audio buffer overflow"); + BX_ERROR(("ALSA: audio buffer overflow")); return BX_SOUND_OUTPUT_ERR; } if (audio_bufsize < alsa_bufsize) { @@ -483,7 +480,7 @@ int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[]) if (ret == length) { return BX_SOUND_OUTPUT_OK; } else { - WRITELOG(WAVELOG(3), "OSS: write error"); + BX_ERROR(("OSS: write error")); return BX_SOUND_OUTPUT_ERR; } } diff --git a/bochs/iodev/soundlnx.h b/bochs/iodev/soundlnx.h index e08871760..98b81c2c0 100644 --- a/bochs/iodev/soundlnx.h +++ b/bochs/iodev/soundlnx.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundlnx.h,v 1.15 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundlnx.h,v 1.16 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -35,7 +35,7 @@ class bx_sound_linux_c : public bx_sound_output_c { public: - bx_sound_linux_c(bx_sb16_c *dev); + bx_sound_linux_c(logfunctions *dev); virtual ~bx_sound_linux_c(); virtual int waveready(); diff --git a/bochs/iodev/soundmod.h b/bochs/iodev/soundmod.h index 592e16a7b..f0020d3e0 100644 --- a/bochs/iodev/soundmod.h +++ b/bochs/iodev/soundmod.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundmod.h,v 1.1 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundmod.h,v 1.2 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011 The Bochs Project @@ -19,6 +19,11 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// this is the size of a DMA chunk sent to output +// it should not be too large to avoid lag, and not too +// small to avoid unnecessary overhead. +#define BX_SOUND_OUTPUT_WAVEPACKETSIZE 8192 + /* Definitions for the output functions */ #define BX_SOUND_OUTPUT_OK 0 #define BX_SOUND_OUTPUT_ERR 1 @@ -34,7 +39,7 @@ public: non-portable, while everything in sb16.cc is portable */ - bx_sound_output_c(bx_sb16_c *dev); + bx_sound_output_c(logfunctions *dev); virtual ~bx_sound_output_c(); virtual int waveready(); @@ -50,5 +55,5 @@ public: virtual int stopwaveplayback(); virtual int closewaveoutput(); protected: - bx_sb16_c *device; + logfunctions *device; }; diff --git a/bochs/iodev/soundosx.cc b/bochs/iodev/soundosx.cc index 83c855ee6..ebcab90a4 100644 --- a/bochs/iodev/soundosx.cc +++ b/bochs/iodev/soundosx.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundosx.cc,v 1.14 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundosx.cc,v 1.15 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004-2011 The Bochs Project @@ -24,15 +24,13 @@ #include #endif -#include "iodev.h" -#define BX_SOUNDLOW -#include "sb16.h" -#include "soundmod.h" +#include "bochs.h" #if defined(macintosh) && BX_SUPPORT_SB16 #define LOG_THIS device-> +#include "soundmod.h" #include "soundosx.h" #if BX_WITH_MACOS @@ -71,7 +69,7 @@ AudioUnit WaveOutputUnit = NULL; AudioConverterRef WaveConverter = NULL; #endif -bx_sound_osx_c::bx_sound_osx_c(bx_sb16_c *dev) +bx_sound_osx_c::bx_sound_osx_c(logfunctions *dev) :bx_sound_output_c(dev) { MidiOpen = 0; @@ -136,14 +134,14 @@ int bx_sound_osx_c::openmidioutput(char *mididev) // Start playing AUGraphStart (MidiGraph); #endif - WRITELOG(WAVELOG(4), "openmidioutput(%s)", mididev); + BX_DEBUG(("openmidioutput(%s)", mididev)); MidiOpen = 1; return BX_SOUND_OUTPUT_OK; } int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[]) { - WRITELOG(WAVELOG(5), "sendmidicommand(%i,%02x,%i)", delta, command, length); + BX_DEBUG(("sendmidicommand(%i,%02x,%i)", delta, command, length)); if (!MidiOpen) return BX_SOUND_OUTPUT_ERR; #ifdef BX_SOUND_OSX_use_converter @@ -161,7 +159,7 @@ int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u da int bx_sound_osx_c::closemidioutput() { - WRITELOG(WAVELOG(4), "closemidioutput()"); + BX_DEBUG(("closemidioutput()")); MidiOpen = 0; #ifdef BX_SOUND_OSX_use_converter AUGraphStop (MidiGraph); @@ -186,7 +184,7 @@ int bx_sound_osx_c::openwaveoutput(char *wavedev) { OSStatus err; - WRITELOG(WAVELOG(4), "openwaveoutput(%s)", wavedev); + BX_DEBUG(("openwaveoutput(%s)", wavedev)); // open the default output unit #ifdef BX_SOUND_OSX_use_quicktime @@ -218,7 +216,7 @@ int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int f UInt32 formatSize = sizeof(AudioStreamBasicDescription); #endif - WRITELOG(WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format); + BX_DEBUG(("startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format)); #ifdef BX_SOUND_OSX_use_quicktime WaveInfo.samplePtr = NULL; @@ -309,7 +307,7 @@ int bx_sound_osx_c::sendwavepacket(int length, Bit8u data[]) SndCommand mySndCommand; #endif - WRITELOG(WAVELOG(4), "sendwavepacket(%d, %p), head=%u", length, data, head); + BX_DEBUG(("sendwavepacket(%d, %p), head=%u", length, data, head)); // sanity check if ((!WaveOpen) || (head - tail >= BX_SOUND_OSX_NBUF)) @@ -390,7 +388,7 @@ OSStatus MyACInputProc (AudioConverterRef inAudioConverter, void bx_sound_osx_c::nextbuffer (int *outDataSize, void **outData) { - WRITELOG(WAVELOG(4), "nextbuffer(), tail=%u", tail); + BX_DEBUG(("nextbuffer(), tail=%u", tail)); if (head - tail <= 0) { *outData = NULL; *outDataSize = 0; diff --git a/bochs/iodev/soundosx.h b/bochs/iodev/soundosx.h index f772752ab..35ac774a6 100644 --- a/bochs/iodev/soundosx.h +++ b/bochs/iodev/soundosx.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundosx.h,v 1.5 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundosx.h,v 1.6 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004-2011 The Bochs Project @@ -37,7 +37,7 @@ class bx_sound_osx_c : public bx_sound_output_c { public: - bx_sound_osx_c(bx_sb16_c *dev); + bx_sound_osx_c(logfunctions *dev); virtual ~bx_sound_osx_c(); virtual int waveready(); diff --git a/bochs/iodev/soundwin.cc b/bochs/iodev/soundwin.cc index 0cecd93f5..7bcb44cc9 100644 --- a/bochs/iodev/soundwin.cc +++ b/bochs/iodev/soundwin.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundwin.cc,v 1.27 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundwin.cc,v 1.28 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -26,18 +26,16 @@ // is used to know when we are exporting symbols and when we are importing. #define BX_PLUGGABLE -#include "iodev.h" -#define BX_SOUNDLOW -#include "sb16.h" -#include "soundmod.h" +#include "bochs.h" #if defined(WIN32) && BX_SUPPORT_SB16 +#include "soundmod.h" #include "soundwin.h" #define LOG_THIS device-> -bx_sound_windows_c::bx_sound_windows_c(bx_sb16_c *dev) +bx_sound_windows_c::bx_sound_windows_c(logfunctions *dev) :bx_sound_output_c(dev) { MidiOpen = 0; @@ -126,7 +124,7 @@ int bx_sound_windows_c::openmidioutput(char *mididev) if (ret == 0) MidiOpen = 1; - WRITELOG(MIDILOG(4), "midiOutOpen() = %d, MidiOpen: %d", ret, MidiOpen); + BX_DEBUG(("midiOutOpen() = %d, MidiOpen: %d", ret, MidiOpen)); return (MidiOpen == 1) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; } @@ -140,7 +138,7 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8 if ((command == 0xf0) || (command == 0xf7) || (length > 3)) { - WRITELOG(WAVELOG(5), "SYSEX started, length %d", length); + BX_DEBUG(("SYSEX started, length %d", length)); ismidiready = 0; // until the buffer is done memcpy(MidiData, data, length); MidiHeader->lpData = MidiData; @@ -150,10 +148,10 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8 MidiHeader->dwFlags = 0; ret = midiOutPrepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader)); if (ret != 0) - WRITELOG(MIDILOG(2), "midiOutPrepareHeader() = %d", ret); + BX_ERROR(("midiOutPrepareHeader() = %d", ret)); ret = midiOutLongMsg(MidiOut, MidiHeader, sizeof(*MidiHeader)); if (ret != 0) - WRITELOG(MIDILOG(2), "midiOutLongMsg() = %d", ret); + BX_ERROR(("midiOutLongMsg() = %d", ret)); } else { @@ -163,7 +161,7 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8 msg |= (data[i] << (8 * (i + 1))); ret = midiOutShortMsg(MidiOut, msg); - WRITELOG(MIDILOG(4), "midiOutShortMsg(%x) = %d", msg, ret); + BX_DEBUG(("midiOutShortMsg(%x) = %d", msg, ret)); } return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; @@ -181,7 +179,7 @@ int bx_sound_windows_c::closemidioutput() checkmidiready(); // to clear any pending SYSEX ret = midiOutClose(MidiOut); - WRITELOG(MIDILOG(4), "midiOutClose() = %d", ret); + BX_DEBUG(("midiOutClose() = %d", ret)); MidiOpen = 0; return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; @@ -193,7 +191,7 @@ int bx_sound_windows_c::openwaveoutput(char *wavedev) // but currently only the wave mapper is supported UNUSED(wavedev); - WRITELOG(WAVELOG(4), "openwaveoutput(%s)", wavedev); + BX_DEBUG(("openwaveoutput(%s)", wavedev)); #ifdef usewaveOut WaveDevice = (UINT) WAVEMAPPER; @@ -260,7 +258,7 @@ int bx_sound_windows_c::playnextbuffer() { char errormsg[4*MAXERRORLENGTH+1]; waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1); - WRITELOG(WAVELOG(5), "waveOutOpen: %s", errormsg); + BX_DEBUG(("waveOutOpen: %s", errormsg)); switch (tries) { case 0: // maybe try a different frequency if (frequency < 15600) @@ -270,7 +268,7 @@ int bx_sound_windows_c::playnextbuffer() else frequency = 44100; - WRITELOG(WAVELOG(4), "Couldn't open wave device (error %d), trying frequency %d", ret, frequency); + BX_DEBUG(("Couldn't open wave device (error %d), trying frequency %d", ret, frequency)); break; case 1: // or something else @@ -279,18 +277,18 @@ int bx_sound_windows_c::playnextbuffer() bits = 8; bps = 1; - WRITELOG(WAVELOG(4), "Couldn't open wave device again (error %d), trying 11KHz, mono, 8bit", ret); + BX_DEBUG(("Couldn't open wave device again (error %d), trying 11KHz, mono, 8bit", ret)); break; case 2: // nope, doesn't work - WRITELOG(WAVELOG(2), "Couldn't open wave device (error %d)!", ret); + BX_ERROR(("Couldn't open wave device (error %d)!", ret)); return BX_SOUND_OUTPUT_ERR; } - WRITELOG(WAVELOG(5), "The format was: wFormatTag=%d, nChannels=%d, nSamplesPerSec=%d,", - waveformat.wf.wFormatTag, waveformat.wf.nChannels, waveformat.wf.nSamplesPerSec); - WRITELOG(WAVELOG(5), " nAvgBytesPerSec=%d, nBlockAlign=%d, wBitsPerSample=%d", - waveformat.wf.nAvgBytesPerSec, waveformat.wf.nBlockAlign, waveformat.wBitsPerSample); + BX_DEBUG(("The format was: wFormatTag=%d, nChannels=%d, nSamplesPerSec=%d,", + waveformat.wf.wFormatTag, waveformat.wf.nChannels, waveformat.wf.nSamplesPerSec)); + BX_DEBUG((" nAvgBytesPerSec=%d, nBlockAlign=%d, wBitsPerSample=%d", + waveformat.wf.nAvgBytesPerSec, waveformat.wf.nBlockAlign, waveformat.wBitsPerSample)); } else { @@ -304,7 +302,7 @@ int bx_sound_windows_c::playnextbuffer() for (bufnum=tailplay; bufnum != head; bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK, tailplay=bufnum) { - WRITELOG(WAVELOG(5), "Playing buffer %d", bufnum); + BX_DEBUG(("Playing buffer %d", bufnum)); // prepare the wave header WaveHeader[bufnum]->lpData = WaveData[bufnum]; @@ -317,7 +315,7 @@ int bx_sound_windows_c::playnextbuffer() ret = waveOutPrepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum])); if (ret != 0) { - WRITELOG(WAVELOG(2), "waveOutPrepareHeader = %d", ret); + BX_ERROR(("waveOutPrepareHeader = %d", ret)); return BX_SOUND_OUTPUT_ERR; } @@ -326,7 +324,7 @@ int bx_sound_windows_c::playnextbuffer() { char errormsg[4*MAXERRORLENGTH+1]; waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1); - WRITELOG(WAVELOG(5), "waveOutWrite: %s", errormsg); + BX_DEBUG(("waveOutWrite: %s", errormsg)); } } @@ -335,7 +333,7 @@ int bx_sound_windows_c::playnextbuffer() int bx_sound_windows_c::startwaveplayback(int frequency, int bits, int stereo, int format) { - WRITELOG(WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format); + BX_DEBUG(("startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format)); #ifdef usewaveOut // check if any of the properties have changed @@ -383,7 +381,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[]) UINT ret; #endif - WRITELOG(WAVELOG(4), "sendwavepacket(%d, %p)", length, data); + BX_DEBUG(("sendwavepacket(%d, %p)", length, data)); #ifdef usewaveOut bufnum = head; @@ -397,7 +395,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[]) if (((bufnum + 1) & BX_SOUND_WINDOWS_NMASK) == tailfull) { // this should not actually happen! - WRITELOG(WAVELOG(2), "Output buffer overflow! Not played. Iswaveready was %d", iswaveready); + BX_ERROR(("Output buffer overflow! Not played. Iswaveready was %d", iswaveready)); iswaveready = 0; // stop the output for a while return BX_SOUND_OUTPUT_ERR; } @@ -407,8 +405,8 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[]) // check if more buffers are available, otherwise stall the emulator if (((bufnum + 2) & BX_SOUND_WINDOWS_NMASK) == tailfull) { - WRITELOG(WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Stall.", - head, tailfull, tailplay); + BX_DEBUG(("Buffer status: Head %d, TailFull %d, TailPlay %d. Stall.", + head, tailfull, tailplay)); iswaveready = 0; } @@ -426,7 +424,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[]) ret = sndPlaySoundA((LPCSTR) header, SND_SYNC | SND_MEMORY); if (ret != 0) { - WRITELOG(WAVELOG(3), "sndPlaySoundA: %d", ret); + BX_DEBUG(("sndPlaySoundA: %d", ret)); } #endif @@ -435,7 +433,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[]) int bx_sound_windows_c::stopwaveplayback() { - WRITELOG(WAVELOG(4), "stopwaveplayback()"); + BX_DEBUG(("stopwaveplayback()")); #ifdef usewaveOut // this is handled by checkwaveready() when closing @@ -452,7 +450,7 @@ int bx_sound_windows_c::stopwaveplayback() int bx_sound_windows_c::closewaveoutput() { - WRITELOG(WAVELOG(4), "closewaveoutput"); + BX_DEBUG(("closewaveoutput")); #ifdef usewaveOut if (WaveOpen == 1) @@ -480,7 +478,7 @@ void bx_sound_windows_c::checkmidiready() if ((MidiHeader->dwFlags & MHDR_DONE) != 0) { - WRITELOG(MIDILOG(5), "SYSEX message done, midi ready again."); + BX_DEBUG(("SYSEX message done, midi ready again")); ret = midiOutUnprepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader)); ismidiready = 1; } @@ -495,7 +493,7 @@ void bx_sound_windows_c::checkwaveready() ((WaveHeader[bufnum]->dwFlags & WHDR_DONE) != 0); bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK) { - WRITELOG(WAVELOG(5), "Buffer %d done.", bufnum); + BX_DEBUG(("Buffer %d done.", bufnum)); ret = waveOutUnprepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum])); } @@ -504,8 +502,8 @@ void bx_sound_windows_c::checkwaveready() // enable gathering data if a buffer is available if (((head + 2) & BX_SOUND_WINDOWS_NMASK) != tailfull) { - WRITELOG(WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Ready.", - head, tailfull, tailplay); + BX_DEBUG(("Buffer status: Head %d, TailFull %d, TailPlay %d. Ready.", + head, tailfull, tailplay)); iswaveready = 1; } } diff --git a/bochs/iodev/soundwin.h b/bochs/iodev/soundwin.h index 94fb02fc0..7b97ac9df 100644 --- a/bochs/iodev/soundwin.h +++ b/bochs/iodev/soundwin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: soundwin.h,v 1.9 2011-01-25 23:29:08 vruppert Exp $ +// $Id: soundwin.h,v 1.10 2011-02-10 22:58:22 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2011 The Bochs Project @@ -31,7 +31,7 @@ #define BX_SOUND_WINDOWS_MAXSYSEXLEN 256 // maximum supported length of a sysex message -#define BX_SOUND_WINDOWS_NBUF 4 // number of buffers for the output, must be power of 2 and >= 4 +#define BX_SOUND_WINDOWS_NBUF 64 // number of buffers for the output, must be power of 2 and >= 4 #define BX_SOUND_WINDOWS_NMASK (BX_SOUND_WINDOWS_NBUF - 1) #ifndef WAVEMAPPER @@ -166,7 +166,7 @@ typedef struct { class bx_sound_windows_c : public bx_sound_output_c { public: - bx_sound_windows_c(bx_sb16_c *dev); + bx_sound_windows_c(logfunctions *dev); virtual ~bx_sound_windows_c(); virtual int waveready();