aboutsummaryrefslogtreecommitdiff
path: root/sound/mididrv.cpp
diff options
context:
space:
mode:
authorMax Horn2002-12-11 16:09:58 +0000
committerMax Horn2002-12-11 16:09:58 +0000
commitbf62494fd5fc578a609b5986237035997c214b15 (patch)
tree68c3f90d9ddd0f93fafc1c84548e611d458d88de /sound/mididrv.cpp
parent5bf87dd3682af7de77fd0fff8d182087ebc8151a (diff)
downloadscummvm-rg350-bf62494fd5fc578a609b5986237035997c214b15.tar.gz
scummvm-rg350-bf62494fd5fc578a609b5986237035997c214b15.tar.bz2
scummvm-rg350-bf62494fd5fc578a609b5986237035997c214b15.zip
ripped out obsolete midi streaming code from backends (this may break Alsa/SEQ/Windows/Morphos compile, I tried my best, but you'll have to clean up after me)
svn-id: r5905
Diffstat (limited to 'sound/mididrv.cpp')
-rw-r--r--sound/mididrv.cpp212
1 files changed, 24 insertions, 188 deletions
diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp
index d473ed128b..d8d0db83ac 100644
--- a/sound/mididrv.cpp
+++ b/sound/mididrv.cpp
@@ -42,7 +42,7 @@ uint32 MidiDriver::property(int prop, uint32 param)
/* retrieve a string representation of an error code */
-const char *MidiDriver::get_error_name(int error_code)
+const char *MidiDriver::getErrorName(int error_code)
{
static const char *const midi_errors[] = {
"No error",
@@ -69,14 +69,12 @@ const char *MidiDriver::get_error_name(int error_code)
#include "morphos_sound.h"
/* MorphOS MIDI driver */
-class MidiDriver_ETUDE:public MidiDriver_MPU401 {
+class MidiDriver_ETUDE : public MidiDriver_MPU401 {
public:
+ MidiDriver_ETUDE();
int open(int mode);
void close();
void send(uint32 b);
- void pause(bool p);
- void set_stream_callback(void *param, StreamCallback *sc);
- // void setPitchBendRange (byte channel, uint range);
private:
enum {
@@ -85,88 +83,37 @@ private:
BUFFER_SIZE = MIDI_EVENT_SIZE * 12,
};
- static void midi_callback(ULONG msg, struct IOMidiRequest *req, APTR user_data);
- void fill_all();
uint32 property(int prop, uint32 param);
- StreamCallback *_stream_proc;
- void *_stream_param;
- IOMidiRequest *_stream_req[NUM_BUFFERS];
- void *_stream_buf[NUM_BUFFERS];
- bool _req_sent[NUM_BUFFERS];
- int _mode;
- uint16 _time_div;
+ bool _isOpen;
};
-void MidiDriver_ETUDE::set_stream_callback(void *param, StreamCallback *sc)
+MidiDriver_ETUDE::MidiDriver_ETUDE()
{
- _stream_param = param;
- _stream_proc = sc;
+ _isOpen = false;
}
-int MidiDriver_ETUDE::open(int mode)
+int MidiDriver_ETUDE::open()
{
- if (_mode != 0)
+ if (_isOpen)
return MERR_ALREADY_OPEN;
- _mode = mode;
- if (!init_morphos_music(0, _mode == MO_STREAMING ? ETUDEF_STREAMING : ETUDEF_DIRECT))
+ _isOpen = true;
+ if (!init_morphos_music(0, ETUDEF_DIRECT))
return MERR_DEVICE_NOT_AVAILABLE;
- if (_mode == MO_STREAMING && ScummMidiRequest) {
- _stream_req[0] = ScummMidiRequest;
- _stream_req[1] = (IOMidiRequest *) AllocVec(sizeof (IOMidiRequest), MEMF_PUBLIC);
- _stream_buf[0] = AllocVec(BUFFER_SIZE, MEMF_PUBLIC);
- _stream_buf[1] = AllocVec(BUFFER_SIZE, MEMF_PUBLIC);
- _req_sent[0] = _req_sent[1] = false;
-
- if (_stream_req[1] == NULL || _stream_buf[0] == NULL || _stream_buf[1] == NULL) {
- close();
- return MERR_DEVICE_NOT_AVAILABLE;
- }
-
- if (ScummMidiRequest)
- {
- memcpy(_stream_req[1], _stream_req[0], sizeof (IOMidiRequest));
- struct TagItem MidiStreamTags[] = { { ESA_Callback, (ULONG) &midi_callback },
- { ESA_UserData, (ULONG) this },
- { ESA_TimeDiv, _time_div },
- { TAG_DONE, 0 }
- };
- SetMidiStreamAttrsA(ScummMidiRequest, MidiStreamTags);
- fill_all();
- }
- }
-
return 0;
}
void MidiDriver_ETUDE::close()
{
- if (_mode == MO_STREAMING) {
- if (_req_sent[0]) {
- AbortIO((IORequest *) _stream_req[0]);
- WaitIO((IORequest *) _stream_req[0]);
- _req_sent[0] = false;
- }
- if (_req_sent[1]) {
- AbortIO((IORequest *) _stream_req[1]);
- WaitIO((IORequest *) _stream_req[1]);
- _req_sent[1] = false;
- }
-
- if (_stream_req[1]) FreeVec(_stream_req[1]);
- if (_stream_buf[0]) FreeVec(_stream_buf[0]);
- if (_stream_buf[1]) FreeVec(_stream_buf[1]);
- }
-
exit_morphos_music();
- _mode = 0;
+ _isOpen = false;
}
void MidiDriver_ETUDE::send(uint32 b)
{
- if (_mode != MO_SIMPLE)
- error("MidiDriver_ETUDE::send called but driver is not in simple mode");
+ if (_isOpen)
+ error("MidiDriver_ETUDE::send called but driver was no opened");
if (ScummMidiRequest) {
ULONG midi_data = READ_LE_UINT32(&b);
@@ -174,103 +121,12 @@ void MidiDriver_ETUDE::send(uint32 b)
}
}
-void MidiDriver_ETUDE::midi_callback(ULONG msg, struct IOMidiRequest *req, APTR user_data)
-{
- switch (msg) {
- case ETUDE_STREAM_MSG_BLOCKEND: {
- MidiDriver_ETUDE *md = ((MidiDriver_ETUDE *) user_data);
- if (md && md->_mode)
- md->fill_all();
- break;
- }
- }
-}
-
-void MidiDriver_ETUDE::fill_all()
-{
- if (_stream_proc == NULL) {
- error("MidiDriver_ETUDE::fill_all() called, but _stream_proc == NULL");
- }
-
- uint buf;
- MidiEvent my_evs[64];
-
- for (buf = 0; buf < NUM_BUFFERS; buf++) {
- if (!_req_sent[buf] || CheckIO((IORequest *) _stream_req[buf])) {
- int num = _stream_proc(_stream_param, my_evs, 64);
-
- if (_req_sent[buf]) {
- WaitIO((IORequest *) _stream_req[buf]);
- _req_sent[buf] = false;
- }
-
- /* end of stream? */
- if (num == 0)
- break;
-
- MIDIEVENT *ev = (MIDIEVENT *) _stream_buf[buf];
- MidiEvent *my_ev = my_evs;
-
- for (int i = 0; i < num; i++, my_ev++) {
- ev->me_StreamID = 0;
- ev->me_DeltaTime = my_ev->delta;
-
- switch (my_ev->event >> 24) {
- case 0:
- ev->me_Event = my_ev->event;
- break;
- case ME_TEMPO:
- /* change tempo event */
- ev->me_Event = (MEVT_TEMPO << 24) | (my_ev->event & 0xFFFFFF);
- break;
- default:
- error("Invalid event type passed");
- }
-
- /* increase stream pointer by 12 bytes
- * (need to be 12 bytes, and sizeof(MIDIEVENT) is 16)
- */
- ev = (MIDIEVENT *)((byte *)ev + 12);
- }
-
- ConvertWindowsMidiStream(_stream_buf[buf], num * 12);
-
- _stream_req[buf]->emr_Std.io_Command = CMD_WRITE;
- _stream_req[buf]->emr_Std.io_Data = _stream_buf[buf];
- _stream_req[buf]->emr_Std.io_Length = num * 12;
- SendIO((IORequest *) _stream_req[buf]);
- _req_sent[buf] = true;
- }
- }
-}
-
-void MidiDriver_ETUDE::pause(bool p)
-{
- if (_mode == MO_STREAMING && ScummMidiRequest) {
- if (p)
- PauseMidiStream(ScummMidiRequest);
- else
- RestartMidiStream(ScummMidiRequest);
- }
-}
-
-uint32 MidiDriver_ETUDE::property(int prop, uint32 param)
-{
- switch (prop) {
- /* 16-bit time division according to standard midi specification */
- case PROP_TIMEDIV:
- _time_div = (uint16)param;
- return 1;
- }
-
- return 0;
-}
-
-extern MidiDriver* EtudeMidiDriver;
+extern MidiDriver* EtudeMidiDriver = NULL;
MidiDriver *MidiDriver_ETUDE_create()
{
- EtudeMidiDriver = new MidiDriver_ETUDE();
+ if (!EtudeMidiDriver)
+ EtudeMidiDriver = new MidiDriver_ETUDE();
return EtudeMidiDriver;
}
@@ -280,39 +136,31 @@ MidiDriver *MidiDriver_ETUDE_create()
#define SEQ_MIDIPUTC 5
#define SPECIAL_CHANNEL 9
-class MidiDriver_SEQ:public MidiDriver_MPU401 {
+class MidiDriver_SEQ : public MidiDriver_MPU401 {
public:
MidiDriver_SEQ();
- int open(int mode);
+ int open();
void close();
void send(uint32 b);
- void pause(bool p);
- void set_stream_callback(void *param, StreamCallback *sc);
- // void setPitchBendRange (byte channel, uint range);
private:
- StreamCallback *_stream_proc;
- void *_stream_param;
- int _mode;
+ bool _isOpen;
int device, _device_num;
};
MidiDriver_SEQ::MidiDriver_SEQ()
{
- _mode = 0;
+ _isOpen = false;
device = 0;
_device_num = 0;
}
-int MidiDriver_SEQ::open(int mode)
+int MidiDriver_SEQ::open()
{
- if (_mode != 0)
+ if (_isOpen)
return MERR_ALREADY_OPEN;
+ _isOpen = true;
device = 0;
- if (mode != MO_SIMPLE)
- return MERR_STREAMING_NOT_AVAILABLE;
-
- _mode = mode;
char *device_name = getenv("SCUMMVM_MIDI");
if (device_name != NULL) {
@@ -339,7 +187,7 @@ int MidiDriver_SEQ::open(int mode)
void MidiDriver_SEQ::close()
{
::close(device);
- _mode = 0;
+ _isOpen = false;
}
@@ -385,18 +233,6 @@ void MidiDriver_SEQ::send(uint32 b)
write(device, buf, position);
}
-void MidiDriver_SEQ::pause(bool p)
-{
- if (_mode == MO_STREAMING) {
- }
-}
-
-void MidiDriver_SEQ::set_stream_callback(void *param, StreamCallback *sc)
-{
- _stream_param = param;
- _stream_proc = sc;
-}
-
MidiDriver *MidiDriver_SEQ_create()
{
return new MidiDriver_SEQ();