midi out device named correctly to aid code readability

This commit is contained in:
Jasmine Iwanek 2022-03-13 09:00:03 -04:00
parent 51532f7aaa
commit 297909a884
14 changed files with 146 additions and 144 deletions

View file

@ -935,7 +935,9 @@ pc_reset_hard_close(void)
scsi_device_close_all(); scsi_device_close_all();
midi_close(); midi_out_close();
midi_in_close();
cdrom_close(); cdrom_close();
@ -1158,7 +1160,9 @@ pc_close(thread_t *ptr)
scsi_device_close_all(); scsi_device_close_all();
midi_close(); midi_out_close();
midi_in_close();
network_close(); network_close();

View file

@ -1036,9 +1036,9 @@ load_sound(void)
p = config_get_string(cat, "midi_device", NULL); p = config_get_string(cat, "midi_device", NULL);
if (p != NULL) if (p != NULL)
midi_device_current = midi_device_get_from_internal_name(p); midi_output_device_current = midi_out_device_get_from_internal_name(p);
else else
midi_device_current = 0; midi_output_device_current = 0;
p = config_get_string(cat, "midi_in_device", NULL); p = config_get_string(cat, "midi_in_device", NULL);
if (p != NULL) if (p != NULL)
@ -2111,6 +2111,7 @@ config_load(void)
serial_enabled[1] = 1; serial_enabled[1] = 1;
for (i = 2 ; i < SERIAL_MAX; i++) for (i = 2 ; i < SERIAL_MAX; i++)
serial_enabled[i] = 0; serial_enabled[i] = 0;
lpt_ports[0].enabled = 1; lpt_ports[0].enabled = 1;
for (i = 1 ; i < PARALLEL_MAX; i++) for (i = 1 ; i < PARALLEL_MAX; i++)
@ -2529,10 +2530,10 @@ save_sound(void)
else else
config_set_string(cat, "sndcard", sound_card_get_internal_name(sound_card_current)); config_set_string(cat, "sndcard", sound_card_get_internal_name(sound_card_current));
if (!strcmp(midi_device_get_internal_name(midi_device_current), "none")) if (!strcmp(midi_out_device_get_internal_name(midi_output_device_current), "none"))
config_delete_var(cat, "midi_device"); config_delete_var(cat, "midi_device");
else else
config_set_string(cat, "midi_device", midi_device_get_internal_name(midi_device_current)); config_set_string(cat, "midi_device", midi_out_device_get_internal_name(midi_output_device_current));
if (!strcmp(midi_in_device_get_internal_name(midi_input_device_current), "none")) if (!strcmp(midi_in_device_get_internal_name(midi_input_device_current), "none"))
config_delete_var(cat, "midi_in_device"); config_delete_var(cat, "midi_in_device");

View file

