1 diff -ur allegro-4.0.2/acconfig.h allegro-4.0.2.new/acconfig.h
2 --- allegro-4.0.2/acconfig.h Sun Jun 16 21:22:15 2002
3 +++ allegro-4.0.2.new/acconfig.h Fri Jun 21 12:53:40 2002
5 /* Define if ALSA MIDI driver is supported. */
6 #undef ALLEGRO_WITH_ALSAMIDI
8 +/* Define if ALSA9 DIGI driver is supported. */
9 +#undef ALLEGRO_WITH_ALSA9DIGI
11 +/* Define if ALSA9 MIDI driver is supported. */
12 +#undef ALLEGRO_WITH_ALSA9MIDI
14 /* Define if ESD DIGI driver is supported. */
15 #undef ALLEGRO_WITH_ESDDIGI
17 diff -ur allegro-4.0.2/aclocal.m4 allegro-4.0.2.new/aclocal.m4
18 --- allegro-4.0.2/aclocal.m4 Sun Jun 16 21:22:15 2002
19 +++ allegro-4.0.2.new/aclocal.m4 Fri Jun 21 14:23:44 2002
24 +dnl Test for ALSA9 DIGI driver.
27 +dnl allegro_enable_alsa9digi=(yes|)
28 +dnl allegro_cv_support_alsa9digi=(yes|)
30 +AC_DEFUN(ALLEGRO_ACTEST_ALSA9DIGI,
31 +[AC_ARG_ENABLE(alsa9digi,
32 +[ --enable-alsa9digi[=x] enable building ALSA9 DIGI driver [default=yes]],
33 +test "X$enableval" != "Xno" && allegro_enable_alsa9digi=yes,
34 +allegro_enable_alsa9digi=yes)
36 +if test -n "$allegro_enable_alsa9digi"; then
37 + AC_CACHE_CHECK(for supported ALSA9 version for digital sound,
38 + allegro_cv_support_alsa9digi,
39 + AC_TRY_RUN([#include <alsa/asoundlib.h>
40 + int main (void) { return SND_LIB_MAJOR != 0 || SND_LIB_MINOR != 9; }],
41 + allegro_cv_support_alsa9digi=yes,
42 + allegro_cv_support_alsa9digi=no,
43 + allegro_cv_support_alsa9digi=no))
44 + if test "X$allegro_cv_support_alsa9digi" = "Xyes" &&
45 + test -z "$allegro_support_modules"; then
46 + LIBS="-lasound $LIBS"
51 +dnl Test for ALSA9 MIDI driver.
54 +dnl allegro_enable_alsa9midi=(yes|)
55 +dnl allegro_support_alsa9midi=(yes|)
57 +AC_DEFUN(ALLEGRO_ACTEST_ALSA9MIDI,
58 +[AC_ARG_ENABLE(alsa9midi,
59 +[ --enable-alsa9midi[=x] enable building ALSA9 MIDI driver [default=yes]],
60 +test "X$enableval" != "Xno" && allegro_enable_alsa9midi=yes,
61 +allegro_enable_alsa9midi=yes)
63 +if test -n "$allegro_enable_alsa9midi"; then
64 + AC_CACHE_CHECK(for supported ALSA9 version for MIDI,
65 + allegro_cv_support_alsa9midi,
66 + AC_TRY_RUN([#include <alsa/asoundlib.h>
67 + int main (void) { return SND_LIB_MAJOR != 0 || SND_LIB_MINOR != 9; }],
68 + allegro_cv_support_alsa9midi=yes,
69 + allegro_cv_support_alsa9midi=no,
70 + allegro_cv_support_alsa9midi=no))
71 + if test "X$allegro_cv_support_alsa9midi" = "Xyes" &&
72 + test -z "$allegro_support_modules"; then
73 + LIBS="-lasound $LIBS"
78 dnl Test for ESD DIGI driver.
81 diff -ur allegro-4.0.2/allegro.mft allegro-4.0.2.new/allegro.mft
82 --- allegro-4.0.2/allegro.mft Sun Jun 16 21:49:13 2002
83 +++ allegro-4.0.2.new/allegro.mft Fri Jun 21 12:48:18 2002
86 allegro/src/unix/alsa.c
87 allegro/src/unix/alsamidi.c
88 +allegro/src/unix/alsa9.c
89 +allegro/src/unix/alsa9midi.c
90 allegro/src/unix/udjgpp.c
91 allegro/src/unix/udrvlist.c
92 allegro/src/unix/uesd.c
93 diff -ur allegro-4.0.2/configure.in allegro-4.0.2.new/configure.in
94 --- allegro-4.0.2/configure.in Sun Jun 16 21:22:15 2002
95 +++ allegro-4.0.2.new/configure.in Fri Jun 21 12:39:47 2002
97 AC_DEFINE(ALLEGRO_WITH_ALSAMIDI)
100 +dnl Test for ALSA9 drivers.
101 +ALLEGRO_ACTEST_ALSA9DIGI
102 +if test "$allegro_cv_support_alsa9digi" = yes; then
103 + AC_DEFINE(ALLEGRO_WITH_ALSA9DIGI)
106 +ALLEGRO_ACTEST_ALSA9MIDI
107 +if test "$allegro_cv_support_alsa9midi" = yes; then
108 + AC_DEFINE(ALLEGRO_WITH_ALSA9MIDI)
111 dnl Test for ESD drivers.
112 ALLEGRO_ACTEST_ESDDIGI
113 if test -n "$allegro_support_esddigi"; then
115 ALLEGRO_MODULE_TARGETS="$ALLEGRO_MODULE_TARGETS lib/unix/alleg-alsamidi.so"
119 + if test "X$allegro_cv_support_alsa9digi" = "Xyes"; then
120 + ALLEGRO_MODULE_TARGETS="$ALLEGRO_MODULE_TARGETS lib/unix/alleg-alsa9digi.so"
124 + if test "X$allegro_cv_support_alsa9midi" = "Xyes"; then
125 + ALLEGRO_MODULE_TARGETS="$ALLEGRO_MODULE_TARGETS lib/unix/alleg-alsa9midi.so"
129 if test "X$allegro_support_esddigi" = "Xyes"; then
130 ALLEGRO_MODULE_TARGETS="$ALLEGRO_MODULE_TARGETS lib/unix/alleg-esddigi.so"
131 diff -ur allegro-4.0.2/makefile.in allegro-4.0.2.new/makefile.in
132 --- allegro-4.0.2/makefile.in Fri Jun 21 14:39:28 2002
133 +++ allegro-4.0.2.new/makefile.in Fri Jun 21 14:31:28 2002
135 $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh fbcon -- $(ALLEGRO_MODULE_FBCON_FILES)' >>makefile.dep
136 $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsadigi -lasound $(ALLEGRO_MODULE_ALSADIGI_FILES)' >>makefile.dep
137 $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsamidi -lasound $(ALLEGRO_MODULE_ALSAMIDI_FILES)' >>makefile.dep
138 + $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsa9digi -lasound $(ALLEGRO_MODULE_ALSA9DIGI_FILES)' >>makefile.dep
139 + $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsa9midi -lasound $(ALLEGRO_MODULE_ALSA9MIDI_FILES)' >>makefile.dep
140 $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh esddigi "\`esd-config --libs\`" $(ALLEGRO_MODULE_ESD_FILES)' >>makefile.dep
141 $(SHELL) -c 'cd $(srcdir) && misc/depmod.sh dga2 -lXxf86dga $(ALLEGRO_MODULE_DGA2_FILES)' >> makefile.dep
142 @echo "Generating dependencies for simple programs"
143 diff -ur allegro-4.0.2/makefile.lst allegro-4.0.2.new/makefile.lst
144 --- allegro-4.0.2/makefile.lst Sun Jun 16 21:43:10 2002
145 +++ allegro-4.0.2.new/makefile.lst Fri Jun 21 12:46:00 2002
147 ALLEGRO_SRC_UNIX_FILES = \
149 src/unix/alsamidi.c \
151 + src/unix/alsa9midi.c \
153 src/unix/udrvlist.c \
156 ALLEGRO_MODULE_ALSAMIDI_FILES = \
159 +ALLEGRO_MODULE_ALSA9DIGI_FILES = \
162 +ALLEGRO_MODULE_ALSA9MIDI_FILES = \
163 + src/unix/alsa9midi.c
165 ALLEGRO_MODULE_ESD_FILES = \
168 diff -ur allegro-4.0.2/modules.lst allegro-4.0.2.new/modules.lst
169 --- allegro-4.0.2/modules.lst Sun Jun 16 21:22:15 2002
170 +++ allegro-4.0.2.new/modules.lst Fri Jun 21 12:47:13 2002
177 diff -uNr allegro-4.0.2/src/unix/alsa9.c allegro-4.0.2.new/src/unix/alsa9.c
178 --- allegro-4.0.2/src/unix/alsa9.c Thu Jan 1 01:00:00 1970
179 +++ allegro-4.0.2.new/src/unix/alsa9.c Fri Jun 21 14:35:09 2002
182 + * /\ _ \ /\_ \ /\_ \
183 + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
184 + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
185 + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
186 + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
187 + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
191 + * ALSA sound driver.
193 + * By Peter Wang (based heavily on uoss.c)
195 + * See readme.txt for copyright information.
199 +#include "allegro.h"
201 +#if (defined DIGI_ALSA) && ((!defined ALLEGRO_WITH_MODULES) || (defined ALLEGRO_MODULE))
203 +#include "allegro/internal/aintern.h"
205 +#include "allegro/platform/aintqnx.h"
207 +#include "allegro/platform/aintunix.h"
211 + #include <string.h>
212 + #include <sys/asoundlib.h>
216 +#ifndef SND_PCM_SFMT_S16_NE
217 + #ifdef ALLEGRO_BIG_ENDIAN
218 + #define SND_PCM_SFMT_S16_NE SND_PCM_SFMT_S16_BE
220 + #define SND_PCM_SFMT_S16_NE SND_PCM_SFMT_S16_LE
223 +#ifndef SND_PCM_SFMT_U16_NE
224 + #ifdef ALLEGRO_BIG_ENDIAN
225 + #define SND_PCM_SFMT_U16_NE SND_PCM_SFMT_U16_BE
227 + #define SND_PCM_SFMT_U16_NE SND_PCM_SFMT_U16_LE
232 +#define ALSA_DEFAULT_NUMFRAGS 16
235 +static snd_pcm_t *pcm_handle;
236 +static int alsa_bufsize;
237 +static unsigned char *alsa_bufdata;
238 +static int alsa_bits, alsa_signed, alsa_rate, alsa_stereo;
239 +static int alsa_fragments;
241 +static char alsa_desc[256] = EMPTY_STRING;
245 +static int alsa_detect(int input);
246 +static int alsa_init(int input, int voices);
247 +static void alsa_exit(int input);
248 +static int alsa_mixer_volume(int volume);
249 +static int alsa_buffer_size(void);
253 +DIGI_DRIVER digi_alsa =
273 + _mixer_release_voice,
274 + _mixer_start_voice,
278 + _mixer_get_position,
279 + _mixer_set_position,
283 + _mixer_ramp_volume,
284 + _mixer_stop_volume_ramp,
286 + _mixer_get_frequency,
287 + _mixer_set_frequency,
288 + _mixer_sweep_frequency,
289 + _mixer_stop_frequency_sweep,
294 + _mixer_stop_pan_sweep,
297 + _mixer_set_tremolo,
298 + _mixer_set_vibrato,
310 +/* alsa_buffer_size:
311 + * Returns the current DMA buffer size, for use by the audiostream code.
313 +static int alsa_buffer_size()
315 + return alsa_bufsize * alsa_fragments / (alsa_bits / 8) / (alsa_stereo ? 2 : 1);
323 +static void alsa_update(int threaded)
327 + for (i = 0; i < alsa_fragments; i++) {
328 + if (snd_pcm_write(pcm_handle, alsa_bufdata, alsa_bufsize) != alsa_bufsize)
330 + _mix_some_samples((unsigned long) alsa_bufdata, 0, alsa_signed);
337 + * Detect driver presence.
339 +static int alsa_detect(int input)
342 + snd_pcm_info_t info;
344 + char tmp1[128], tmp2[128];
347 + card = get_config_int(uconvert_ascii("sound", tmp1),
348 + uconvert_ascii("alsa_card", tmp2),
349 + snd_defaults_card());
351 + device = get_config_int(uconvert_ascii("sound", tmp1),
352 + uconvert_ascii("alsa_pcmdevice", tmp2),
353 + snd_defaults_pcm_device());
355 + if (snd_pcm_open(&handle, card, device, (SND_PCM_OPEN_PLAYBACK
356 + | SND_PCM_OPEN_NONBLOCK)) == 0) {
357 + if ((snd_pcm_info(handle, &info) == 0)
358 + && (info.flags & SND_PCM_INFO_PLAYBACK))
361 + snd_pcm_close(handle);
370 + * ALSA init routine.
372 +static int alsa_init(int input, int voices)
375 + int format, bps, fragsize, numfrags;
376 + snd_pcm_channel_params_t params;
377 + snd_pcm_channel_setup_t setup;
378 + char tmp1[128], tmp2[128];
381 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Input is not supported"));
386 + card = get_config_int(uconvert_ascii("sound", tmp1),
387 + uconvert_ascii("alsadigi_card", tmp2),
388 + snd_defaults_card());
390 + device = get_config_int(uconvert_ascii("sound", tmp1),
391 + uconvert_ascii("alsadigi_pcmdevice", tmp2),
392 + snd_defaults_pcm_device());
394 + fragsize = get_config_int(uconvert_ascii("sound", tmp1),
395 + uconvert_ascii("alsa_fragsize", tmp2),
398 + numfrags = get_config_int(uconvert_ascii("sound", tmp1),
399 + uconvert_ascii("alsa_numfrags", tmp2),
400 + ALSA_DEFAULT_NUMFRAGS);
402 + /* Open PCM device. */
403 + if (snd_pcm_open(&pcm_handle, card, device, (SND_PCM_OPEN_PLAYBACK
404 + | SND_PCM_OPEN_NONBLOCK)) < 0) {
405 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not open card/pcm device"));
409 + /* Set format variables. */
410 + alsa_bits = (_sound_bits == 8) ? 8 : 16;
411 + alsa_stereo = (_sound_stereo) ? 1 : 0;
412 + alsa_rate = (_sound_freq > 0) ? _sound_freq : 44100;
414 + format = ((alsa_bits == 16) ? SND_PCM_SFMT_S16_NE : SND_PCM_SFMT_U8);
417 + bps = alsa_rate * (alsa_stereo ? 2 : 1);
419 + case SND_PCM_SFMT_S8:
421 + case SND_PCM_SFMT_U8:
424 + case SND_PCM_SFMT_S16_NE:
426 + case SND_PCM_SFMT_U16_NE:
429 + if (sizeof(short) != 2) {
430 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Unsupported sample format"));
435 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Unsupported sample format"));
439 + if (fragsize < 0) {
444 + while ((fragsize << 1) < bps)
448 + fragsize = fragsize * (alsa_bits / 8) * (alsa_stereo ? 2 : 1);
451 + /* Set PCM channel format. */
452 + memset(¶ms, 0, sizeof(params));
453 + params.mode = SND_PCM_MODE_BLOCK;
454 + params.channel = SND_PCM_CHANNEL_PLAYBACK;
455 + params.start_mode = SND_PCM_START_FULL;
456 + params.stop_mode = SND_PCM_STOP_ROLLOVER;
457 + params.format.interleave = 1;
458 + params.format.format = format;
459 + params.format.rate = alsa_rate;
460 + params.format.voices = alsa_stereo + 1;
461 + params.buf.block.frag_size = fragsize;
462 + params.buf.block.frags_min = 1;
463 + params.buf.block.frags_max = numfrags;
465 + if (snd_pcm_channel_params(pcm_handle, ¶ms) < 0) {
466 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not set channel parameters"));
470 + snd_pcm_channel_prepare(pcm_handle, SND_PCM_CHANNEL_PLAYBACK);
472 + /* Read back fragments information. */
473 + memset(&setup, 0, sizeof(setup));
474 + setup.mode = SND_PCM_MODE_BLOCK;
475 + setup.channel = SND_PCM_CHANNEL_PLAYBACK;
477 + if (snd_pcm_channel_setup(pcm_handle, &setup) < 0) {
478 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not get channel setup"));
482 + alsa_fragments = numfrags;
483 + alsa_bufsize = setup.buf.block.frag_size;
485 + /* Allocate mixing buffer. */
486 + alsa_bufdata = malloc(alsa_bufsize);
487 + if (!alsa_bufdata) {
488 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not allocate audio buffer"));
492 + /* Initialise mixer. */
493 + digi_alsa.voices = voices;
495 + if (_mixer_init(alsa_bufsize / (alsa_bits / 8), alsa_rate,
496 + alsa_stereo, ((alsa_bits == 16) ? 1 : 0),
497 + &digi_alsa.voices) != 0) {
498 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not init software mixer"));
502 + _mix_some_samples((unsigned long) alsa_bufdata, 0, alsa_signed);
504 + /* Add audio interrupt. */
505 + _unix_bg_man->register_func(alsa_update);
507 + uszprintf(alsa_desc, sizeof(alsa_desc),
508 + get_config_text("Card #%d, device #%d: %d bits, %s, %d bps, %s"),
509 + card, device, alsa_bits,
510 + uconvert_ascii((alsa_signed ? "signed" : "unsigned"), tmp1),
512 + uconvert_ascii((alsa_stereo ? "stereo" : "mono"), tmp2));
514 + digi_driver->desc = alsa_desc;
521 + snd_pcm_close(pcm_handle);
531 + * Shutdown ALSA driver.
533 +static void alsa_exit(int input)
539 + _unix_bg_man->unregister_func(alsa_update);
541 + free(alsa_bufdata);
542 + alsa_bufdata = NULL;
546 + snd_pcm_close(pcm_handle);
551 +/* alsa_mixer_volume:
552 + * Set mixer volume (0-255)
554 +static int alsa_mixer_volume(int volume)
558 + snd_mixer_t *handle;
561 + if (snd_mixer_open(&handle, card, device) == 0) {
562 + /* do something special */
563 + snd_mixer_close(handle);
575 +#ifdef ALLEGRO_MODULE
578 + * Called when loaded as a dynamically linked module.
580 +void _module_init(int system_driver)
582 + _unix_register_digi_driver(DIGI_ALSA, &digi_alsa, TRUE, TRUE);
589 diff -uNr allegro-4.0.2/src/unix/alsa9midi.c allegro-4.0.2.new/src/unix/alsa9midi.c
590 --- allegro-4.0.2/src/unix/alsa9midi.c Thu Jan 1 01:00:00 1970
591 +++ allegro-4.0.2.new/src/unix/alsa9midi.c Sun Jun 16 21:22:31 2002
594 + * /\ _ \ /\_ \ /\_ \
595 + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
596 + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
597 + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
598 + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
599 + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
603 + * ALSA RawMIDI Sound driver.
605 + * By Tom Fjellstrom.
607 + * See readme.txt for copyright information.
610 +#include "allegro.h"
612 +#if (defined MIDI_ALSA) && ((!defined ALLEGRO_WITH_MODULES) || (defined ALLEGRO_MODULE))
614 +#include "allegro/internal/aintern.h"
616 +#include "allegro/platform/aintqnx.h"
618 +#include "allegro/platform/aintunix.h"
622 + #include <stdlib.h>
624 + #include <string.h>
626 + #include <sys/asoundlib.h>
629 +/* external interface to the ALSA rawmidi driver */
630 +static int alsa_rawmidi_detect(int input);
631 +static int alsa_rawmidi_init(int input, int voices);
632 +static void alsa_rawmidi_exit(int input);
633 +static void alsa_rawmidi_output(int data);
635 +static char alsa_rawmidi_desc[256];
637 +static snd_rawmidi_t *rawmidi_handle = NULL;
639 +MIDI_DRIVER midi_alsa =
641 + MIDI_ALSA, /* id */
642 + empty_string, /* name */
643 + empty_string, /* desc */
644 + "ALSA RawMIDI", /* ASCII name */
645 + 0, 0, 0xFFFF, 0, -1, -1, /* voices, basevoice, max_voices, def_voices, xmin, xmax */
646 + alsa_rawmidi_detect, /* detect */
647 + alsa_rawmidi_init, /* init */
648 + alsa_rawmidi_exit, /* exit */
649 + NULL, /* mixer_volume */
650 + alsa_rawmidi_output, /* raw_midi */
651 + _dummy_load_patches, /* load_patches */
652 + _dummy_adjust_patches, /* adjust_patches */
653 + _dummy_key_on, /* key_on */
654 + _dummy_noop1, /* key_off */
655 + _dummy_noop2, /* set_volume */
656 + _dummy_noop3, /* set_pitch */
657 + _dummy_noop2, /* set_pan */
658 + _dummy_noop2 /* set_vibrato */
661 +/* alsa_rawmidi_detect:
662 + * ALSA RawMIDI detection.
664 +static int alsa_rawmidi_detect(int input)
668 + int ret = FALSE, err;
669 + char tmp1[128], tmp2[128], temp[256];
670 + snd_rawmidi_t *handle = NULL;
673 + /* Input not supported.
674 + card = get_config_int(uconvert_ascii("sound", tmp1),
675 + uconvert_ascii("alsa_rawmidi_input_card", tmp2),
676 + snd_defaults_rawmidi_card());
678 + device = get_config_int(uconvert_ascii("sound", tmp1),
679 + uconvert_ascii("alsa_rawmidi_input_device", tmp2),
680 + snd_defaults_rawmidi_device());
682 + if ((err = snd_rawmidi_open(&handle, card, device, SND_RAWMIDI_OPEN_INPUT)) < 0) {
683 + snprintf(temp, sizeof(temp), "Could not open card/rawmidi device: %s", snd_strerror(err));
684 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(temp));
688 + snd_rawmidi_close(handle);
695 + card = get_config_int(uconvert_ascii("sound", tmp1),
696 + uconvert_ascii("alsa_rawmidi_card", tmp2),
697 + snd_defaults_rawmidi_card());
699 + device = get_config_int(uconvert_ascii("sound", tmp1),
700 + uconvert_ascii("alsa_rawmidi_device", tmp2),
701 + snd_defaults_rawmidi_device());
703 + if ((err = snd_rawmidi_open(&handle, card, device, SND_RAWMIDI_OPEN_OUTPUT_APPEND)) < 0) {
704 + snprintf(temp, sizeof(temp), "Could not open card/rawmidi device: %s", snd_strerror(err));
705 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(temp));
709 + snd_rawmidi_close(handle);
717 +/* alsa_rawmidi_init:
718 + * Setup the ALSA RawMIDI interface.
720 +static int alsa_rawmidi_init(int input, int voices)
725 + char tmp1[128], tmp2[128], temp[256];
726 + snd_rawmidi_info_t info;
729 + /* Input not supported
730 + card = get_config_int(uconvert_ascii("sound", tmp1),
731 + uconvert_ascii("alsa_rawmidi_input_card", tmp2),
732 + snd_defaults_rawmidi_card());
734 + device = get_config_int(uconvert_ascii("sound", tmp1),
735 + uconvert_ascii("alsa_rawmidi_input_device", tmp2),
736 + snd_defaults_rawmidi_device());
738 + if ((err = snd_rawmidi_open(&rawmidi_handle, card, device, SND_RAWMIDI_OPEN_INPUT)) < 0) {
739 + snprintf(temp, sizeof(temp), "Could not open card/rawmidi device: %s", snd_strerror(err));
740 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(temp));
749 + card = get_config_int(uconvert_ascii("sound", tmp1),
750 + uconvert_ascii("alsa_rawmidi_card", tmp2),
751 + snd_defaults_rawmidi_card());
753 + device = get_config_int(uconvert_ascii("sound", tmp1),
754 + uconvert_ascii("alsa_rawmidi_device", tmp2),
755 + snd_defaults_rawmidi_device());
757 + if ((err = snd_rawmidi_open(&rawmidi_handle, card, device, SND_RAWMIDI_OPEN_OUTPUT_APPEND)) < 0) {
758 + snprintf(temp, sizeof(temp), "Could not open card/rawmidi device: %s", snd_strerror(err));
759 + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(temp));
766 + if(rawmidi_handle) {
767 + snd_rawmidi_block_mode(rawmidi_handle, 1);
768 + snd_rawmidi_info(rawmidi_handle, &info);
770 + strcpy(alsa_rawmidi_desc, info.name);
771 + midi_alsa.desc = alsa_rawmidi_desc;
773 + LOCK_VARIABLE(alsa_rawmidi_desc);
774 + LOCK_VARIABLE(rawmidi_handle);
775 + LOCK_VARIABLE(midi_alsa);
776 + LOCK_FUNCTION(alsa_rawmidi_output);
782 +/* alsa_rawmidi_exit:
785 +static void alsa_rawmidi_exit(int input)
787 + if(rawmidi_handle) {
788 + snd_rawmidi_output_drain(rawmidi_handle);
789 + snd_rawmidi_close(rawmidi_handle);
792 + rawmidi_handle = NULL;
795 +/* alsa_rawmidi_output:
796 + * Outputs MIDI data.
798 +static void alsa_rawmidi_output(int data)
802 + err = snd_rawmidi_write(rawmidi_handle, &data, sizeof(char));
805 +END_OF_STATIC_FUNCTION(alsa_rawmidi_output);
807 +/* alsa_rawmidi_input:
810 +static INLINE int alsa_rawmidi_input(void)
814 + if(snd_rawmidi_read(rawmidi_handle, &data, sizeof(char)) > 0)
821 +#ifdef ALLEGRO_MODULE
824 + * Called when loaded as a dynamically linked module.
826 +void _module_init(int system_driver)
828 + _unix_register_midi_driver(MIDI_ALSA, &midi_alsa, TRUE, TRUE);
831 +#endif /* ALLEGRO_MODULE */
833 +#endif /* MIDI_ALSA */