Moved midi output support to a separate C++ class. The lowlevel sound module

creates the object and returns a pointer to it. TODO: Rewrite of the sound
configuration to support a more detailed setup (e.g. waveout with alsa,
dummy wavein, midiout to a file).
This commit is contained in:
Volker Ruppert 2015-02-15 18:32:36 +00:00
parent f84439f8e8
commit 79058610d7
12 changed files with 305 additions and 224 deletions

View File

@ -186,6 +186,7 @@ void CDECL libsb16_LTX_plugin_fini(void)
#define BX_SB16_OUTPUT BX_SB16_THIS soundmod
#define BX_SB16_WAVEOUT BX_SB16_THIS waveout
#define BX_SB16_WAVEIN BX_SB16_THIS wavein
#define BX_SB16_MIDIOUT BX_SB16_THIS midiout
// here's a safe way to print out null pointeres
#define MIGHT_BE_NULL(x) ((x==NULL)? "(null)" : x)
@ -266,6 +267,10 @@ void bx_sb16_c::init(void)
if (BX_SB16_WAVEIN == NULL) {
BX_PANIC(("Couldn't initialize lowlevel driver (wavein)"));
}
BX_SB16_MIDIOUT = soundmod->get_midiout();
if (BX_SB16_MIDIOUT == NULL) {
BX_PANIC(("Couldn't initialize lowlevel driver (midiout)"));
}
DSP.dma.chunk = new Bit8u[BX_SOUNDLOW_WAVEPACKETSIZE];
DSP.dma.chunkindex = 0;
@ -1887,7 +1892,7 @@ Bit32u bx_sb16_c::mpu_status()
if ((MPU.datain.full() == 1) ||
((BX_SB16_THIS midimode == 1) &&
(BX_SB16_OUTPUT->midiready() == BX_SOUNDLOW_ERR)))
(BX_SB16_MIDIOUT->midiready() == BX_SOUNDLOW_ERR)))
result |= 0x40; // output not ready
if (MPU.dataout.empty() == 1)
result |= 0x80; // no input available
@ -2424,7 +2429,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(midiparam->getptr()) == BX_SOUNDLOW_OK)
if (BX_SB16_MIDIOUT->openmidioutput(midiparam->getptr()) == BX_SOUNDLOW_OK)
MPU.outputinit = 1;
else
MPU.outputinit = 0;
@ -2434,7 +2439,7 @@ void bx_sb16_c::writemidicommand(int command, int length, Bit8u data[])
return;
}
}
BX_SB16_OUTPUT->sendmidicommand(deltatime, command, length, data);
BX_SB16_MIDIOUT->sendmidicommand(deltatime, command, length, data);
return;
} else if ((BX_SB16_THIS midimode == 2) ||
(BX_SB16_THIS midimode == 3)) {
@ -2659,7 +2664,6 @@ void bx_sb16_c::closemidioutput()
switch (BX_SB16_THIS midimode) {
case 1:
if (MPU.outputinit != 0) {
BX_SB16_OUTPUT->closemidioutput();
MPU.outputinit = 0;
}
break;

View File

@ -155,9 +155,10 @@ private:
bx_bool midi_changed, wave_changed;
Bit32u dmatimer;
FILE *logfile, *midifile, *wavefile; // the output files or devices
bx_sound_lowlevel_c *soundmod; // the lowlevel class
bx_sound_lowlevel_c *soundmod; // the lowlevel class
bx_soundlow_waveout_c *waveout; // waveout support
bx_soundlow_wavein_c *wavein; // wavein support
bx_soundlow_wavein_c *wavein; // wavein support
bx_soundlow_midiout_c *midiout; // midiout support
int currentirq;
int currentdma8;
int currentdma16;

View File

@ -263,32 +263,22 @@ void bx_soundlow_wavein_alsa_c::record_timer(void)
record_handler(this, record_packet_size);
}
// bx_sound_alsa_c class implemenzation
// bx_soundlow_midiout_alsa_c class implemenzation
bx_sound_alsa_c::bx_sound_alsa_c()
:bx_sound_lowlevel_c()
bx_soundlow_midiout_alsa_c::bx_soundlow_midiout_alsa_c()
:bx_soundlow_midiout_c()
{
alsa_seq.handle = NULL;
BX_INFO(("Sound lowlevel module 'alsa' initialized"));
}
bx_soundlow_waveout_c* bx_sound_alsa_c::get_waveout()
bx_soundlow_midiout_alsa_c::~bx_soundlow_midiout_alsa_c()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_alsa_c();
if (alsa_seq.handle != NULL) {
snd_seq_close(alsa_seq.handle);
}
return waveout;
}
bx_soundlow_wavein_c* bx_sound_alsa_c::get_wavein()
{
if (wavein == NULL) {
wavein = new bx_soundlow_wavein_alsa_c();
}
return wavein;
}
int bx_sound_alsa_c::alsa_seq_open(const char *alsadev)
int bx_soundlow_midiout_alsa_c::alsa_seq_open(const char *alsadev)
{
char *mididev, *ptr;
int client, port, ret = 0;
@ -341,7 +331,7 @@ int bx_sound_alsa_c::alsa_seq_open(const char *alsadev)
}
}
int bx_sound_alsa_c::openmidioutput(const char *mididev)
int bx_soundlow_midiout_alsa_c::openmidioutput(const char *mididev)
{
if ((mididev == NULL) || (strlen(mididev) < 1))
return BX_SOUNDLOW_ERR;
@ -349,12 +339,7 @@ int bx_sound_alsa_c::openmidioutput(const char *mididev)
return alsa_seq_open(mididev);
}
int bx_sound_alsa_c::midiready()
{
return BX_SOUNDLOW_OK;
}
int bx_sound_alsa_c::alsa_seq_output(int delta, int command, int length, Bit8u data[])
int bx_soundlow_midiout_alsa_c::alsa_seq_output(int delta, int command, int length, Bit8u data[])
{
int cmd, chan, value;
snd_seq_event_t ev;
@ -421,7 +406,7 @@ int bx_sound_alsa_c::alsa_seq_output(int delta, int command, int length, Bit8u d
return BX_SOUNDLOW_OK;
}
int bx_sound_alsa_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
int bx_soundlow_midiout_alsa_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
if (alsa_seq.handle != NULL) {
return alsa_seq_output(delta, command, length, data);
@ -430,13 +415,36 @@ int bx_sound_alsa_c::sendmidicommand(int delta, int command, int length, Bit8u d
return BX_SOUNDLOW_ERR;
}
int bx_sound_alsa_c::closemidioutput()
{
if (alsa_seq.handle != NULL) {
snd_seq_close(alsa_seq.handle);
}
// bx_sound_alsa_c class implemenzation
return BX_SOUNDLOW_OK;
bx_sound_alsa_c::bx_sound_alsa_c()
:bx_sound_lowlevel_c()
{
BX_INFO(("Sound lowlevel module 'alsa' initialized"));
}
bx_soundlow_waveout_c* bx_sound_alsa_c::get_waveout()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_alsa_c();
}
return waveout;
}
bx_soundlow_wavein_c* bx_sound_alsa_c::get_wavein()
{
if (wavein == NULL) {
wavein = new bx_soundlow_wavein_alsa_c();
}
return wavein;
}
bx_soundlow_midiout_c* bx_sound_alsa_c::get_midiout()
{
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_alsa_c();
}
return midiout;
}
#endif