@ -6,26 +6,26 @@
extern uint8_t MIDI_InSysexBuf[SYSEX_SIZE]; extern uint8_t MIDI_InSysexBuf[SYSEX_SIZE];
extern uint8_t MIDI_evt_len[256]; extern uint8_t MIDI_evt_len[256];
extern int midi_device_current; extern int midi_output_device_current;
extern int midi_input_device_current; extern int midi_input_device_current;
extern void (*input_msg)(void *p, uint8_t *msg, uint32_t len); extern void (*input_msg)(void *p, uint8_t *msg, uint32_t len);
extern int (*input_sysex)(void *p, uint8_t *buf, uint32_t len, int abort); extern int (*input_sysex)(void *p, uint8_t *buf, uint32_t len, int abort);
extern void *midi_in_p; extern void *midi_in_p;
extern int midi_device_available(int card); extern int midi_out_device_available(int card);
extern int midi_in_device_available(int card); extern int midi_in_device_available(int card);
#ifdef EMU_DEVICE_H #ifdef EMU_DEVICE_H
const device_t *midi_device_getdevice(int card); const device_t *midi_out_device_getdevice(int card);
const device_t *midi_in_device_getdevice(int card); const device_t *midi_in_device_getdevice(int card);
#endif #endif
extern int midi_device_has_config(int card); extern int midi_out_device_has_config(int card);
extern int midi_in_device_has_config(int card); extern int midi_in_device_has_config(int card);
extern char *midi_device_get_internal_name(int card); extern char *midi_out_device_get_internal_name(int card);
extern char *midi_in_device_get_internal_name(int card); extern char *midi_in_device_get_internal_name(int card);
extern int midi_device_get_from_internal_name(char *s); extern int midi_out_device_get_from_internal_name(char *s);
extern int midi_in_device_get_from_internal_name(char *s); extern int midi_in_device_get_from_internal_name(char *s);
extern void midi_device_init(); extern void midi_out_device_init();
extern void midi_in_device_init(); extern void midi_in_device_init();
typedef struct midi_device_t { typedef struct midi_device_t {
@ -56,11 +56,11 @@ typedef struct midi_t {
midi_device_t *m_out_device, *m_in_device; midi_device_t *m_out_device, *m_in_device;
} midi_t; } midi_t;
extern midi_t *midi, *midi_in; extern midi_t *midi_out, *midi_in;
extern void midi_init(midi_device_t *device); extern void midi_out_init(midi_device_t *device);
extern void midi_in_init(midi_device_t *device, midi_t **mididev); extern void midi_in_init(midi_device_t *device, midi_t **mididev);
extern void midi_close(); extern void midi_out_close();
extern void midi_in_close(void); extern void midi_in_close(void);
extern void midi_raw_out_rt_byte(uint8_t val); extern void midi_raw_out_rt_byte(uint8_t val);
extern void midi_raw_out_thru_rt_byte(uint8_t val); extern void midi_raw_out_thru_rt_byte(uint8_t val);
@ -90,7 +90,7 @@ extern void midi_in_sysex(uint8_t *buffer, uint32_t len);
#define MIDI_INPUT_INTERNAL_NAME "midi_in" #define MIDI_INPUT_INTERNAL_NAME "midi_in"
#ifdef EMU_DEVICE_H #ifdef EMU_DEVICE_H
extern const device_t rtmidi_device; extern const device_t rtmidi_output_device;
extern const device_t rtmidi_input_device; extern const device_t rtmidi_input_device;
# ifdef USE_FLUIDSYNTH # ifdef USE_FLUIDSYNTH
extern const device_t fluidsynth_device; extern const device_t fluidsynth_device;

View file

@ -5,8 +5,8 @@
extern "C" { extern "C" {
#endif #endif
extern int rtmidi_get_num_devs(void); extern int rtmidi_out_get_num_devs(void);
extern void rtmidi_get_dev_name(int num, char *s); extern void rtmidi_out_get_dev_name(int num, char *s);
extern int rtmidi_in_get_num_devs(void); extern int rtmidi_in_get_num_devs(void);
extern void rtmidi_in_get_dev_name(int num, char *s); extern void rtmidi_in_get_dev_name(int num, char *s);

View file

@ -75,9 +75,9 @@ void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Setting
auto* model = cbox->model(); auto* model = cbox->model();
int currentIndex = -1; int currentIndex = -1;
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int); int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
for (int i = 0; i < rtmidi_get_num_devs(); i++) { for (int i = 0; i < rtmidi_out_get_num_devs(); i++) {
char midiName[512] = { 0 }; char midiName[512] = { 0 };
rtmidi_get_dev_name(i, midiName); rtmidi_out_get_dev_name(i, midiName);
Models::AddEntry(model, midiName, i); Models::AddEntry(model, midiName, i);
if (selected == i) { if (selected == i) {

View file

@ -45,7 +45,7 @@ SettingsSound::~SettingsSound()
void SettingsSound::save() { void SettingsSound::save() {
sound_card_current = ui->comboBoxSoundCard->currentData().toInt(); sound_card_current = ui->comboBoxSoundCard->currentData().toInt();
midi_device_current = ui->comboBoxMidiOut->currentData().toInt(); midi_output_device_current = ui->comboBoxMidiOut->currentData().toInt();
midi_input_device_current = ui->comboBoxMidiIn->currentData().toInt(); midi_input_device_current = ui->comboBoxMidiIn->currentData().toInt();
mpu401_standalone_enable = ui->checkBoxMPU401->isChecked() ? 1 : 0; mpu401_standalone_enable = ui->checkBoxMPU401->isChecked() ? 1 : 0;
SSI2001 = ui->checkBoxSSI2001->isChecked() ? 1 : 0;; SSI2001 = ui->checkBoxSSI2001->isChecked() ? 1 : 0;;
@ -95,14 +95,14 @@ void SettingsSound::onCurrentMachineChanged(int machineId) {
c = 0; c = 0;
selectedRow = 0; selectedRow = 0;
while (true) { while (true) {
QString name = DeviceConfig::DeviceName(midi_device_getdevice(c), midi_device_get_internal_name(c), 0); QString name = DeviceConfig::DeviceName(midi_out_device_getdevice(c), midi_out_device_get_internal_name(c), 0);
if (name.isEmpty()) { if (name.isEmpty()) {
break; break;
} }
if (midi_device_available(c)) { if (midi_out_device_available(c)) {
int row = Models::AddEntry(model, name, c); int row = Models::AddEntry(model, name, c);
if (c == midi_device_current) { if (c == midi_output_device_current) {
selectedRow = row - removeRows; selectedRow = row - removeRows;
} }
} }
@ -118,7 +118,7 @@ void SettingsSound::onCurrentMachineChanged(int machineId) {
c = 0; c = 0;
selectedRow = 0; selectedRow = 0;
while (true) { while (true) {
QString name = DeviceConfig::DeviceName(midi_in_device_getdevice(c), midi_device_get_internal_name(c), 0); QString name = DeviceConfig::DeviceName(midi_in_device_getdevice(c), midi_in_device_get_internal_name(c), 0);
if (name.isEmpty()) { if (name.isEmpty()) {
break; break;
} }
@ -154,7 +154,7 @@ void SettingsSound::onCurrentMachineChanged(int machineId) {
} }
static bool allowMpu401(Ui::SettingsSound *ui) { static bool allowMpu401(Ui::SettingsSound *ui) {
QString midiOut = midi_device_get_internal_name(ui->comboBoxMidiOut->currentData().toInt()); QString midiOut = midi_out_device_get_internal_name(ui->comboBoxMidiOut->currentData().toInt());
QString midiIn = midi_in_device_get_internal_name(ui->comboBoxMidiIn->currentData().toInt()); QString midiIn = midi_in_device_get_internal_name(ui->comboBoxMidiIn->currentData().toInt());
if (midiOut.isEmpty()) { if (midiOut.isEmpty()) {
@ -184,13 +184,13 @@ void SettingsSound::on_comboBoxMidiOut_currentIndexChanged(int index) {
if (index < 0) { if (index < 0) {
return; return;
} }
ui->pushButtonConfigureMidiOut->setEnabled(midi_device_has_config(ui->comboBoxMidiOut->currentData().toInt())); ui->pushButtonConfigureMidiOut->setEnabled(midi_out_device_has_config(ui->comboBoxMidiOut->currentData().toInt()));
ui->checkBoxMPU401->setEnabled(allowMpu401(ui) && (machine_has_bus(machineId, MACHINE_BUS_ISA) || machine_has_bus(machineId, MACHINE_BUS_MCA))); ui->checkBoxMPU401->setEnabled(allowMpu401(ui) && (machine_has_bus(machineId, MACHINE_BUS_ISA) || machine_has_bus(machineId, MACHINE_BUS_MCA)));
ui->pushButtonConfigureMPU401->setEnabled(allowMpu401(ui) && ui->checkBoxMPU401->isChecked()); ui->pushButtonConfigureMPU401->setEnabled(allowMpu401(ui) && ui->checkBoxMPU401->isChecked());
} }
void SettingsSound::on_pushButtonConfigureMidiOut_clicked() { void SettingsSound::on_pushButtonConfigureMidiOut_clicked() {
DeviceConfig::ConfigureDevice(midi_device_getdevice(ui->comboBoxMidiOut->currentData().toInt()), 0, qobject_cast<Settings*>(Settings::settings)); DeviceConfig::ConfigureDevice(midi_out_device_getdevice(ui->comboBoxMidiOut->currentData().toInt()), 0, qobject_cast<Settings*>(Settings::settings));
} }
void SettingsSound::on_comboBoxMidiIn_currentIndexChanged(int index) { void SettingsSound::on_comboBoxMidiIn_currentIndexChanged(int index) {

View file

@ -31,12 +31,12 @@
#include <86box/midi.h> #include <86box/midi.h>
#include <86box/plat.h> #include <86box/plat.h>
int midi_device_current = 0; int midi_output_device_current = 0;
static int midi_device_last = 0; static int midi_output_device_last = 0;
int midi_input_device_current = 0; int midi_input_device_current = 0;
static int midi_input_device_last = 0; static int midi_input_device_last = 0;
midi_t *midi = NULL, *midi_in = NULL; midi_t *midi_out = NULL, *midi_in = NULL;
midi_in_handler_t *mih_first = NULL, *mih_last = NULL, midi_in_handler_t *mih_first = NULL, *mih_last = NULL,
*mih_cur = NULL; *mih_cur = NULL;
@ -69,9 +69,9 @@ uint8_t MIDI_evt_len[256] = {
typedef struct typedef struct
{ {
const device_t *device; const device_t *device;
} MIDI_DEVICE, MIDI_IN_DEVICE; } MIDI_OUT_DEVICE, MIDI_IN_DEVICE;
static const device_t midi_none_device = { static const device_t midi_out_none_device = {
"None", "None",
"none", "none",
0, 0,
@ -85,20 +85,20 @@ static const device_t midi_none_device = {
NULL NULL
}; };
static const MIDI_DEVICE devices[] = { static const MIDI_OUT_DEVICE devices[] = {
// clang-format off // clang-format off
{ &midi_none_device }, { &midi_out_none_device },
#ifdef USE_FLUIDSYNTH #ifdef USE_FLUIDSYNTH
{ &fluidsynth_device }, { &fluidsynth_device },
#endif #endif
#ifdef USE_MUNT #ifdef USE_MUNT
{ &mt32_device }, { &mt32_device },
{ &cm32l_device }, { &cm32l_device },
#endif #endif
#ifdef USE_RTMIDI #ifdef USE_RTMIDI
{ &rtmidi_device }, { &rtmidi_output_device },
#endif #endif
{ NULL } { NULL }
// clang-format on // clang-format on
}; };
@ -127,7 +127,7 @@ static const MIDI_IN_DEVICE midi_in_devices[] = {
}; };
int int
midi_device_available(int card) midi_out_device_available(int card)
{ {
if (devices[card].device) if (devices[card].device)
return device_available(devices[card].device); return device_available(devices[card].device);
@ -136,13 +136,13 @@ midi_device_available(int card)
} }
const device_t * const device_t *
midi_device_getdevice(int card) midi_out_device_getdevice(int card)
{ {
return devices[card].device; return devices[card].device;
} }
int int
midi_device_has_config(int card) midi_out_device_has_config(int card)
{ {
if (!devices[card].device) if (!devices[card].device)
return 0; return 0;
@ -150,13 +150,13 @@ midi_device_has_config(int card)
} }
char * char *
midi_device_get_internal_name(int card) midi_out_device_get_internal_name(int card)
{ {
return device_get_internal_name(devices[card].device); return device_get_internal_name(devices[card].device);
} }
int int
midi_device_get_from_internal_name(char *s) midi_out_device_get_from_internal_name(char *s)
{ {
int c = 0; int c = 0;
@ -170,20 +170,20 @@ midi_device_get_from_internal_name(char *s)
} }
void void
midi_device_init() midi_out_device_init()
{ {
if (devices[midi_device_current].device) if (devices[midi_output_device_current].device)
device_add(devices[midi_device_current].device); device_add(devices[midi_output_device_current].device);
midi_device_last = midi_device_current; midi_output_device_last = midi_output_device_current;
} }
void void
midi_init(midi_device_t *device) midi_out_init(midi_device_t *device)
{ {
midi = (midi_t *) malloc(sizeof(midi_t)); midi_out = (midi_t *) malloc(sizeof(midi_t));
memset(midi, 0, sizeof(midi_t)); memset(midi_out, 0, sizeof(midi_t));
midi->m_out_device = device; midi_out->m_out_device = device;
} }
void void
@ -196,16 +196,16 @@ midi_in_init(midi_device_t *device, midi_t **mididev)
} }
void void
midi_close(void) midi_out_close(void)
{ {
if (midi && midi->m_out_device) { if (midi_out && midi_out->m_out_device) {
free(midi->m_out_device); free(midi_out->m_out_device);
midi->m_out_device = NULL; midi_out->m_out_device = NULL;
} }
if (midi) { if (midi_out) {
free(midi); free(midi_out);
midi = NULL; midi_out = NULL;
} }
} }
@ -226,22 +226,22 @@ midi_in_close(void)
void void
midi_poll(void) midi_poll(void)
{ {
if (midi && midi->m_out_device && midi->m_out_device->poll) if (midi_out && midi_out->m_out_device && midi_out->m_out_device->poll)
midi->m_out_device->poll(); midi_out->m_out_device->poll();
} }
void void
play_msg(uint8_t *msg) play_msg(uint8_t *msg)
{ {
if (midi->m_out_device->play_msg) if (midi_out->m_out_device->play_msg)
midi->m_out_device->play_msg(msg); midi_out->m_out_device->play_msg(msg);
} }
void void
play_sysex(uint8_t *sysex, unsigned int len) play_sysex(uint8_t *sysex, unsigned int len)
{ {
if (midi->m_out_device->play_sysex) if (midi_out->m_out_device->play_sysex)
midi->m_out_device->play_sysex(sysex, len); midi_out->m_out_device->play_sysex(sysex, len);
} }
int int
@ -324,69 +324,69 @@ midi_raw_out_byte(uint8_t val)
{ {
uint32_t passed_ticks; uint32_t passed_ticks;
if (!midi || !midi->m_out_device) if (!midi_out || !midi_out->m_out_device)
return; return;
if ((midi->m_out_device->write && midi->m_out_device->write(val))) if ((midi_out->m_out_device->write && midi_out->m_out_device->write(val)))
return; return;
if (midi->midi_sysex_start) { if (midi_out->midi_sysex_start) {
passed_ticks = plat_get_ticks() - midi->midi_sysex_start; passed_ticks = plat_get_ticks() - midi_out->midi_sysex_start;
if (passed_ticks < midi->midi_sysex_delay) if (passed_ticks < midi_out->midi_sysex_delay)
plat_delay_ms(midi->midi_sysex_delay - passed_ticks); plat_delay_ms(midi_out->midi_sysex_delay - passed_ticks);
} }
/* Test for a realtime MIDI message */ /* Test for a realtime MIDI message */
if (val >= 0xf8) { if (val >= 0xf8) {
midi->midi_rt_buf[0] = val; midi_out->midi_rt_buf[0] = val;
play_msg(midi->midi_rt_buf); play_msg(midi_out->midi_rt_buf);
return; return;
} }
/* Test for a active sysex transfer */ /* Test for a active sysex transfer */
if (midi->midi_status == 0xf0) { if (midi_out->midi_status == 0xf0) {
if (!(val & 0x80)) { if (!(val & 0x80)) {
if (midi->midi_pos < (SYSEX_SIZE - 1)) if (midi_out->midi_pos < (SYSEX_SIZE - 1))
midi->midi_sysex_data[midi->midi_pos++] = val; midi_out->midi_sysex_data[midi_out->midi_pos++] = val;
return; return;
} else { } else {
midi->midi_sysex_data[midi->midi_pos++] = 0xf7; midi_out->midi_sysex_data[midi_out->midi_pos++] = 0xf7;
if ((midi->midi_sysex_start) && (midi->midi_pos >= 4) && (midi->midi_pos <= 9) && (midi->midi_sysex_data[1] == 0x41) && (midi->midi_sysex_data[3] == 0x16)) { if ((midi_out->midi_sysex_start) && (midi_out->midi_pos >= 4) && (midi_out->midi_pos <= 9) && (midi_out->midi_sysex_data[1] == 0x41) && (midi_out->midi_sysex_data[3] == 0x16)) {
/* pclog("MIDI: Skipping invalid MT-32 SysEx MIDI message\n"); */ /* pclog("MIDI: Skipping invalid MT-32 SysEx MIDI message\n"); */
} else { } else {
play_sysex(midi->midi_sysex_data, midi->midi_pos); play_sysex(midi_out->midi_sysex_data, midi_out->midi_pos);
if (midi->midi_sysex_start) { if (midi_out->midi_sysex_start) {
if (midi->midi_sysex_data[5] == 0x7f) if (midi_out->midi_sysex_data[5] == 0x7f)
midi->midi_sysex_delay = 290; /* All parameters reset */ midi_out->midi_sysex_delay = 290; /* All parameters reset */
else if ((midi->midi_sysex_data[5] == 0x10) && (midi->midi_sysex_data[6] == 0x00) && (midi->midi_sysex_data[7] == 0x04)) else if ((midi_out->midi_sysex_data[5] == 0x10) && (midi_out->midi_sysex_data[6] == 0x00) && (midi_out->midi_sysex_data[7] == 0x04))
midi->midi_sysex_delay = 145; /* Viking Child */ midi_out->midi_sysex_delay = 145; /* Viking Child */
else if ((midi->midi_sysex_data[5] == 0x10) && (midi->midi_sysex_data[6] == 0x00) && (midi->midi_sysex_data[7] == 0x01)) else if ((midi_out->midi_sysex_data[5] == 0x10) && (midi_out->midi_sysex_data[6] == 0x00) && (midi_out->midi_sysex_data[7] == 0x01))
midi->midi_sysex_delay = 30; /* Dark Sun 1 */ midi_out->midi_sysex_delay = 30; /* Dark Sun 1 */
else else
midi->midi_sysex_delay = (unsigned int) (((float) (midi->midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2; midi_out->midi_sysex_delay = (unsigned int) (((float) (midi_out->midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2;
midi->midi_sysex_start = plat_get_ticks(); midi_out->midi_sysex_start = plat_get_ticks();
} }
} }
} }
} }
if (val & 0x80) { if (val & 0x80) {
midi->midi_status = val; midi_out->midi_status = val;
midi->midi_cmd_pos = 0; midi_out->midi_cmd_pos = 0;
midi->midi_cmd_len = MIDI_evt_len[val]; midi_out->midi_cmd_len = MIDI_evt_len[val];
if (midi->midi_status == 0xf0) { if (midi_out->midi_status == 0xf0) {
midi->midi_sysex_data[0] = 0xf0; midi_out->midi_sysex_data[0] = 0xf0;
midi->midi_pos = 1; midi_out->midi_pos = 1;
} }
} }
if (midi->midi_cmd_len) { if (midi_out->midi_cmd_len) {
midi->midi_cmd_buf[midi->midi_cmd_pos++] = val; midi_out->midi_cmd_buf[midi_out->midi_cmd_pos++] = val;
if (midi->midi_cmd_pos >= midi->midi_cmd_len) { if (midi_out->midi_cmd_pos >= midi_out->midi_cmd_len) {
play_msg(midi->midi_cmd_buf); play_msg(midi_out->midi_cmd_buf);
midi->midi_cmd_pos = 1; midi_out->midi_cmd_pos = 1;
} }
} }
} }
@ -394,13 +394,13 @@ midi_raw_out_byte(uint8_t val)
void void
midi_clear_buffer(void) midi_clear_buffer(void)
{ {
if (!midi) if (!midi_out)
return; return;
midi->midi_pos = 0; midi_out->midi_pos = 0;
midi->midi_status = 0x00; midi_out->midi_status = 0x00;
midi->midi_cmd_pos = 0; midi_out->midi_cmd_pos = 0;
midi->midi_cmd_len = 0; midi_out->midi_cmd_len = 0;
} }
void void

View file

@ -317,7 +317,7 @@ fluidsynth_init(const device_t *info)
dev->play_sysex = fluidsynth_sysex; dev->play_sysex = fluidsynth_sysex;
dev->poll = fluidsynth_poll; dev->poll = fluidsynth_poll;
midi_init(dev); midi_out_init(dev);
data->on = 1; data->on = 1;

View file

@ -272,7 +272,7 @@ mt32emu_init(char *control_rom, char *pcm_rom)
dev->play_sysex = mt32_sysex; dev->play_sysex = mt32_sysex;
dev->poll = mt32_poll; dev->poll = mt32_poll;
midi_init(dev); midi_out_init(dev);
mt32_on = 1; mt32_on = 1;

View file

@ -66,7 +66,7 @@ rtmidi_play_sysex(uint8_t *sysex, unsigned int len)
void* void*
rtmidi_init(const device_t *info) rtmidi_output_init(const device_t *info)
{ {
midi_device_t* dev = (midi_device_t*)malloc(sizeof(midi_device_t)); midi_device_t* dev = (midi_device_t*)malloc(sizeof(midi_device_t));
memset(dev, 0, sizeof(midi_device_t)); memset(dev, 0, sizeof(midi_device_t));
@ -99,14 +99,14 @@ rtmidi_init(const device_t *info)
} }
} }
midi_init(dev); midi_out_init(dev);
return dev; return dev;
} }
void void
rtmidi_close(void *p) rtmidi_output_close(void *p)
{ {
if (!midiout) if (!midiout)
return; return;
@ -116,12 +116,12 @@ rtmidi_close(void *p)
delete midiout; delete midiout;
midiout = nullptr; midiout = nullptr;
midi_close(); midi_out_close();
} }
int int
rtmidi_get_num_devs(void) rtmidi_out_get_num_devs(void)
{ {
if (!midiout) { if (!midiout) {
try { try {
@ -136,7 +136,7 @@ rtmidi_get_num_devs(void)
void void
rtmidi_get_dev_name(int num, char *s) rtmidi_out_get_dev_name(int num, char *s)
{ {
strcpy(s, midiout->getPortName(num).c_str()); strcpy(s, midiout->getPortName(num).c_str());
} }
@ -207,7 +207,7 @@ rtmidi_input_close(void* p)
delete midiin; delete midiin;
midiin = nullptr; midiin = nullptr;
midi_close(); midi_out_close();
} }
@ -232,8 +232,7 @@ rtmidi_in_get_dev_name(int num, char *s)
strcpy(s, midiin->getPortName(num).c_str()); strcpy(s, midiin->getPortName(num).c_str());
} }
static const device_config_t system_midi_config[] = static const device_config_t system_midi_config[] = {
{
{ {
"midi", "MIDI out device", CONFIG_MIDI_OUT, "", 0 "midi", "MIDI out device", CONFIG_MIDI_OUT, "", 0
}, },
@ -242,8 +241,7 @@ static const device_config_t system_midi_config[] =
} }
}; };
static const device_config_t midi_input_config[] = static const device_config_t midi_input_config[] = {
{
{ {
"midi_input", "MIDI in device", CONFIG_MIDI_IN, "", 0 "midi_input", "MIDI in device", CONFIG_MIDI_IN, "", 0
}, },
@ -261,15 +259,14 @@ static const device_config_t midi_input_config[] =
} }
}; };
const device_t rtmidi_device = const device_t rtmidi_output_device = {
{
SYSTEM_MIDI_NAME, SYSTEM_MIDI_NAME,
SYSTEM_MIDI_INTERNAL_NAME, SYSTEM_MIDI_INTERNAL_NAME,
0, 0, 0, 0,
rtmidi_init, rtmidi_output_init,
rtmidi_close, rtmidi_output_close,
NULL, NULL,
{ rtmidi_get_num_devs }, { rtmidi_out_get_num_devs },
NULL, NULL,
NULL, NULL,
system_midi_config system_midi_config

View file

@ -481,7 +481,7 @@ sound_reset(void)
{ {
sound_realloc_buffers(); sound_realloc_buffers();
midi_device_init(); midi_out_device_init();
midi_in_device_init(); midi_in_device_init();
inital(); inital();

View file

@ -167,7 +167,7 @@ inital()
IXAudio2SourceVoice_Start(srcvoice, 0, XAUDIO2_COMMIT_NOW); IXAudio2SourceVoice_Start(srcvoice, 0, XAUDIO2_COMMIT_NOW);
IXAudio2SourceVoice_Start(srcvoicecd, 0, XAUDIO2_COMMIT_NOW); IXAudio2SourceVoice_Start(srcvoicecd, 0, XAUDIO2_COMMIT_NOW);
char *mdn = midi_device_get_internal_name(midi_device_current); char *mdn = midi_out_device_get_internal_name(midi_output_device_current);
if (strcmp(mdn, "none") && strcmp(mdn, SYSTEM_MIDI_INTERNAL_NAME)) { if (strcmp(mdn, "none") && strcmp(mdn, SYSTEM_MIDI_INTERNAL_NAME)) {
fmt.nSamplesPerSec = midi_freq; fmt.nSamplesPerSec = midi_freq;

View file

@ -98,9 +98,9 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
val_int = config_get_int((char *) config_device.name, val_int = config_get_int((char *) config_device.name,
(char *) config->name, config->default_int); (char *) config->name, config->default_int);
num = rtmidi_get_num_devs(); num = rtmidi_out_get_num_devs();
for (c = 0; c < num; c++) { for (c = 0; c < num; c++) {
rtmidi_get_dev_name(c, s); rtmidi_out_get_dev_name(c, s);
mbstowcs(lptsTemp, s, strlen(s) + 1); mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp);
if (val_int == c) if (val_int == c)

View file

@ -91,7 +91,7 @@ static int temp_gfxcard, temp_voodoo;
static int temp_mouse, temp_joystick; static int temp_mouse, temp_joystick;
/* Sound category */ /* Sound category */
static int temp_sound_card, temp_midi_device, temp_midi_input_device, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS; static int temp_sound_card, temp_midi_output_device, temp_midi_input_device, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS;
static int temp_float; static int temp_float;
/* Network category */ /* Network category */
@ -339,7 +339,7 @@ win_settings_init(void)
/* Sound category */ /* Sound category */
temp_sound_card = sound_card_current; temp_sound_card = sound_card_current;
temp_midi_device = midi_device_current; temp_midi_output_device = midi_output_device_current;
temp_midi_input_device = midi_input_device_current; temp_midi_input_device = midi_input_device_current;
temp_mpu401 = mpu401_standalone_enable; temp_mpu401 = mpu401_standalone_enable;
temp_SSI2001 = SSI2001; temp_SSI2001 = SSI2001;
@ -463,7 +463,7 @@ win_settings_changed(void)
/* Sound category */ /* Sound category */
i = i || (sound_card_current != temp_sound_card); i = i || (sound_card_current != temp_sound_card);
i = i || (midi_device_current != temp_midi_device); i = i || (midi_output_device_current != temp_midi_output_device);
i = i || (midi_input_device_current != temp_midi_input_device); i = i || (midi_input_device_current != temp_midi_input_device);
i = i || (mpu401_standalone_enable != temp_mpu401); i = i || (mpu401_standalone_enable != temp_mpu401);
i = i || (SSI2001 != temp_SSI2001); i = i || (SSI2001 != temp_SSI2001);
@ -553,7 +553,7 @@ win_settings_save(void)
/* Sound category */ /* Sound category */
sound_card_current = temp_sound_card; sound_card_current = temp_sound_card;
midi_device_current = temp_midi_device; midi_output_device_current = temp_midi_output_device;
midi_input_device_current = temp_midi_input_device; midi_input_device_current = temp_midi_input_device;
mpu401_standalone_enable = temp_mpu401; mpu401_standalone_enable = temp_mpu401;
SSI2001 = temp_SSI2001; SSI2001 = temp_SSI2001;
@ -1261,7 +1261,7 @@ mpu401_standalone_allow(void)
if (!machine_has_bus(temp_machine, MACHINE_BUS_ISA) && !machine_has_bus(temp_machine, MACHINE_BUS_MCA)) if (!machine_has_bus(temp_machine, MACHINE_BUS_ISA) && !machine_has_bus(temp_machine, MACHINE_BUS_MCA))
return 0; return 0;
md = midi_device_get_internal_name(temp_midi_device); md = midi_out_device_get_internal_name(temp_midi_output_device);
mdin = midi_in_device_get_internal_name(temp_midi_input_device); mdin = midi_in_device_get_internal_name(temp_midi_input_device);
if (md != NULL) { if (md != NULL) {
@ -1327,18 +1327,18 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
c = d = 0; c = d = 0;
settings_reset_content(hdlg, IDC_COMBO_MIDI_OUT); settings_reset_content(hdlg, IDC_COMBO_MIDI_OUT);
while (1) { while (1) {
generate_device_name(midi_device_getdevice(c), midi_device_get_internal_name(c), 0); generate_device_name(midi_out_device_getdevice(c), midi_out_device_get_internal_name(c), 0);
if (!device_name[0]) if (!device_name[0])
break; break;
if (midi_device_available(c)) { if (midi_out_device_available(c)) {
if (c == 0) if (c == 0)
settings_add_string(hdlg, IDC_COMBO_MIDI_OUT, win_get_string(IDS_2103)); settings_add_string(hdlg, IDC_COMBO_MIDI_OUT, win_get_string(IDS_2103));
else else
settings_add_string(hdlg, IDC_COMBO_MIDI_OUT, (LPARAM) device_name); settings_add_string(hdlg, IDC_COMBO_MIDI_OUT, (LPARAM) device_name);
settings_list_to_midi[d] = c; settings_list_to_midi[d] = c;
if ((c == 0) || (c == temp_midi_device)) if ((c == 0) || (c == temp_midi_output_device))
settings_set_cur_sel(hdlg, IDC_COMBO_MIDI_OUT, d); settings_set_cur_sel(hdlg, IDC_COMBO_MIDI_OUT, d);
d++; d++;
} }
@ -1346,7 +1346,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
c++; c++;
} }
settings_enable_window(hdlg, IDC_CONFIGURE_MIDI_OUT, midi_device_has_config(temp_midi_device)); settings_enable_window(hdlg, IDC_CONFIGURE_MIDI_OUT, midi_out_device_has_config(temp_midi_output_device));
c = d = 0; c = d = 0;
settings_reset_content(hdlg, IDC_COMBO_MIDI_IN); settings_reset_content(hdlg, IDC_COMBO_MIDI_IN);
@ -1405,16 +1405,16 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
case IDC_COMBO_MIDI_OUT: case IDC_COMBO_MIDI_OUT:
temp_midi_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)]; temp_midi_output_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)];
settings_enable_window(hdlg, IDC_CONFIGURE_MIDI_OUT, midi_device_has_config(temp_midi_device)); settings_enable_window(hdlg, IDC_CONFIGURE_MIDI_OUT, midi_out_device_has_config(temp_midi_output_device));
settings_set_check(hdlg, IDC_CHECK_MPU401, temp_mpu401); settings_set_check(hdlg, IDC_CHECK_MPU401, temp_mpu401);
settings_enable_window(hdlg, IDC_CHECK_MPU401, mpu401_standalone_allow()); settings_enable_window(hdlg, IDC_CHECK_MPU401, mpu401_standalone_allow());
settings_enable_window(hdlg, IDC_CONFIGURE_MPU401, mpu401_standalone_allow() && temp_mpu401); settings_enable_window(hdlg, IDC_CONFIGURE_MPU401, mpu401_standalone_allow() && temp_mpu401);
break; break;
case IDC_CONFIGURE_MIDI_OUT: case IDC_CONFIGURE_MIDI_OUT:
temp_midi_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)]; temp_midi_output_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)];
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)midi_device_getdevice(temp_midi_device)); temp_deviceconfig |= deviceconfig_open(hdlg, (void *)midi_out_device_getdevice(temp_midi_output_device));
break; break;
case IDC_COMBO_MIDI_IN: case IDC_COMBO_MIDI_IN:
@ -1474,7 +1474,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SAVESETTINGS: case WM_SAVESETTINGS:
temp_sound_card = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SOUND)]; temp_sound_card = settings_list_to_device[0][settings_get_cur_sel(hdlg, IDC_COMBO_SOUND)];
temp_midi_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)]; temp_midi_output_device = settings_list_to_midi[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_OUT)];
temp_midi_input_device = settings_list_to_midi_in[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_IN)]; temp_midi_input_device = settings_list_to_midi_in[settings_get_cur_sel(hdlg, IDC_COMBO_MIDI_IN)];
temp_mpu401 = settings_get_check(hdlg, IDC_CHECK_MPU401); temp_mpu401 = settings_get_check(hdlg, IDC_CHECK_MPU401);
temp_GAMEBLASTER = settings_get_check(hdlg, IDC_CHECK_CMS); temp_GAMEBLASTER = settings_get_check(hdlg, IDC_CHECK_CMS);