aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx/device
diff options
context:
space:
mode:
authorMax Horn2009-05-26 14:09:07 +0000
committerMax Horn2009-05-26 14:09:07 +0000
commit7050c5065f875ef3a41312671ad4020444d7db87 (patch)
tree53bb1cbf838a2fd2ed296a18766d60fc934333c8 /engines/sci/sfx/device
parent1d00cc5df09dd5fcacd3ea007b45ab33e6332e77 (diff)
downloadscummvm-rg350-7050c5065f875ef3a41312671ad4020444d7db87.tar.gz
scummvm-rg350-7050c5065f875ef3a41312671ad4020444d7db87.tar.bz2
scummvm-rg350-7050c5065f875ef3a41312671ad4020444d7db87.zip
SCI: removed realtime and polled player, as well as the sfx/device dir, after discussion with Walter
svn-id: r40913
Diffstat (limited to 'engines/sci/sfx/device')
-rw-r--r--engines/sci/sfx/device/alsa-midi.cpp213
-rw-r--r--engines/sci/sfx/device/camd-midi.cpp150
-rw-r--r--engines/sci/sfx/device/devices.cpp78
-rw-r--r--engines/sci/sfx/device/unixraw-midi.cpp90
4 files changed, 0 insertions, 531 deletions
diff --git a/engines/sci/sfx/device/alsa-midi.cpp b/engines/sci/sfx/device/alsa-midi.cpp
deleted file mode 100644
index 0041e4a3c8..0000000000
--- a/engines/sci/sfx/device/alsa-midi.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include <sfx_engine.h>
-#include "../device.h"
-#ifdef HAVE_ALSA
-
-#include <alsa/asoundlib.h>
-
-namespace Sci {
-
-#define SCI_ALSA_MIDI_VERSION "0.1"
-
-static snd_midi_event_t *parser = NULL;
-static snd_seq_t *seq = NULL;
-static int queue = -1;
-static int delta = 0;
-static int port_out = -1;
-static int port_nr = 128;
-static int subport_nr = 0;
-
-static const char *seq_name = "default";
-
-static void _set_tempo(void) {
- int resolution = 60;
- int tempo = 1;
- snd_seq_queue_tempo_t *queue_tempo;
-
- snd_seq_queue_tempo_malloc(&queue_tempo);
-
- memset(queue_tempo, 0, snd_seq_queue_tempo_sizeof());
- snd_seq_queue_tempo_set_ppq(queue_tempo, resolution);
- snd_seq_queue_tempo_set_tempo(queue_tempo, 1000000 / tempo);
-
- snd_seq_set_queue_tempo(seq, queue, queue_tempo);
-
- snd_seq_queue_tempo_free(queue_tempo);
-
-#if 0
- int tempo = 1000000 / 60;
- snd_seq_queue_tempo_t *queue_tempo;
-
- snd_seq_queue_tempo_malloc(&queue_tempo);
- snd_seq_queue_tempo_set_tempo(queue_tempo, tempo);
- snd_seq_queue_tempo_set_ppq(queue_tempo, 1);
- snd_seq_set_queue_tempo(seq, queue, queue_tempo);
- snd_seq_queue_tempo_free(queue_tempo);
-#endif
-}
-
-
-static Common::Error am_subscribe_to_ports(void) {
- if ((port_out = snd_seq_connect_to(seq, port_out, port_nr, subport_nr)) < 0) {
- fprintf(stderr, "[SFX] Could not connect to ALSA sequencer port: %s\n", snd_strerror(port_out));
- return Common::kUnknownError;
- }
- return Common::kNoError;
-}
-
-
-static Common::Error aminit(midi_writer_t *self) {
- int err;
-
- snd_midi_event_new(4096, &parser);
- snd_midi_event_init(parser);
-
- sciprintf("[SFX] Initialising ALSA MIDI backend, v%s\n", SCI_ALSA_MIDI_VERSION);
-
- if (snd_seq_open(&seq, seq_name, SND_SEQ_OPEN_OUTPUT, SND_SEQ_NONBLOCK)) {
- fprintf(stderr, "[SFX] Failed to open ALSA MIDI sequencer '%s' for output\n",
- seq_name);
- return Common::kUnknownError;
- }
-
- if ((port_out = snd_seq_create_simple_port(seq, "FreeSCI",
- SND_SEQ_PORT_CAP_WRITE |
- SND_SEQ_PORT_CAP_SUBS_WRITE |
- SND_SEQ_PORT_CAP_READ,
- SND_SEQ_PORT_TYPE_MIDI_GENERIC)) < 0) {
- fprintf(stderr, "[SFX] Could not create ALSA sequencer port\n");
- return Common::kUnknownError;
- }
-
- if (am_subscribe_to_ports())
- return Common::kUnknownError;
-
- queue = snd_seq_alloc_queue(seq);
- _set_tempo();
-
- snd_seq_start_queue(seq, queue, NULL);
-
- if ((err = snd_seq_drain_output(seq))) {
- fflush(NULL);
- fprintf(stderr, "[SFX] Error while draining: %s\n",
- snd_strerror(err));
- return Common::kUnknownError;
- }
-
- return Common::kNoError;
-}
-
-static Common::Error amsetopt(midi_writer_t *self, char *name, char *value) {
- return Common::kUnknownError;
-}
-
-
-static Common::Error amwrite(midi_writer_t *self, unsigned char *buf, int len) {
- snd_seq_event_t evt;
-
-#if 0
- {
- int i;
- fprintf(stderr, "[MID] ");
- for (i = 0; i < len; i++)
- fprintf(stderr, " %02x", buf[i]);
- fprintf(stderr, "\n");
- }
-#endif
-
- snd_seq_ev_clear(&evt);
- snd_seq_ev_set_source(&evt, port_out);
- snd_seq_ev_set_subs(&evt); /* Broadcast to all subscribers */
-
- snd_midi_event_encode(parser, buf, len, &evt);
- snd_seq_ev_schedule_tick(&evt, queue, 0, delta);
-
- snd_seq_event_output_direct(seq, &evt);
-
-#if 0
- {
- snd_seq_queue_status_t *status;
- snd_seq_queue_status_malloc(&status);
-
- snd_seq_get_queue_status(seq, queue, status);
- //snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
- fprintf(stderr, "Queue at %d/%d\n", delta, snd_seq_queue_status_get_tick_time(status));
-
- snd_seq_queue_status_free(status);
- }
-#endif
-
-
- return Common::kNoError;
-}
-
-static void amdelay(midi_writer_t *self, int ticks) {
- delta += ticks;
-}
-
-static void amreset_timer(midi_writer_t *self) {
- snd_seq_drain_output(seq);
- snd_seq_stop_queue(seq, queue, NULL);
-
-
- {
- snd_seq_event_t evt;
- snd_seq_ev_clear(&evt);
- snd_seq_ev_set_source(&evt, port_out);
- snd_seq_ev_set_subs(&evt); /* Broadcast to all subscribers */
-
- snd_seq_ev_set_queue_pos_tick(&evt, queue, 0);
-
- snd_seq_event_output_direct(seq, &evt);
- }
- delta = 0;
-
-
-
- snd_seq_start_queue(seq, queue, NULL);
-}
-
-static void amclose(midi_writer_t *self) {
- snd_midi_event_free(parser);
- parser = NULL;
-}
-
-
-midi_writer_t sfx_device_midi_alsa = {
- "alsa",
- aminit,
- amsetopt,
- amwrite,
- amdelay,
- NULL,
- amreset_timer,
- amclose,
-};
-
-} // End of namespace Sci
-
-#endif
diff --git a/engines/sci/sfx/device/camd-midi.cpp b/engines/sci/sfx/device/camd-midi.cpp
deleted file mode 100644
index 26e3db6520..0000000000
--- a/engines/sci/sfx/device/camd-midi.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#ifdef HAVE_PROTO_CAMD_H
-
-#include "sfx_engine.h"
-#include "../device.h"
-
-#include <proto/camd.h>
-#include <proto/dos.h>
-#include <proto/exec.h>
-#include <proto/intuition.h>
-#include <stdio.h>
-
-namespace Sci {
-
-#define SWAP_BYTES
-#define FILL_BYTES
-
-#define SCI_CAMD_MIDI_VERSION "0.1"
-#define SYSEX_PREFIX 0xf0
-
-static const char *devicename = "via686.out.0";
-
-struct Library *CamdBase = NULL;
-struct CamdIFace *ICamd = NULL;
-static struct MidiLink *midi_link = NULL;
-static struct MidiNode *midi_node = NULL;
-
-#define ABORT(m) { \
- if (CamdBase) \
- IExec->CloseLibrary(CamdBase); \
- sciprintf("[SFX] CAMD driver: "); \
- sciprintf(m); \
- sciprintf("\n"); \
- return Common::kUnknownError; \
- }
-
-static Common::Error camd_init(midi_writer_t *self) {
- sciprintf("[SFX] Initialising CAMD raw MIDI backend, v%s\n", SCI_CAMD_MIDI_VERSION);
-
- CamdBase = IExec->OpenLibrary("camd.library", 36L);
- if (!CamdBase)
- ABORT("Could not open 'camd.library'");
-
- ICamd = (struct CamdIFace *) IExec->GetInterface(CamdBase, "main", 1, NULL);
- if (!ICamd)
- ABORT("Error while retrieving CAMD interface\n");
-
- midi_node = ICamd->CreateMidi(MIDI_MsgQueue, 0L, MIDI_SysExSize, 4096L, MIDI_Name, "freesci", TAG_END);
- if (!midi_node)
- ABORT("Could not create CAMD MIDI node");
-
- midi_link = ICamd->AddMidiLink(midi_node, MLTYPE_Sender, MLINK_Location, devicename, TAG_END);
- if (!midi_link)
- ABORT(("Could not create CAMD MIDI link to '%s'", devicename));
-
- sciprintf("[SFX] CAMD initialisation completed\n");
-
- return Common::kNoError;
-}
-
-static Common::Error camd_set_option(midi_writer_t *self, char *name, char *value) {
- return Common::kUnknownError;
-}
-
-#define MAX_MIDI_LEN 3
-
-static Common::Error camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
- if (len == 0)
- return Common::kNoError;
-
- if (buffer[0] == SYSEX_PREFIX) {
- /* Must send this as a SysEx */
- ICamd->PutSysEx(midi_link, buffer);
- } else {
- ULONG data = 0l;
- int i;
- int readlen = (len > MAX_MIDI_LEN) ? MAX_MIDI_LEN : len;
-
- for (i = 0; i < readlen; i++)
- if (len >= i) {
- data <<= 8;
- data |= buffer[i];
- }
- data <<= (8 * (sizeof(ULONG) - readlen));
-
- if (len > MAX_MIDI_LEN)
- sciprintf("[SFX] Warning: Truncated MIDI message to fit CAMD format (sent %d: %02x %02x %02x, real length %d)\n",
- MAX_MIDI_LEN, buffer[0], buffer[1], buffer[2], len);
-
- ICamd->PutMidi(midi_link, data);
- }
-
- return Common::kNoError;
-}
-
-static void camd_delay(midi_writer_t *self, int ticks) {
-}
-
-static void camd_reset_timer(midi_writer_t *self) {
-}
-
-static void camd_close(midi_writer_t *self) {
-#ifdef NO_OP
- return;
-#endif
- if (CamdBase)
- IExec->CloseLibrary(CamdBase);
-}
-
-midi_writer_t sfx_device_midi_camd = {
- "camd-midi",
- &camd_init,
- &camd_set_option,
- &camd_write,
- &camd_delay,
- NULL,
- &camd_reset_timer,
- &camd_close
-};
-
-} // End of namespace Sci
-
-#endif /* HAVE_PROTO_CAMD_H */
diff --git a/engines/sci/sfx/device/devices.cpp b/engines/sci/sfx/device/devices.cpp
deleted file mode 100644
index c4a9f4808f..0000000000
--- a/engines/sci/sfx/device/devices.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/scummsys.h"
-#include "sci/sfx/device.h"
-
-#include "sci/tools.h"
-
-namespace Sci {
-
-static struct _midi_device *devices_midi[] = {
- NULL
-};
-
-static struct _midi_device *devices_opl2[] = {
- NULL
-};
-
-
-/** -- **/
-
-struct _midi_device **devices[] = {
- NULL, /* No device */
- devices_midi,
- devices_opl2,
-};
-
-void *sfx_find_device(int type, char *name) {
- struct _midi_device *dev = NULL;
- int i = 0;
-
- if (!type)
- return NULL;
-
- if (!name) {
- dev = devices[type][0];
- } else {
- while (devices[type][i] && !strcmp(name, devices[type][i]->name))
- ++i;
-
- dev = devices[type][i];
- }
-
- if (dev) {
- if (dev->init(dev)) {
- fprintf(stderr, "[SFX] Opening device '%s' failed\n", dev->name);
- return NULL;
- }
-
- return dev;
- };
-
- return NULL;
-}
-
-} // End of namespace Sci
diff --git a/engines/sci/sfx/device/unixraw-midi.cpp b/engines/sci/sfx/device/unixraw-midi.cpp
deleted file mode 100644
index bc9e8b7427..0000000000
--- a/engines/sci/sfx/device/unixraw-midi.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include <sfx_engine.h>
-#include "../device.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-namespace Sci {
-
-#define SCI_UNIXRAW_MIDI_VERSION "0.1"
-
-#ifndef O_SYNC
-# define O_SYNC 0
-#endif
-
-static int fd;
-static const char *devicename = "/dev/midi";
-
-static Common::Error unixraw_init(midi_writer_t *self) {
- sciprintf("[SFX] Initialising UNIX raw MIDI backend, v%s\n", SCI_UNIXRAW_MIDI_VERSION);
-
- fd = open(devicename, O_WRONLY | O_SYNC);
-
- if (!IS_VALID_FD(fd)) {
- sciprintf("[SFX] Failed to open %s\n", devicename);
- return Common::kUnknownError;
- }
-
- return Common::kNoError;
-}
-
-static Common::Error unixraw_set_option(midi_writer_t *self, char *name, char *value) {
- return Common::kUnknownError;
-}
-
-static Common::Error unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
- if (write(fd, buffer, len) != len) {
- sciprintf("[SFX] MIDI write error\n");
- return Common::kUnknownError;
- }
- return Common::kNoError;
-}
-
-static void unixraw_delay(midi_writer_t *self, int ticks) {
-}
-
-static void unixraw_reset_timer(midi_writer_t *self) {
-}
-
-static void unixraw_close(midi_writer_t *self) {
- close(fd);
-}
-
-midi_writer_t sfx_device_midi_unixraw = {
- "unixraw-midi",
- &unixraw_init,
- &unixraw_set_option,
- &unixraw_write,
- &unixraw_delay,
- NULL,
- &unixraw_reset_timer,
- &unixraw_close
-};
-
-} // End of namespace Sci