View File

@ -66,18 +66,13 @@ private:
Bit8u audio_buffer[BX_SOUND_ALSA_BUFSIZE];
};
class bx_sound_alsa_c : public bx_sound_lowlevel_c {
class bx_soundlow_midiout_alsa_c : public bx_soundlow_midiout_c {
public:
bx_sound_alsa_c();
virtual ~bx_sound_alsa_c() {}
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
bx_soundlow_midiout_alsa_c();
virtual ~bx_soundlow_midiout_alsa_c();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
private:
int alsa_seq_open(const char *alsadev);
@ -89,4 +84,14 @@ private:
} alsa_seq;
};
class bx_sound_alsa_c : public bx_sound_lowlevel_c {
public:
bx_sound_alsa_c();
virtual ~bx_sound_alsa_c() {}
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
virtual bx_soundlow_midiout_c* get_midiout();
};
#endif

View File

@ -293,12 +293,57 @@ 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()
{
fclose(midi);
}
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::midiready()
{
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;
}
// bx_sound_oss_c class implemenzation
bx_sound_oss_c::bx_sound_oss_c()
:bx_sound_lowlevel_c()
{
midi = NULL;
BX_INFO(("Sound lowlevel module 'oss' initialized"));
}
@ -318,44 +363,12 @@ bx_soundlow_wavein_c* bx_sound_oss_c::get_wavein()
return wavein;
}
int bx_sound_oss_c::openmidioutput(const char *mididev)
bx_soundlow_midiout_c* bx_sound_oss_c::get_midiout()
{
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;
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_oss_c();
}
return BX_SOUNDLOW_OK;
}
int bx_sound_oss_c::midiready()
{
return BX_SOUNDLOW_OK;
}
int bx_sound_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_sound_oss_c::closemidioutput()
{
fclose(midi);
return BX_SOUNDLOW_OK;
return midiout;
}
#endif

