- renamed some symbols from BX_SOUND_OUTPUT_* to BX_SOUNDLOW_*

- es1370: fixed transfer size for the ADC channel
- es1370: call startwaveplayback() when the DAC2 channel is activated
- added missing change to BX_SUPPORT_SOUNDLOW
- changed type of variable "stereo" to bx_bool
- minor other changes
This commit is contained in:
Volker Ruppert 2011-03-20 18:02:12 +00:00
parent bcd15ddf31
commit 932df44658
11 changed files with 149 additions and 149 deletions

View File

@ -422,7 +422,7 @@ void bx_es1370_c::es1370_timer(void)
unsigned i;
Bit32u new_status = BX_ES1370_THIS s.status;
Bit32u addr, sc, csc_bytes, cnt, size, left, transfered, temp;
Bit8u tmpbuf[BX_SOUND_OUTPUT_WAVEPACKETSIZE];
Bit8u tmpbuf[BX_SOUNDLOW_WAVEPACKETSIZE];
bx_bool irq = 0;
timer_id = bx_pc_system.triggeredTimerID();
@ -447,12 +447,12 @@ void bx_es1370_c::es1370_timer(void)
size = d->frame_cnt & 0xffff;
left = ((size - cnt + 1) << 2) + d->leftover;
transfered = 0;
temp = BX_MIN(BX_SOUND_OUTPUT_WAVEPACKETSIZE, BX_MIN(left, csc_bytes));
temp = BX_MIN(BX_SOUNDLOW_WAVEPACKETSIZE, BX_MIN(left, csc_bytes));
addr += (cnt << 2) + d->leftover;
if (i == ADC_CHANNEL) {
// TODO: audio input
transfered = BX_SOUND_OUTPUT_WAVEPACKETSIZE;
transfered = temp;
memset(tmpbuf, 0, transfered);
DEV_MEM_WRITE_PHYSICAL_BLOCK(addr, transfered, tmpbuf);
} else {
@ -558,20 +558,12 @@ void bx_es1370_c::update_voices(Bit32u ctl, Bit32u sctl)
if (i == DAC2_CHANNEL) {
if (!BX_ES1370_THIS s.dac2_outputinit) {
ret = BX_ES1370_THIS soundmod->openwaveoutput(SIM->get_param_string(BXPN_ES1370_WAVEDEV)->getptr());
if (ret != BX_SOUND_OUTPUT_OK) {
if (ret != BX_SOUNDLOW_OK) {
BX_ERROR(("could not open wave output device"));
} else {
BX_ES1370_THIS s.dac2_outputinit = 1;
}
}
if (BX_ES1370_THIS s.dac2_outputinit) {
ret = BX_ES1370_THIS soundmod->startwaveplayback(new_freq, (new_fmt >> 1) ? 16 : 8, (new_fmt & 1), (new_fmt >> 1));
if (ret != BX_SOUND_OUTPUT_OK) {
BX_ES1370_THIS soundmod->closewaveoutput();
BX_ES1370_THIS s.dac2_outputinit = 0;
BX_ERROR(("could not start wave playback"));
}
}
}
}
}
@ -591,8 +583,15 @@ void bx_es1370_c::update_voices(Bit32u ctl, Bit32u sctl)
chan_name[i], new_freq, 1 << (new_fmt & 1), (new_fmt & 2) ? 16 : 8, d->shift));
if (i != DAC2_CHANNEL) {
BX_ERROR(("channel %s not supported yet", chan_name[i]));
} else if (BX_ES1370_THIS s.dac2_outputinit) {
ret = BX_ES1370_THIS soundmod->startwaveplayback(new_freq, (new_fmt >> 1) ? 16 : 8, (new_fmt & 1), (new_fmt >> 1));
if (ret != BX_SOUNDLOW_OK) {
BX_ES1370_THIS soundmod->closewaveoutput();
BX_ES1370_THIS s.dac2_outputinit = 0;
BX_ERROR(("could not start wave playback"));
}
}
timer_val = (Bit64u)BX_SOUND_OUTPUT_WAVEPACKETSIZE * 1000000 / (new_freq << d->shift);
timer_val = (Bit64u)BX_SOUNDLOW_WAVEPACKETSIZE * 1000000 / (new_freq << d->shift);
bx_pc_system.activate_timer(timer_id, timer_val, 1);
} else {
if ((i == DAC2_CHANNEL) && BX_ES1370_THIS s.dac2_outputinit) {

View File

@ -161,7 +161,7 @@ void bx_sb16_c::init(void)
BX_SB16_THIS wavemode = 0;
}
DSP.dma.chunk = new Bit8u[BX_SOUND_OUTPUT_WAVEPACKETSIZE];
DSP.dma.chunk = new Bit8u[BX_SOUNDLOW_WAVEPACKETSIZE];
DSP.dma.chunkindex = 0;
DSP.outputinit = 0;
MPU.outputinit = 0;
@ -335,7 +335,7 @@ void bx_sb16_c::register_state(void)
new bx_shadow_num_c(dma, "blocklength", &DSP.dma.blocklength);
new bx_shadow_num_c(dma, "samplerate", &DSP.dma.samplerate);
new bx_shadow_bool_c(dsp, "outputinit", &DSP.outputinit);
new bx_shadow_data_c(list, "chunk", DSP.dma.chunk, BX_SOUND_OUTPUT_WAVEPACKETSIZE);
new bx_shadow_data_c(list, "chunk", DSP.dma.chunk, BX_SOUNDLOW_WAVEPACKETSIZE);
bx_list_c *csp = new bx_list_c(list, "csp_reg", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
@ -435,9 +435,9 @@ void bx_sb16_c::dsp_dmatimer(void *this_ptr)
// output buffer and the output functions are not ready yet.
if ((BX_SB16_THIS wavemode != 1) ||
((This->dsp.dma.chunkindex + 1 < BX_SOUND_OUTPUT_WAVEPACKETSIZE) &&
((This->dsp.dma.chunkindex + 1 < BX_SOUNDLOW_WAVEPACKETSIZE) &&
(This->dsp.dma.count > 0)) ||
(BX_SB16_OUTPUT->waveready() == BX_SOUND_OUTPUT_OK)) {
(BX_SB16_OUTPUT->waveready() == BX_SOUNDLOW_OK)) {
if ((DSP.dma.bits == 8) || (BX_SB16_DMAH == 0)) {
DEV_dma_set_drq(BX_SB16_DMAL, 1);
} else {
@ -1129,13 +1129,13 @@ void bx_sb16_c::dsp_dma(Bit8u command, Bit8u mode, Bit16u length, Bit8u comp)
if (BX_SB16_THIS wavemode == 1) {
if (DSP.outputinit == 0) {
ret = BX_SB16_OUTPUT->openwaveoutput(SIM->get_param_string(BXPN_SB16_WAVEFILE)->getptr());
if (ret != BX_SOUND_OUTPUT_OK) {
if (ret != BX_SOUNDLOW_OK) {
BX_SB16_THIS wavemode = 0;
writelog(WAVELOG(2), "Error: Could not open wave output device.");
} else {
DSP.outputinit = 1;
ret = BX_SB16_OUTPUT->startwaveplayback(DSP.dma.samplerate, DSP.dma.bits, DSP.dma.stereo, DSP.dma.format);
if (ret != BX_SOUND_OUTPUT_OK) {
if (ret != BX_SOUNDLOW_OK) {
BX_SB16_THIS wavemode = 0;
writelog(WAVELOG(2), "Error: Could not start wave playback.");
}
@ -1253,10 +1253,10 @@ void bx_sb16_c::dsp_getwavepacket()
if (DSP.dma.bits == 8)
byteA = byteB;
for (int i = 0; i < BX_SOUND_OUTPUT_WAVEPACKETSIZE; i++)
for (int i = 0; i < BX_SOUNDLOW_WAVEPACKETSIZE; i++)
DSP.dma.chunk[i] = ((i & 1) == 0) ? byteA : byteB;
DSP.dma.chunkcount = BX_SOUND_OUTPUT_WAVEPACKETSIZE;
DSP.dma.chunkcount = BX_SOUNDLOW_WAVEPACKETSIZE;
DSP.dma.chunkindex = 0;
}
@ -1300,10 +1300,10 @@ void bx_sb16_c::dsp_sendwavepacket()
// put a sample byte into the output buffer
void bx_sb16_c::dsp_getsamplebyte(Bit8u value)
{
if (DSP.dma.chunkindex < BX_SOUND_OUTPUT_WAVEPACKETSIZE)
if (DSP.dma.chunkindex < BX_SOUNDLOW_WAVEPACKETSIZE)
DSP.dma.chunk[DSP.dma.chunkindex++] = value;
if (DSP.dma.chunkindex >= BX_SOUND_OUTPUT_WAVEPACKETSIZE)
if (DSP.dma.chunkindex >= BX_SOUNDLOW_WAVEPACKETSIZE)
dsp_sendwavepacket();
}
@ -1707,7 +1707,7 @@ Bit32u bx_sb16_c::mpu_status()
if ((MPU.datain.full() == 1) ||
((BX_SB16_THIS midimode == 1) &&
(BX_SB16_OUTPUT->midiready() == BX_SOUND_OUTPUT_ERR)))
(BX_SB16_OUTPUT->midiready() == BX_SOUNDLOW_ERR)))
result |= 0x40; // output not ready
if (MPU.dataout.empty() == 1)
result |= 0x80; // no input available
@ -2880,7 +2880,7 @@ void bx_sb16_c::writemidicommand(int command, int length, Bit8u data[])
if (BX_SB16_THIS midimode == 1) {
if (MPU.outputinit != 1) {
writelog(MIDILOG(4), "Initializing Midi output.");
if (BX_SB16_OUTPUT->openmidioutput(SIM->get_param_string(BXPN_SB16_MIDIFILE)->getptr()) == BX_SOUND_OUTPUT_OK)
if (BX_SB16_OUTPUT->openmidioutput(SIM->get_param_string(BXPN_SB16_MIDIFILE)->getptr()) == BX_SOUNDLOW_OK)
MPU.outputinit = 1;
else
MPU.outputinit = 0;

View File

@ -190,7 +190,7 @@ private:
int midimode, wavemode, loglevel;
Bit32u dmatimer;
FILE *logfile, *midifile, *wavefile; // the output files or devices
bx_sound_lowlevel_c *soundmod;// the output class
bx_sound_lowlevel_c *soundmod; // the lowlevel class
int currentirq;
int currentdma8;
int currentdma16;
@ -231,8 +231,8 @@ private:
int mode, bits, bps, format, timer;
bx_bool fifo, output, stereo, issigned, highspeed;
Bit16u count; // bytes remaining in this transfer
Bit8u *chunk; // buffers up to BX_SOUND_OUTPUT_WAVEPACKETSIZE bytes
int chunkindex; // index into the buffer
Bit8u *chunk; // buffers up to BX_SOUNDLOW_WAVEPACKETSIZE bytes
int chunkindex; // index into the buffer
int chunkcount; // for input: size of the recorded input
Bit16u timeconstant;
Bit16u blocklength, samplerate;

View File

@ -58,12 +58,12 @@ bx_sound_linux_c::~bx_sound_linux_c()
int bx_sound_linux_c::waveready()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_linux_c::midiready()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#if BX_HAVE_ALSASOUND
@ -76,19 +76,19 @@ int bx_sound_linux_c::alsa_seq_open(const char *alsadev)
mididev = new char[length];
if (mididev == NULL)
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
strcpy(mididev, alsadev);
ptr = strtok(mididev, ":");
if (ptr == NULL) {
BX_ERROR(("ALSA sequencer setup: missing client parameters"));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
client = atoi(ptr);
ptr = strtok(NULL, ":");
if (ptr == NULL) {
BX_ERROR(("ALSA sequencer setup: missing port parameter"));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
port = atoi(ptr);
@ -96,7 +96,7 @@ int bx_sound_linux_c::alsa_seq_open(const char *alsadev)
if (snd_seq_open(&alsa_seq.handle, "default", SND_SEQ_OPEN_OUTPUT, 0) < 0) {
BX_ERROR(("Couldn't open ALSA sequencer for midi output"));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
ret = snd_seq_create_simple_port(alsa_seq.handle, NULL,
SND_SEQ_PORT_CAP_WRITE |
@ -114,9 +114,9 @@ int bx_sound_linux_c::alsa_seq_open(const char *alsadev)
}
if (ret < 0) {
snd_seq_close(alsa_seq.handle);
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
} else {
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
}
#endif
@ -124,7 +124,7 @@ int bx_sound_linux_c::alsa_seq_open(const char *alsadev)
int bx_sound_linux_c::openmidioutput(const char *mididev)
{
if ((mididev == NULL) || (strlen(mididev) < 1))
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
#if BX_HAVE_ALSASOUND
use_alsa_seq = !strncmp(mididev, "alsa:", 5);
@ -138,10 +138,10 @@ int bx_sound_linux_c::openmidioutput(const char *mididev)
if (midi == NULL) {
BX_ERROR(("Couldn't open midi output device %s: %s",
mididev, strerror(errno)));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
@ -203,14 +203,14 @@ int bx_sound_linux_c::alsa_seq_output(int delta, int command, int length, Bit8u
break;
case 0xf0:
BX_ERROR(("alsa_seq_output(): SYSEX not implemented, length=%d", length));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
default:
BX_ERROR(("alsa_seq_output(): unknown command 0x%02x, length=%d", command, length));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
snd_seq_event_output(alsa_seq.handle, &ev);
snd_seq_drain_output(alsa_seq.handle);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif
@ -228,7 +228,7 @@ int bx_sound_linux_c::sendmidicommand(int delta, int command, int length, Bit8u
fwrite(data, 1, length, midi);
fflush(midi); // to start playing immediately
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
@ -237,12 +237,12 @@ int bx_sound_linux_c::closemidioutput()
#if BX_HAVE_ALSASOUND
if ((use_alsa_seq) && (alsa_seq.handle != NULL)) {
snd_seq_close(alsa_seq.handle);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif
fclose(midi);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
@ -251,7 +251,7 @@ int bx_sound_linux_c::openwaveoutput(const char *wavedev)
#if BX_HAVE_ALSASOUND
use_alsa_pcm = !strcmp(wavedev, "alsa");
if (use_alsa_pcm) {
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif
int length = strlen(wavedev) + 1;
@ -262,15 +262,15 @@ int bx_sound_linux_c::openwaveoutput(const char *wavedev)
wavedevice = new char[length];
if (wavedevice == NULL)
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
strncpy(wavedevice, wavedev, length);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#if BX_HAVE_ALSASOUND
int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int format)
int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, bx_bool stereo, int format)
{
int ret;
snd_pcm_format_t fmt;
@ -283,7 +283,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for
if (alsa_pcm.handle == NULL) {
ret = snd_pcm_open(&alsa_pcm.handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (ret < 0) {
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
BX_INFO(("ALSA: opened default PCM output device"));
}
@ -295,7 +295,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for
(bits == oldbits) &&
(stereo == oldstereo) &&
(format == oldformat))
return BX_SOUND_OUTPUT_OK; // nothing to do
return BX_SOUNDLOW_OK; // nothing to do
oldfreq = frequency;
oldbits = bits;
@ -317,7 +317,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for
fmt = SND_PCM_FORMAT_U8;
size = 1;
} else
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
if (stereo) size *= 2;
@ -330,7 +330,7 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for
ret = snd_pcm_hw_params(alsa_pcm.handle, params);
if (ret < 0) {
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
snd_pcm_hw_params_get_period_size(params, &alsa_pcm.frames, &dir);
alsa_bufsize = alsa_pcm.frames * size;
@ -340,11 +340,11 @@ int bx_sound_linux_c::alsa_pcm_open(int frequency, int bits, int stereo, int for
alsa_buffer = NULL;
}
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif
int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int format)
int bx_sound_linux_c::startwaveplayback(int frequency, int bits, bx_bool stereo, int format)
{
int fmt, ret;
int signeddata = format & 1;
@ -355,12 +355,12 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
}
#endif
if ((wavedevice == NULL) || (strlen(wavedevice) < 1))
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
if (wave == -1) {
wave = open(wavedevice, O_WRONLY);
if (wave == -1) {
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
} else {
BX_INFO(("OSS: opened output device %s", wavedevice));
}
@ -369,7 +369,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
(bits == oldbits) &&
(stereo == oldstereo) &&
(format == oldformat))
return BX_SOUND_OUTPUT_OK; // nothing to do
return BX_SOUNDLOW_OK; // nothing to do
}
oldfreq = frequency;
oldbits = bits;
@ -387,7 +387,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
else
fmt = AFMT_U8;
else
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
// set frequency etc.
ret = ioctl(wave, SNDCTL_DSP_RESET);
@ -406,7 +406,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
{
BX_DEBUG(("ioctl(SNDCTL_DSP_SETFMT, %d): %s",
fmt, strerror(errno)));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
ret = ioctl(wave, SNDCTL_DSP_STEREO, &stereo);
@ -422,7 +422,7 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
// ioctl(wave, SNDCTL_DSP_GETBLKSIZE, &fragment);
// BX_DEBUG(("current output block size is %d", fragment));
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#if BX_HAVE_ALSASOUND
@ -455,7 +455,7 @@ int bx_sound_linux_c::alsa_pcm_write()
alsa_buffer = NULL;
}
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif
@ -468,10 +468,10 @@ int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[])
audio_bufsize += length;
} else {
BX_ERROR(("ALSA: audio buffer overflow"));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
if (audio_bufsize < alsa_bufsize) {
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
} else {
return alsa_pcm_write();
}
@ -480,10 +480,10 @@ int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[])
int ret = write(wave, data, length);
if (ret == length) {
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
} else {
BX_ERROR(("OSS: write error"));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
}
@ -502,7 +502,7 @@ int bx_sound_linux_c::stopwaveplayback()
// close(wave);
// wave = -1;
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_linux_c::closewaveoutput()
@ -524,7 +524,7 @@ int bx_sound_linux_c::closewaveoutput()
}
wavedevice = NULL;
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif

View File

@ -22,11 +22,11 @@
// Josef Drexler coded the original version of the lowlevel sound support
// for Linux using OSS. The current version also supports OSS on FreeBSD and
// ALSA PCM output on Linux.
// ALSA PCM input/output on Linux.
#if (defined(linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
#define BX_SOUND_LINUX_BUFSIZE BX_SOUND_OUTPUT_WAVEPACKETSIZE * 2
#define BX_SOUND_LINUX_BUFSIZE BX_SOUNDLOW_WAVEPACKETSIZE * 2
#if BX_HAVE_ALSASOUND
#define ALSA_PCM_NEW_HW_PARAMS_API
@ -46,7 +46,7 @@ public:
virtual int closemidioutput();
virtual int openwaveoutput(const char *wavedev);
virtual int startwaveplayback(int frequency, int bits, int stereo, int format);
virtual int startwaveplayback(int frequency, int bits, bx_bool stereo, int format);
virtual int sendwavepacket(int length, Bit8u data[]);
virtual int stopwaveplayback();
virtual int closewaveoutput();
@ -55,7 +55,7 @@ private:
#if BX_HAVE_ALSASOUND
int alsa_seq_open(const char *alsadev);
int alsa_seq_output(int delta, int command, int length, Bit8u data[]);
int alsa_pcm_open(int frequency, int bits, int stereo, int format);
int alsa_pcm_open(int frequency, int bits, bx_bool stereo, int format);
int alsa_pcm_write();
bx_bool use_alsa_seq;
@ -75,7 +75,8 @@ private:
char *wavedevice;
int wave;
Bit8u audio_buffer[BX_SOUND_LINUX_BUFSIZE];
int oldfreq,oldbits,oldstereo,oldformat;
int oldfreq,oldbits,oldformat;
bx_bool oldstereo;
};
#endif

View File

@ -18,7 +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 output functions
// 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
@ -27,14 +27,14 @@
#include "iodev.h"
#if BX_SUPPORT_SB16
#if BX_SUPPORT_SOUNDLOW
#include "soundmod.h"
#include "soundlnx.h"
#include "soundosx.h"
#include "soundwin.h"
#define LOG_THIS dev->
#define LOG_THIS device->
bx_soundmod_ctl_c* theSoundModCtl = NULL;
@ -50,14 +50,14 @@ void libsoundmod_LTX_plugin_fini(void)
delete theSoundModCtl;
}
int bx_soundmod_ctl_c::init_module(const char *type, void **module, logfunctions *dev)
int bx_soundmod_ctl_c::init_module(const char *type, void **module, logfunctions *device)
{
bx_sound_lowlevel_c **soundmod = (bx_sound_lowlevel_c**)module;
if (!strcmp(type, "default")) {
*soundmod = new BX_SOUND_LOWLEVEL_C(dev);
*soundmod = new BX_SOUND_LOWLEVEL_C(device);
} else if (!strcmp(type, "dummy")) {
*soundmod = new bx_sound_lowlevel_c(dev);
*soundmod = new bx_sound_lowlevel_c(device);
} else {
BX_PANIC(("unknown sound module type '%s'", type));
*soundmod = NULL;
@ -65,7 +65,7 @@ int bx_soundmod_ctl_c::init_module(const char *type, void **module, logfunctions
return 0;
}
// The dummy sound output functions. They don't do anything.
// The dummy sound lowlevel functions. They don't do anything.
bx_sound_lowlevel_c::bx_sound_lowlevel_c(logfunctions *dev)
{
device = dev;
@ -77,18 +77,18 @@ bx_sound_lowlevel_c::~bx_sound_lowlevel_c()
int bx_sound_lowlevel_c::waveready()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::midiready()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::openmidioutput(const char *mididev)
{
UNUSED(mididev);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
@ -97,44 +97,44 @@ int bx_sound_lowlevel_c::sendmidicommand(int delta, int command, int length, Bit
UNUSED(command);
UNUSED(length);
UNUSED(data);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::closemidioutput()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::openwaveoutput(const char *wavedev)
{
UNUSED(wavedev);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::startwaveplayback(int frequency, int bits, int stereo, int format)
int bx_sound_lowlevel_c::startwaveplayback(int frequency, int bits, bx_bool stereo, int format)
{
UNUSED(frequency);
UNUSED(bits);
UNUSED(stereo);
UNUSED(format);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::sendwavepacket(int length, Bit8u data[])
{
UNUSED(length);
UNUSED(data);
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::stopwaveplayback()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::closewaveoutput()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#endif

View File

@ -18,34 +18,34 @@
// 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 output modules
// Common code for sound lowlevel modules
// this is the size of a DMA chunk sent to output
// this is the size of a sound packet used for sending and receiving
// 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_SOUNDLOW_WAVEPACKETSIZE 8192
// Definitions for the output functions
#define BX_SOUND_OUTPUT_OK 0
#define BX_SOUND_OUTPUT_ERR 1
#define BX_SOUNDLOW_OK 0
#define BX_SOUNDLOW_ERR 1
// Pseudo device that loads the lowlevel sound module
class bx_soundmod_ctl_c : public bx_soundmod_ctl_stub_c {
public:
bx_soundmod_ctl_c() {}
virtual ~bx_soundmod_ctl_c() {}
virtual int init_module(const char *type, void **module, logfunctions *dev);
virtual int init_module(const char *type, void **module, logfunctions *device);
};
// The class with the output functions
// The class with the input/output functions
class bx_sound_lowlevel_c : public logfunctions {
public:
/*
These functions are the sound output functions, sending
the music/sound to the OS specific driver.
These functions are the sound lowlevel functions, sending
the music or sending/receiving sound to/from the OS specific driver.
They are in a different file (soundxxx.cc) because they are
non-portable, while everything in sb16.cc is portable
non-portable, while everything in the soundcard code is portable
*/
bx_sound_lowlevel_c(logfunctions *dev);
@ -59,7 +59,7 @@ public:
virtual int closemidioutput();
virtual int openwaveoutput(const char *wavedev);
virtual int startwaveplayback(int frequency, int bits, int stereo, int format);
virtual int startwaveplayback(int frequency, int bits, bx_bool stereo, int format);
virtual int sendwavepacket(int length, Bit8u data[]);
virtual int stopwaveplayback();
virtual int closewaveoutput();

View File

@ -89,7 +89,7 @@ bx_sound_osx_c::~bx_sound_osx_c()
int bx_sound_osx_c::midiready()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::openmidioutput(const char *mididev)
@ -136,13 +136,13 @@ int bx_sound_osx_c::openmidioutput(const char *mididev)
#endif
BX_DEBUG(("openmidioutput(%s)", mididev));
MidiOpen = 1;
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
BX_DEBUG(("sendmidicommand(%i,%02x,%i)", delta, command, length));
if (!MidiOpen) return BX_SOUND_OUTPUT_ERR;
if (!MidiOpen) return BX_SOUNDLOW_ERR;
#ifdef BX_SOUND_OSX_use_converter
if (length <= 2) {
@ -154,7 +154,7 @@ int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u da
MusicDeviceSysEx (synthUnit, data, length);
}
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::closemidioutput()
@ -165,7 +165,7 @@ int bx_sound_osx_c::closemidioutput()
AUGraphStop (MidiGraph);
AUGraphClose (MidiGraph);
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#ifdef BX_SOUND_OSX_use_quicktime
@ -189,11 +189,11 @@ int bx_sound_osx_c::openwaveoutput(const char *wavedev)
// open the default output unit
#ifdef BX_SOUND_OSX_use_quicktime
err = SndNewChannel (&WaveChannel, sampledSynth, 0, NewSndCallBackUPP(WaveCallbackProc));
if (err != noErr) return BX_SOUND_OUTPUT_ERR;
if (err != noErr) return BX_SOUNDLOW_ERR;
#endif
#ifdef BX_SOUND_OSX_use_converter
err = OpenDefaultAudioOutput (&WaveOutputUnit);
if (err != noErr) return BX_SOUND_OUTPUT_ERR;
if (err != noErr) return BX_SOUNDLOW_ERR;
AudioUnitInitialize (WaveOutputUnit);
// Set up a callback function to generate output to the output unit
@ -205,10 +205,10 @@ int bx_sound_osx_c::openwaveoutput(const char *wavedev)
#endif
WaveOpen = 1;
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int format)
int bx_sound_osx_c::startwaveplayback(int frequency, int bits, bx_bool stereo, int format)
{
#ifdef BX_SOUND_OSX_use_converter
static int oldfreq, oldbits, oldstereo, oldformat;
@ -240,7 +240,7 @@ int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int f
(bits == oldbits) &&
(stereo == oldstereo) &&
(format == oldformat))
return BX_SOUND_OUTPUT_OK; // nothing to do
return BX_SOUNDLOW_OK; // nothing to do
oldfreq = frequency;
oldbits = bits;
@ -278,7 +278,7 @@ int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int f
if (WavePlaying) AudioOutputUnitStart (WaveOutputUnit);
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::waveready()
@ -287,7 +287,7 @@ int bx_sound_osx_c::waveready()
// have been sent, but possibly not yet played. There
// should be a better way of doing this.
if (WaveOpen && (head - tail < BX_SOUND_OSX_NBUF-4)) {
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
else {
#ifdef BX_SOUND_OSX_use_converter
@ -297,7 +297,7 @@ int bx_sound_osx_c::waveready()
WavePlaying = 1;
}
#endif
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
}
@ -311,7 +311,7 @@ int bx_sound_osx_c::sendwavepacket(int length, Bit8u data[])
// sanity check
if ((!WaveOpen) || (head - tail >= BX_SOUND_OSX_NBUF))
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
// find next available buffer
int n = head++ % BX_SOUND_OSX_NBUF;
@ -347,12 +347,12 @@ int bx_sound_osx_c::sendwavepacket(int length, Bit8u data[])
SndDoCommand(WaveChannel, &mySndCommand, TRUE);
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::stopwaveplayback()
{
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::closewaveoutput()
@ -366,7 +366,7 @@ int bx_sound_osx_c::closewaveoutput()
WaveConverter = NULL;
WaveOutputUnit = NULL;
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
#ifdef BX_SOUND_OSX_use_converter

View File

@ -48,7 +48,7 @@ public:
virtual int closemidioutput();
virtual int openwaveoutput(const char *wavedev);
virtual int startwaveplayback(int frequency, int bits, int stereo, int format);
virtual int startwaveplayback(int frequency, int bits, bx_bool stereo, int format);
virtual int sendwavepacket(int length, Bit8u data[]);
virtual int stopwaveplayback();
virtual int closewaveoutput();
@ -60,7 +60,7 @@ private:
int MidiOpen;
int WaveOpen;
Bit8u WaveData[BX_SOUND_OSX_NBUF][BX_SOUND_OUTPUT_WAVEPACKETSIZE];
Bit8u WaveData[BX_SOUND_OSX_NBUF][BX_SOUNDLOW_WAVEPACKETSIZE];
int WaveLength[BX_SOUND_OSX_NBUF];
int head, tail; // buffer pointers

View File

@ -53,7 +53,7 @@ bx_sound_windows_c::bx_sound_windows_c(logfunctions *dev)
#define size ALIGN(sizeof(MIDIHDR)) \
+ ALIGN(sizeof(WAVEHDR)) \
+ ALIGN(BX_SOUND_WINDOWS_MAXSYSEXLEN) * BX_SOUND_WINDOWS_NBUF \
+ ALIGN(BX_SOUND_OUTPUT_WAVEPACKETSIZE) * BX_SOUND_WINDOWS_NBUF
+ ALIGN(BX_SOUNDLOW_WAVEPACKETSIZE) * BX_SOUND_WINDOWS_NBUF
DataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
DataPointer = (Bit8u*) GlobalLock(DataHandle);
@ -70,7 +70,7 @@ bx_sound_windows_c::bx_sound_windows_c(logfunctions *dev)
for (int bufnum=0; bufnum<BX_SOUND_WINDOWS_NBUF; bufnum++)
{
WaveHeader[bufnum] = (LPWAVEHDR) NEWBUFFER(sizeof(WAVEHDR));
WaveData[bufnum] = (LPSTR) NEWBUFFER(BX_SOUND_OUTPUT_WAVEPACKETSIZE+64);
WaveData[bufnum] = (LPSTR) NEWBUFFER(BX_SOUNDLOW_WAVEPACKETSIZE+64);
}
if (offset > size)
@ -95,9 +95,9 @@ int bx_sound_windows_c::waveready()
checkwaveready();
if (iswaveready == 1)
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
else
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::midiready()
{
@ -105,9 +105,9 @@ int bx_sound_windows_c::midiready()
checkmidiready();
if (ismidiready == 1)
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
else
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::openmidioutput(const char *mididev)
@ -126,7 +126,7 @@ int bx_sound_windows_c::openmidioutput(const char *mididev)
BX_DEBUG(("midiOutOpen() = %d, MidiOpen: %d", ret, MidiOpen));
return (MidiOpen == 1) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
return (MidiOpen == 1) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
@ -134,7 +134,7 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8
UINT ret;
if (MidiOpen != 1)
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
if ((command == 0xf0) || (command == 0xf7) || (length > 3))
{
@ -164,7 +164,7 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8
BX_DEBUG(("midiOutShortMsg(%x) = %d", msg, ret));
}
return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
return (ret == 0) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::closemidioutput()
@ -172,7 +172,7 @@ int bx_sound_windows_c::closemidioutput()
UINT ret;
if (MidiOpen != 1)
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
ret = midiOutReset(MidiOut);
if (ismidiready == 0)
@ -182,7 +182,7 @@ int bx_sound_windows_c::closemidioutput()
BX_DEBUG(("midiOutClose() = %d", ret));
MidiOpen = 0;
return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
return (ret == 0) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::openwaveoutput(const char *wavedev)
@ -205,7 +205,7 @@ int bx_sound_windows_c::openwaveoutput(const char *wavedev)
needreopen = 0;
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_windows_c::playnextbuffer()
@ -225,7 +225,7 @@ int bx_sound_windows_c::playnextbuffer()
// do we have to play anything?
if (tailplay == head)
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
// if the format is different, we have to close and reopen the device
// or, just open the device if it's not open yet
@ -241,7 +241,7 @@ int bx_sound_windows_c::playnextbuffer()
for (int tries = 0; tries < 3; tries++)
{
int frequency = WaveInfo.frequency;
int stereo = WaveInfo.stereo;
bx_bool stereo = WaveInfo.stereo;
int bits = WaveInfo.bits;
// int format = WaveInfo.format;
int bps = (bits / 8) * (stereo + 1);
@ -282,7 +282,7 @@ int bx_sound_windows_c::playnextbuffer()
case 2: // nope, doesn't work
BX_ERROR(("Couldn't open wave device (error %d)!", ret));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
BX_DEBUG(("The format was: wFormatTag=%d, nChannels=%d, nSamplesPerSec=%d,",
@ -316,7 +316,7 @@ int bx_sound_windows_c::playnextbuffer()
if (ret != 0)
{
BX_ERROR(("waveOutPrepareHeader = %d", ret));
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
ret = waveOutWrite(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
@ -328,10 +328,10 @@ int bx_sound_windows_c::playnextbuffer()
}
}
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_windows_c::startwaveplayback(int frequency, int bits, int stereo, int format)
int bx_sound_windows_c::startwaveplayback(int frequency, int bits, bx_bool stereo, int format)
{
BX_DEBUG(("startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format));
@ -369,7 +369,7 @@ int bx_sound_windows_c::startwaveplayback(int frequency, int bits, int stereo, i
memcpy(header->chnk2, "data", 4);
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
@ -397,7 +397,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
{ // this should not actually happen!
BX_ERROR(("Output buffer overflow! Not played. Iswaveready was %d", iswaveready));
iswaveready = 0; // stop the output for a while
return BX_SOUND_OUTPUT_ERR;
return BX_SOUNDLOW_ERR;
}
head = bufnum;
@ -428,7 +428,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
}
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_windows_c::stopwaveplayback()
@ -445,7 +445,7 @@ int bx_sound_windows_c::stopwaveplayback()
WaveOpen = 0;
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
int bx_sound_windows_c::closewaveoutput()
@ -469,7 +469,7 @@ int bx_sound_windows_c::closewaveoutput()
}
#endif
return BX_SOUND_OUTPUT_OK;
return BX_SOUNDLOW_OK;
}
void bx_sound_windows_c::checkmidiready()

View File

@ -31,11 +31,11 @@
#define BX_SOUND_WINDOWS_MAXSYSEXLEN 256 // maximum supported length of a sysex message
#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)
#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
#define WAVEMAPPER -1
#define WAVEMAPPER -1
#endif
// Definitions for WINMM.DLL, if not defined already
@ -177,7 +177,7 @@ public:
virtual int closemidioutput();
virtual int openwaveoutput(const char *wavedev);
virtual int startwaveplayback(int frequency, int bits, int stereo, int format);
virtual int startwaveplayback(int frequency, int bits, bx_bool stereo, int format);
virtual int sendwavepacket(int length, Bit8u data[]);
virtual int stopwaveplayback();
virtual int closewaveoutput();
@ -186,7 +186,7 @@ private:
struct bx_sound_waveinfo_struct {
int frequency;
int bits;
int stereo;
bx_bool stereo;
int format;
};