[Scummvm-cvs-logs] SF.net SVN: scummvm: [29142] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Sep 30 14:12:22 CEST 2007


Revision: 29142
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29142&view=rev
Author:   fingolfin
Date:     2007-09-30 05:12:22 -0700 (Sun, 30 Sep 2007)

Log Message:
-----------
Patch #1804801: DMedia MIDI driver for IRIX

Modified Paths:
--------------
    scummvm/trunk/COPYRIGHT
    scummvm/trunk/backends/module.mk
    scummvm/trunk/configure
    scummvm/trunk/sound/mididrv.cpp
    scummvm/trunk/sound/mididrv.h

Added Paths:
-----------
    scummvm/trunk/backends/midi/dmedia.cpp

Modified: scummvm/trunk/COPYRIGHT
===================================================================
--- scummvm/trunk/COPYRIGHT	2007-09-30 12:01:11 UTC (rev 29141)
+++ scummvm/trunk/COPYRIGHT	2007-09-30 12:12:22 UTC (rev 29142)
@@ -13,7 +13,6 @@
 Ralph Brorsen
 James Brown
 Stuart Caie
-Filippos Karapetis
 Jamieson Christian
 Marcus Comstedt
 Paolo Costabel
@@ -84,7 +83,7 @@
 Elio Blanca "eblanca76"
 David Breakey "dbreakey"
 Robert Buchholz "prendi"
-Filippos Karapetis "thebluegr"
+Rainer Canavan
 Mathieu Carot "yokna"
 Stefano Ceccherini "jackburton"
 Travis S Coady "theealien"
@@ -116,6 +115,7 @@
 Joerg "macdrega"
 Matt Johnson "mattjon"
 Nicolas Joly "njoly"
+Filippos Karapetis "thebluegr"
 KeithS "keithscr"
 Sam Kenny "sam_k"
 Koen Kooi "koenkooi"

Added: scummvm/trunk/backends/midi/dmedia.cpp
===================================================================
--- scummvm/trunk/backends/midi/dmedia.cpp	                        (rev 0)
+++ scummvm/trunk/backends/midi/dmedia.cpp	2007-09-30 12:12:22 UTC (rev 29142)
@@ -0,0 +1,181 @@
+/* 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: dmedia.cpp
+ */
+
+/*
+ * IRIX dmedia support by Rainer Canavan <scumm at canavan.de>
+ *    some code liberated from seq.cpp and coremidi.cpp
+ */
+
+#if defined(IRIX) 
+
+#include "common/stdafx.h"
+#include "sound/mpu401.h"
+#include "common/util.h"
+
+#include <dmedia/midi.h>
+#include <sys/types.h>
+#include <bstring.h>
+#include <unistd.h>
+
+////////////////////////////////////////
+//
+// IRIX dmedia midi driver
+//
+////////////////////////////////////////
+
+#define SEQ_MIDIPUTC 5
+
+class MidiDriver_DMEDIA : public MidiDriver_MPU401 {
+public:
+	MidiDriver_DMEDIA();
+	int open();
+	void close();
+	void send(uint32 b);
+	void sysEx(const byte *msg, uint16 length);
+
+private:
+	bool _isOpen;
+	int _deviceNum;
+	char *_midiportName;
+	MDport _midiPort;
+	int _fd;
+};
+
+MidiDriver_DMEDIA::MidiDriver_DMEDIA() {
+	_isOpen = false;
+	_deviceNum = 0;
+	_midiportName = NULL;
+}
+
+int MidiDriver_DMEDIA::open() {
+	int numinterfaces;
+
+	if (_isOpen)
+		return MERR_ALREADY_OPEN;
+	_isOpen = true;
+
+	warning("dmedia init");
+	numinterfaces = mdInit();
+	if (numinterfaces <= 0) {
+		fprintf(stderr,"No MIDI interfaces configured.\n");
+		perror("Cannot initialize libmd for sound output");
+		return -1;
+	}
+
+	if (getenv("SCUMMVM_MIDIPORT")) {
+		_deviceNum = atoi(getenv("SCUMMVM_MIDIPORT"));
+		_midiportName = mdGetName(_deviceNum);
+	} 
+		else
+	{
+		_midiportName = mdGetName(0);
+		warning("SCUMMVM_MIDIPORT environment variable not set, using Port %s", _midiportName);
+		_deviceNum = 0;
+	}
+
+	_midiPort = mdOpenOutPort(_midiportName);
+	if (!_midiPort) {
+		warning("Failed to open MIDI interface %s", _midiportName);
+		return -1;
+	}
+
+	_fd = mdGetFd(_midiPort);
+	if (!_fd) {
+		warning("Failed to aquire filehandle for MIDI port %s", _midiportName);
+		mdClosePort(_midiPort);
+		return -1;
+	}
+
+	mdSetStampMode(_midiPort, MD_NOSTAMP);  /* don't use Timestamps */
+
+	return 0;
+}
+
+void MidiDriver_DMEDIA::close() {
+	mdClosePort(_midiPort);
+	_isOpen = false;
+	_deviceNum = 0;
+	_midiportName = NULL;
+}
+
+void MidiDriver_DMEDIA::send(uint32 b) {
+	MDevent event;
+	byte status_byte = (b & 0x000000FF);
+	byte first_byte = (b & 0x0000FF00) >> 8;
+	byte second_byte = (b & 0x00FF0000) >> 16;
+
+
+	event.sysexmsg = NULL;
+	event.msg[0] = status_byte;
+	event.msg[1] = first_byte;
+	event.msg[2] = second_byte;
+
+	switch (status_byte & 0xF0) {
+	case 0x80:      // Note Off
+	case 0x90:      // Note On
+	case 0xA0:      // Polyphonic Aftertouch
+	case 0xB0:      // Controller Change
+	case 0xE0:      // Pitch Bending
+		event.msglen = 3;
+		break;
+	case 0xC0:      // Programm Change
+	case 0xD0:      // Monophonic Aftertouch
+		event.msglen = 2;
+		break;
+	default:
+		warning("DMediaMIDI driver encountered unsupported status byte: 0x%02x", status_byte);
+		event.msglen = 3;
+		break;
+	}
+	if (mdSend(_midiPort, &event, 1) != 1) {
+		warning("failed sending MIDI event (dump follows...)");
+		warning("MIDI Event (len=%u):", event.msglen);
+		for (int i=0; i<event.msglen; i++) warning("%02x ",(int)event.msg[i]);
+	}
+}
+
+void MidiDriver_DMEDIA::sysEx (const byte *msg, uint16 length) {
+	MDevent event;
+	char buf [1024];
+
+	assert(length + 2 <= 256);
+
+	memcpy(buf, msg, length);
+	buf[length] = MD_EOX;
+	event.sysexmsg = buf;
+        event.msglen = length;
+	event.msg[0] = MD_SYSEX;
+	event.msg[1] = 0;
+	event.msg[2] = 0;
+
+	if (mdSend(_midiPort, &event, 1) != 1) {
+		fprintf(stderr,"failed sending MIDI SYSEX event (dump follows...)\n");
+	}
+}
+
+MidiDriver *MidiDriver_DMEDIA_create() {
+	return new MidiDriver_DMEDIA();
+}
+
+#endif