View File

@ -54,6 +54,19 @@ private:
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 midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
private:
FILE *midi;
};
class bx_sound_oss_c : public bx_sound_lowlevel_c {
public:
bx_sound_oss_c();
@ -61,14 +74,7 @@ public:
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
private:
FILE *midi;
virtual bx_soundlow_midiout_c* get_midiout();
};
#endif

View File

@ -392,6 +392,38 @@ void bx_soundlow_wavein_c::record_timer(void)
record_handler(this, record_packet_size);
}
// bx_soundlow_midiout_c class implemenzation
// The dummy output methods don't do anything.
bx_soundlow_midiout_c::bx_soundlow_midiout_c()
{
put("midiout", "MIDI");
}
bx_soundlow_midiout_c::~bx_soundlow_midiout_c()
{
}
int bx_soundlow_midiout_c::openmidioutput(const char *mididev)
{
UNUSED(mididev);
return BX_SOUNDLOW_OK;
}
int bx_soundlow_midiout_c::midiready()
{
return BX_SOUNDLOW_OK;
}
int bx_soundlow_midiout_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
UNUSED(delta);
UNUSED(command);
UNUSED(length);
UNUSED(data);
return BX_SOUNDLOW_OK;
}
// bx_sound_lowlevel_c class implemenzation
// This is the base class of the sound lowlevel support.
@ -400,6 +432,7 @@ bx_sound_lowlevel_c::bx_sound_lowlevel_c()
put("soundlow", "SNDLOW");
waveout = NULL;
wavein = NULL;
midiout = NULL;
}
bx_sound_lowlevel_c::~bx_sound_lowlevel_c()
@ -410,6 +443,9 @@ bx_sound_lowlevel_c::~bx_sound_lowlevel_c()
if (wavein != NULL) {
delete wavein;
}
if (midiout != NULL) {
delete midiout;
}
}
bx_soundlow_waveout_c* bx_sound_lowlevel_c::get_waveout()
@ -428,29 +464,12 @@ bx_soundlow_wavein_c* bx_sound_lowlevel_c::get_wavein()
return wavein;
}
int bx_sound_lowlevel_c::openmidioutput(const char *mididev)
bx_soundlow_midiout_c* bx_sound_lowlevel_c::get_midiout()
{
UNUSED(mididev);
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::midiready()
{
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
UNUSED(delta);
UNUSED(command);
UNUSED(length);
UNUSED(data);
return BX_SOUNDLOW_OK;
}
int bx_sound_lowlevel_c::closemidioutput()
{
return BX_SOUNDLOW_OK;
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_c();
}
return midiout;
}
#endif

View File

@ -112,29 +112,31 @@ protected:
sound_record_handler_t record_handler;
};
// The class with the input/output functions
// the midiout class
class bx_soundlow_midiout_c : public logfunctions {
public:
bx_soundlow_midiout_c();
virtual ~bx_soundlow_midiout_c();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
};
// the lowlevel sound driver class returns pointers to the child objects
class bx_sound_lowlevel_c : public logfunctions {
public:
/*
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 the soundcard code is portable
*/
bx_sound_lowlevel_c();
virtual ~bx_sound_lowlevel_c();
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
virtual bx_soundlow_midiout_c* get_midiout();
protected:
bx_soundlow_waveout_c *waveout;
bx_soundlow_wavein_c *wavein;
bx_soundlow_midiout_c *midiout;
};

View File

