mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
MIDI: Fixed several bugs and bumped the input buffer sizes [R. Belmont]
This commit is contained in:
parent
4efc1f7b05
commit
9c0f4e6683
@ -34,6 +34,7 @@ void midiin_device::device_start()
|
||||
{
|
||||
m_input_func.resolve(m_input_callback, *this);
|
||||
m_timer = timer_alloc(0);
|
||||
m_midi = NULL;
|
||||
}
|
||||
|
||||
void midiin_device::device_reset()
|
||||
@ -71,10 +72,10 @@ void midiin_device::device_config_complete(void)
|
||||
|
||||
void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
UINT8 buf[256];
|
||||
UINT8 buf[8192*4];
|
||||
int bytesRead;
|
||||
|
||||
if (osd_poll_midi_channel(m_midi))
|
||||
while (osd_poll_midi_channel(m_midi))
|
||||
{
|
||||
bytesRead = osd_read_midi_channel(m_midi, buf);
|
||||
|
||||
@ -112,7 +113,10 @@ bool midiin_device::call_load(void)
|
||||
|
||||
void midiin_device::call_unload(void)
|
||||
{
|
||||
osd_close_midi_channel(m_midi);
|
||||
if (m_midi)
|
||||
{
|
||||
osd_close_midi_channel(m_midi);
|
||||
}
|
||||
}
|
||||
|
||||
void midiin_device::tra_complete()
|
||||
|
@ -68,7 +68,7 @@ protected:
|
||||
void input_callback(UINT8 state);
|
||||
|
||||
private:
|
||||
static const int XMIT_RING_SIZE = 64;
|
||||
static const int XMIT_RING_SIZE = (8192*4*4);
|
||||
|
||||
void xmit_char(UINT8 data);
|
||||
|
||||
|
@ -32,6 +32,7 @@ midiout_device::midiout_device(const machine_config &mconfig, const char *tag, d
|
||||
|
||||
void midiout_device::device_start()
|
||||
{
|
||||
m_midi = NULL;
|
||||
}
|
||||
|
||||
void midiout_device::device_reset()
|
||||
@ -73,7 +74,10 @@ bool midiout_device::call_load(void)
|
||||
|
||||
void midiout_device::call_unload(void)
|
||||
{
|
||||
osd_close_midi_channel(m_midi);
|
||||
if (m_midi)
|
||||
{
|
||||
osd_close_midi_channel(m_midi);
|
||||
}
|
||||
}
|
||||
|
||||
void midiout_device::rcv_complete() // Rx completed receiving byte
|
||||
@ -81,7 +85,10 @@ void midiout_device::rcv_complete() // Rx completed receiving byte
|
||||
receive_register_extract();
|
||||
UINT8 data = get_received_char();
|
||||
|
||||
osd_write_midi_channel(m_midi, data);
|
||||
if (m_midi)
|
||||
{
|
||||
osd_write_midi_channel(m_midi, data);
|
||||
}
|
||||
}
|
||||
|
||||
void midiout_device::input_callback(UINT8 state)
|
||||
|
@ -13,7 +13,7 @@ const device_type MIDIIN_PORT = &device_creator<midiin_port_device>;
|
||||
midiin_port_device::midiin_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MIDIIN_PORT, "MIDI In port", tag, owner, clock),
|
||||
device_serial_port_interface(mconfig, *this),
|
||||
m_midiin(*this, "midiin")
|
||||
m_midiin(*this, "midiinimg")
|
||||
{
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ static midiin_config midiin_port_image_config =
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT(midiin_port_config)
|
||||
MCFG_MIDIIN_ADD("midiin", midiin_port_image_config)
|
||||
MCFG_MIDIIN_ADD("midiinimg", midiin_port_image_config)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
machine_config_constructor midiin_port_device::device_mconfig_additions() const
|
||||
|
@ -13,12 +13,12 @@ const device_type MIDIOUT_PORT = &device_creator<midiout_port_device>;
|
||||
midiout_port_device::midiout_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MIDIOUT_PORT, "MIDI Out port", tag, owner, clock),
|
||||
device_serial_port_interface(mconfig, *this),
|
||||
m_midiout(*this, "midiout")
|
||||
m_midiout(*this, "midioutimg")
|
||||
{
|
||||
}
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT(midiout_port_config)
|
||||
MCFG_MIDIOUT_ADD("midiout")
|
||||
MCFG_MIDIOUT_ADD("midioutimg")
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
machine_config_constructor midiout_port_device::device_mconfig_additions() const
|
||||
|
@ -10,11 +10,13 @@
|
||||
#include "portmidi/portmidi.h"
|
||||
#include "osdcore.h"
|
||||
|
||||
static const int RX_EVENT_BUF_SIZE = 512;
|
||||
|
||||
struct osd_midi_device
|
||||
{
|
||||
#ifndef DISABLE_MIDI
|
||||
PortMidiStream *pmStream;
|
||||
PmEvent rx_evBuf[20]; // up to 20 events
|
||||
PmEvent rx_evBuf[RX_EVENT_BUF_SIZE];
|
||||
#endif
|
||||
UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes
|
||||
int xmit_cnt;
|
||||
@ -85,7 +87,7 @@ osd_midi_device *osd_open_midi_input(const char *devname)
|
||||
|
||||
if (found_dev >= 0)
|
||||
{
|
||||
if (Pm_OpenInput(&stm, found_dev, NULL, 20, NULL, NULL) == pmNoError)
|
||||
if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError)
|
||||
{
|
||||
ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
|
||||
memset(ret, 0, sizeof(osd_midi_device));
|
||||
@ -132,7 +134,7 @@ osd_midi_device *osd_open_midi_output(const char *devname)
|
||||
|
||||
if (found_dev >= 0)
|
||||
{
|
||||
if (Pm_OpenOutput(&stm, found_dev, NULL, 20, NULL, NULL, 0) == pmNoError)
|
||||
if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError)
|
||||
{
|
||||
ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
|
||||
memset(ret, 0, sizeof(osd_midi_device));
|
||||
@ -175,7 +177,7 @@ bool osd_poll_midi_channel(osd_midi_device *dev)
|
||||
int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut)
|
||||
{
|
||||
#ifndef DISABLE_MIDI
|
||||
int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, 20);
|
||||
int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE);
|
||||
int bytesOut = 0;
|
||||
|
||||
if (msgsRead <= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user