Property changes on: scummvm/trunk/backends/midi/dmedia.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/backends/module.mk
===================================================================
--- scummvm/trunk/backends/module.mk	2007-09-30 12:01:11 UTC (rev 29141)
+++ scummvm/trunk/backends/module.mk	2007-09-30 12:12:22 UTC (rev 29142)
@@ -9,6 +9,7 @@
 	midi/morphos.o \
 	midi/quicktime.o \
 	midi/seq.o \
+	midi/dmedia.o \
 	midi/windows.o \
 	plugins/dc/dc-provider.o \
 	plugins/posix/posix-provider.o \

Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure	2007-09-30 12:01:11 UTC (rev 29141)
+++ scummvm/trunk/configure	2007-09-30 12:12:22 UTC (rev 29142)
@@ -833,7 +833,8 @@
 			DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
 			;;
 		irix*)
-			DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+			DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
+			LIBS="$LIBS -lmd "
 			_ranlib=:
 			;;
 		darwin*)

Modified: scummvm/trunk/sound/mididrv.cpp
===================================================================
--- scummvm/trunk/sound/mididrv.cpp	2007-09-30 12:01:11 UTC (rev 29141)
+++ scummvm/trunk/sound/mididrv.cpp	2007-09-30 12:12:22 UTC (rev 29142)
@@ -48,6 +48,7 @@
 
 #if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__)
 	{"seq", "SEQ", MD_SEQ, MDT_MIDI},
+	{"dmedia", "DMedia", MD_DMEDIA, MDT_MIDI},
 #endif
 
 #if defined(MACOSX)
@@ -247,6 +248,9 @@
 #if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__)
 	case MD_SEQ:       return MidiDriver_SEQ_create();
 #endif
+#if defined(IRIX)
+	case MD_DMEDIA:    return MidiDriver_DMEDIA_create();
+#endif
 #if defined(MACOSX)
 	case MD_QTMUSIC:   return MidiDriver_QT_create();
 	case MD_COREAUDIO: return MidiDriver_CORE_create();

Modified: scummvm/trunk/sound/mididrv.h
===================================================================
--- scummvm/trunk/sound/mididrv.h	2007-09-30 12:01:11 UTC (rev 29141)
+++ scummvm/trunk/sound/mididrv.h	2007-09-30 12:12:22 UTC (rev 29142)
@@ -67,6 +67,9 @@
 	// MorphOS
 	MD_ETUDE,
 
+	// IRIX
+	MD_DMEDIA,
+
 	// MIDI softsynths
 	MD_FLUIDSYNTH,
 	MD_MT32,
@@ -273,6 +276,7 @@
 extern MidiDriver *MidiDriver_CoreMIDI_create();
 extern MidiDriver *MidiDriver_ETUDE_create();
 extern MidiDriver *MidiDriver_ALSA_create();
+extern MidiDriver *MidiDriver_DMEDIA_create();
 extern MidiDriver *MidiDriver_YM2612_create(Audio::Mixer *mixer);
 #ifdef USE_FLUIDSYNTH
 extern MidiDriver *MidiDriver_FluidSynth_create(Audio::Mixer *mixer);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list