@ -451,24 +451,24 @@ void bx_soundlow_waveout_osx_c::nextbuffer (int *outDataSize, void **outData)
}
#endif
// bx_sound_osx_c class implemenzation
// bx_soundlow_midiout_osx_c class implemenzation
bx_sound_osx_c::bx_sound_osx_c()
:bx_sound_lowlevel_c()
bx_soundlow_midiout_osx_c::bx_soundlow_midiout_osx_c()
:bx_soundlow_midiout_c()
{
MidiOpen = 0;
BX_INFO(("Sound lowlevel module 'osx' initialized"));
}
bx_soundlow_waveout_c* bx_sound_osx_c::get_waveout()
bx_soundlow_midiout_osx_c::~bx_soundlow_midiout_osx_c()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_osx_c();
}
return waveout;
MidiOpen = 0;
#ifdef BX_SOUND_OSX_use_converter
AUGraphStop(MidiGraph);
AUGraphClose(MidiGraph);
#endif
}
int bx_sound_osx_c::openmidioutput(const char *mididev)
int bx_soundlow_midiout_osx_c::openmidioutput(const char *mididev)
{
#ifdef BX_SOUND_OSX_use_converter
ComponentDescription description;
@ -515,12 +515,7 @@ int bx_sound_osx_c::openmidioutput(const char *mididev)
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::midiready()
{
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
int bx_soundlow_midiout_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
BX_DEBUG(("sendmidicommand(%i,%02x,%i)", delta, command, length));
if (!MidiOpen) return BX_SOUNDLOW_ERR;
@ -538,15 +533,28 @@ int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u da
return BX_SOUNDLOW_OK;
}
int bx_sound_osx_c::closemidioutput()
// bx_sound_osx_c class implemenzation
bx_sound_osx_c::bx_sound_osx_c()
:bx_sound_lowlevel_c()
{
BX_DEBUG(("closemidioutput()"));
MidiOpen = 0;
#ifdef BX_SOUND_OSX_use_converter
AUGraphStop (MidiGraph);
AUGraphClose (MidiGraph);
#endif
return BX_SOUNDLOW_OK;
BX_INFO(("Sound lowlevel module 'osx' initialized"));
}
bx_soundlow_waveout_c* bx_sound_osx_c::get_waveout()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_osx_c();
}
return waveout;
}
bx_soundlow_midiout_c* bx_sound_osx_c::get_midiout()
{
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_osx_c();
}
return midiout;
}
#endif // defined(macintosh)

View File

@ -62,20 +62,25 @@ private:
#endif
};
class bx_soundlow_midiout_osx_c : public bx_soundlow_midiout_c {
public:
bx_soundlow_midiout_osx_c();
virtual ~bx_soundlow_midiout_osx_c();
virtual int openmidioutput(const char *mididev);
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
private:
int MidiOpen;
};
class bx_sound_osx_c : public bx_sound_lowlevel_c {
public:
bx_sound_osx_c();
virtual ~bx_sound_osx_c() {}
virtual bx_soundlow_waveout_c* get_waveout();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
private:
int MidiOpen;
virtual bx_soundlow_midiout_c* get_midiout();
};
#endif // macintosh

View File

