Split generic CD-ROM from SCSI-style CD-ROM;
Redid the way SCSI and ATAPI devices are handled; Slight timings change in the NCR 5380; Devices are now closed by device_close_all() in the reverse order of the one in which they were started; Slight changes to some code in win/; Added the WM_HARDRESET and WM_SHUTDOWN window messages for configuration manager purposes.
This commit is contained in:
@@ -83,6 +83,8 @@ int cm32l_available()
|
||||
|
||||
static thread_t *thread_h = NULL;
|
||||
static event_t *event = NULL;
|
||||
static event_t *start_event = NULL;
|
||||
static int mt32_on = 0;
|
||||
|
||||
#define RENDER_RATE 100
|
||||
#define BUFFER_SEGMENTS 10
|
||||
@@ -119,13 +121,19 @@ static void mt32_thread(void *param)
|
||||
{
|
||||
int buf_pos = 0;
|
||||
int bsize = buf_size / BUFFER_SEGMENTS;
|
||||
while (1)
|
||||
float *buf;
|
||||
int16_t *buf16;
|
||||
|
||||
thread_set_event(start_event);
|
||||
|
||||
while (mt32_on)
|
||||
{
|
||||
thread_wait_event(event, -1);
|
||||
thread_reset_event(event);
|
||||
|
||||
if (sound_is_float)
|
||||
{
|
||||
float *buf = (float *) ((uint8_t*)buffer + buf_pos);
|
||||
buf = (float *) ((uint8_t*)buffer + buf_pos);
|
||||
memset(buf, 0, bsize);
|
||||
mt32_stream(buf, bsize / (2 * sizeof(float)));
|
||||
buf_pos += bsize;
|
||||
@@ -138,9 +146,9 @@ static void mt32_thread(void *param)
|
||||
}
|
||||
else
|
||||
{
|
||||
int16_t *buf = (int16_t *) ((uint8_t*)buffer_int16 + buf_pos);
|
||||
memset(buf, 0, bsize);
|
||||
mt32_stream_int16(buf, bsize / (2 * sizeof(int16_t)));
|
||||
buf16 = (int16_t *) ((uint8_t*)buffer_int16 + buf_pos);
|
||||
memset(buf16, 0, bsize);
|
||||
mt32_stream_int16(buf16, bsize / (2 * sizeof(int16_t)));
|
||||
buf_pos += bsize;
|
||||
if (buf_pos >= buf_size)
|
||||
{
|
||||
@@ -164,9 +172,12 @@ void mt32_sysex(uint8_t* data, unsigned int len)
|
||||
|
||||
void* mt32emu_init(wchar_t *control_rom, wchar_t *pcm_rom)
|
||||
{
|
||||
midi_device_t* dev;
|
||||
wchar_t s[512];
|
||||
char fn[512];
|
||||
|
||||
context = mt32emu_create_context(handler, NULL);
|
||||
|
||||
if (!rom_getfile(control_rom, s, 512)) return 0;
|
||||
wcstombs(fn, s, (wcslen(s) << 1) + 2);
|
||||
if (!mt32_check("mt32emu_add_rom_file", mt32emu_add_rom_file(context, fn), MT32EMU_RC_ADDED_CONTROL_ROM)) return 0;
|
||||
@@ -176,8 +187,6 @@ void* mt32emu_init(wchar_t *control_rom, wchar_t *pcm_rom)
|
||||
|
||||
if (!mt32_check("mt32emu_open_synth", mt32emu_open_synth(context), MT32EMU_RC_OK)) return 0;
|
||||
|
||||
event = thread_create_event();
|
||||
thread_h = thread_create(mt32_thread, 0);
|
||||
samplerate = mt32emu_get_actual_stereo_output_samplerate(context);
|
||||
/* buf_size = samplerate/RENDER_RATE*2; */
|
||||
if (sound_is_float)
|
||||
@@ -201,7 +210,7 @@ void* mt32emu_init(wchar_t *control_rom, wchar_t *pcm_rom)
|
||||
|
||||
al_set_midi(samplerate, buf_size);
|
||||
|
||||
midi_device_t* dev = malloc(sizeof(midi_device_t));
|
||||
dev = malloc(sizeof(midi_device_t));
|
||||
memset(dev, 0, sizeof(midi_device_t));
|
||||
|
||||
dev->play_msg = mt32_msg;
|
||||
@@ -210,6 +219,16 @@ void* mt32emu_init(wchar_t *control_rom, wchar_t *pcm_rom)
|
||||
|
||||
midi_init(dev);
|
||||
|
||||
mt32_on = 1;
|
||||
|
||||
start_event = thread_create_event();
|
||||
|
||||
event = thread_create_event();
|
||||
thread_h = thread_create(mt32_thread, 0);
|
||||
|
||||
thread_wait_event(start_event, -1);
|
||||
thread_reset_event(start_event);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -227,15 +246,15 @@ void mt32_close(void* p)
|
||||
{
|
||||
if (!p) return;
|
||||
|
||||
if (thread_h)
|
||||
thread_kill(thread_h);
|
||||
if (event)
|
||||
thread_destroy_event(event);
|
||||
mt32_on = 0;
|
||||
thread_set_event(event);
|
||||
thread_wait(thread_h, -1);
|
||||
|
||||
event = NULL;
|
||||
start_event = NULL;
|
||||
thread_h = NULL;
|
||||
|
||||
if (context)
|
||||
{
|
||||
if (context) {
|
||||
mt32emu_close_synth(context);
|
||||
mt32emu_free_context(context);
|
||||
}
|
||||
@@ -248,10 +267,6 @@ void mt32_close(void* p)
|
||||
if (buffer_int16)
|
||||
free(buffer_int16);
|
||||
buffer_int16 = NULL;
|
||||
|
||||
midi_close();
|
||||
|
||||
free((midi_device_t*)p);
|
||||
}
|
||||
|
||||
static const device_config_t mt32_config[] =
|
||||
|
||||
Reference in New Issue
Block a user