@ -338,56 +338,33 @@ void bx_soundlow_wavein_win_c::record_timer(void)
record_handler(this, record_packet_size);
}
// bx_sound_windows_c class implemenzation
// bx_soundlow_midiout_win_c class implemenzation
bx_sound_windows_c::bx_sound_windows_c()
:bx_sound_lowlevel_c()
bx_soundlow_midiout_win_c::bx_soundlow_midiout_win_c()
:bx_soundlow_midiout_c()
{
MidiOpen = 0;
ismidiready = 1;
DataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
DataPointer = (Bit8u*) GlobalLock(DataHandle);
if (DataPointer == NULL)
BX_PANIC(("GlobalLock returned NULL-pointer"));
MidiHeader = (LPMIDIHDR) newbuffer(sizeof(MIDIHDR));
MidiData = (LPSTR) newbuffer(BX_SOUND_WINDOWS_MAXSYSEXLEN);
if (MidiData == NULL)
BX_PANIC(("Allocated memory was too small!"));
#undef size
#undef ALIGN
BX_INFO(("Sound lowlevel module 'win' initialized"));
}
bx_sound_windows_c::~bx_sound_windows_c()
bx_soundlow_midiout_win_c::~bx_soundlow_midiout_win_c()
{
GlobalUnlock(DataHandle);
GlobalFree(DataHandle);
}
UINT ret;
bx_soundlow_waveout_c* bx_sound_windows_c::get_waveout()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_win_c();
if (MidiOpen == 1) {
ret = midiOutReset(MidiOut);
if (ismidiready == 0)
checkmidiready(); // to clear any pending SYSEX
ret = midiOutClose(MidiOut);
BX_DEBUG(("midiOutClose() = %d", ret));
}
return waveout;
}
bx_soundlow_wavein_c* bx_sound_windows_c::get_wavein()
{
if (wavein == NULL) {
wavein = new bx_soundlow_wavein_win_c();
}
return wavein;
}
int bx_sound_windows_c::openmidioutput(const char *mididev)
int bx_soundlow_midiout_win_c::openmidioutput(const char *mididev)
{
UINT deviceid;
@ -401,7 +378,6 @@ int bx_sound_windows_c::openmidioutput(const char *mididev)
deviceid = (UINT) MIDIMAPPER;
}
}
MidiOpen = 0;
UINT ret = midiOutOpen(&MidiOut, deviceid, 0, 0, CALLBACK_NULL);
@ -413,7 +389,7 @@ int bx_sound_windows_c::openmidioutput(const char *mididev)
return (MidiOpen == 1) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::midiready()
int bx_soundlow_midiout_win_c::midiready()
{
if (ismidiready == 0)
checkmidiready();
@ -424,7 +400,7 @@ int bx_sound_windows_c::midiready()
return BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
int bx_soundlow_midiout_win_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{
UINT ret;
@ -462,32 +438,60 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8
return (ret == 0) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
int bx_sound_windows_c::closemidioutput()
void bx_soundlow_midiout_win_c::checkmidiready()
{
UINT ret;
if (MidiOpen != 1)
return BX_SOUNDLOW_ERR;
ret = midiOutReset(MidiOut);
if (ismidiready == 0)
checkmidiready(); // to clear any pending SYSEX
ret = midiOutClose(MidiOut);
BX_DEBUG(("midiOutClose() = %d", ret));
MidiOpen = 0;
return (ret == 0) ? BX_SOUNDLOW_OK : BX_SOUNDLOW_ERR;
}
void bx_sound_windows_c::checkmidiready()
{
if ((MidiHeader->dwFlags & MHDR_DONE) != 0)
{
if ((MidiHeader->dwFlags & MHDR_DONE) != 0) {
BX_DEBUG(("SYSEX message done, midi ready again"));
midiOutUnprepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader));
ismidiready = 1;
}
}
// bx_sound_windows_c class implemenzation
bx_sound_windows_c::bx_sound_windows_c()
:bx_sound_lowlevel_c()
{
DataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
DataPointer = (Bit8u*) GlobalLock(DataHandle);
if (DataPointer == NULL)
BX_PANIC(("GlobalLock returned NULL-pointer"));
#undef size
#undef ALIGN
BX_INFO(("Sound lowlevel module 'win' initialized"));
}
bx_sound_windows_c::~bx_sound_windows_c()
{
GlobalUnlock(DataHandle);
GlobalFree(DataHandle);
}
bx_soundlow_waveout_c* bx_sound_windows_c::get_waveout()
{
if (waveout == NULL) {
waveout = new bx_soundlow_waveout_win_c();
}
return waveout;
}
bx_soundlow_wavein_c* bx_sound_windows_c::get_wavein()
{
if (wavein == NULL) {
wavein = new bx_soundlow_wavein_win_c();
}
return wavein;
}
bx_soundlow_midiout_c* bx_sound_windows_c::get_midiout()
{
if (midiout == NULL) {
midiout = new bx_soundlow_midiout_win_c();
}
return midiout;
}
#endif // defined(WIN32)

View File

@ -199,18 +199,14 @@ private:
int recordnextpacket();
};
class bx_sound_windows_c : public bx_sound_lowlevel_c {
class bx_soundlow_midiout_win_c : public bx_soundlow_midiout_c {
public:
bx_sound_windows_c();
virtual ~bx_sound_windows_c();
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
bx_soundlow_midiout_win_c();
virtual ~bx_soundlow_midiout_win_c();
virtual int openmidioutput(const char *mididev);
virtual int midiready();
virtual int sendmidicommand(int delta, int command, int length, Bit8u data[]);
virtual int closemidioutput();
private:
HMIDIOUT MidiOut; // Midi output device
@ -224,4 +220,14 @@ private:
void checkmidiready();
};
class bx_sound_windows_c : public bx_sound_lowlevel_c {
public:
bx_sound_windows_c();
virtual ~bx_sound_windows_c();
virtual bx_soundlow_waveout_c* get_waveout();
virtual bx_soundlow_wavein_c* get_wavein();
virtual bx_soundlow_midiout_c* get_midiout();
};
#endif // defined(WIN32)