Permalink
Browse files

-Codechange: a sprankle of coding style over mpu_ files

  • Loading branch information...
1 parent a6b5991 commit 4d314b6babf8a808c59c3b9fb7479dd55eab5d67 @TrueBrain TrueBrain committed Sep 1, 2011
Showing with 62 additions and 62 deletions.
  1. +1 −1 Makefile.tcc
  2. +1 −1 config.lib
  3. +2 −2 src/audio/dsp_sdl.c
  4. +47 −47 src/audio/mpu_alsa.c
  5. +11 −11 src/audio/mpu_win32.c
View
@@ -63,7 +63,7 @@ endif
ifdef ALSA
LIBS := $(LIBS) -lasound
-CFLAGS := $(CFLAGS) -DMPU_ALSA
+CFLAGS := $(CFLAGS) -DALSA
endif
CFLAGS := $(CFLAGS) -g -Wall
View
@@ -806,7 +806,7 @@ make_cflags_and_ldflags() {
else
LIBS="$LIBS -lasound"
fi
- CFLAGS="$CFLAGS -DMPU_ALSA"
+ CFLAGS="$CFLAGS -DALSA"
fi
if [ "$enable_assert" = "0" ]; then
View
@@ -58,15 +58,15 @@ void DSP_Uninit()
bool DSP_Init()
{
-#if defined(MPU_ALSA)
+#if defined(ALSA)
/* XXX - SDL and opening your own asound port are in heavy conflict,
* causing deadlocks. If we are playing music, the soundcard appear to
* be locked, on which SDL starts to wait when it wants to play voices.
* As we always play music, this never happens, and the game deadlocks.
* This is a 'quick and dirty' solution, by the lack of better
* alternatives. */
return false;
-#endif /* MPU_ALSA */
+#endif /* ALSA */
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) return false;
s_spec.freq = 22050;
View
@@ -10,32 +10,32 @@
#include "mpu.h"
-static snd_seq_t *_midi = NULL;
-static snd_midi_event_t *_midiCoder = NULL;
-static int _midiPort = -1;
-static snd_seq_port_subscribe_t *_midiSubscription = NULL;
+static snd_seq_t *s_midi = NULL;
+static snd_midi_event_t *s_midiCoder = NULL;
+static snd_seq_port_subscribe_t *s_midiSubscription = NULL;
+static int s_midiPort = -1;
-char *s_mpu_caption = "OpenDUNE MIDI Port";
+static char *s_midiCaption = "OpenDUNE MIDI Port";
bool mpu_init() {
snd_seq_addr_t sender, receiver;
snd_seq_port_info_t *pinfo;
snd_seq_client_info_t *cinfo;
bool found = false;
- if (snd_seq_open(&_midi, "default", SND_SEQ_OPEN_OUTPUT, 0) < 0) {
+ if (snd_seq_open(&s_midi, "default", SND_SEQ_OPEN_OUTPUT, 0) < 0) {
fprintf(stderr, "Failed to initialize MPU\n");
- _midi = NULL;
+ s_midi = NULL;
return false;
}
- snd_seq_set_client_name(_midi, s_mpu_caption);
+ snd_seq_set_client_name(s_midi, s_midiCaption);
/* Create a port to work on */
- _midiPort = snd_seq_create_simple_port(_midi, s_mpu_caption, SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
- if (_midiPort < 0) {
+ s_midiPort = snd_seq_create_simple_port(s_midi, s_midiCaption, SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
+ if (s_midiPort < 0) {
fprintf(stderr, "Failed to initialize MPU\n");
- snd_seq_close(_midi);
- _midi = NULL;
+ snd_seq_close(s_midi);
+ s_midi = NULL;
return false;
}
@@ -45,15 +45,15 @@ bool mpu_init() {
snd_seq_client_info_set_client(cinfo, -1);
/* Walk all clients and ports, and see if one matches our demands */
- while (snd_seq_query_next_client(_midi, cinfo) >= 0 && !found) {
+ while (snd_seq_query_next_client(s_midi, cinfo) >= 0 && !found) {
int client;
client = snd_seq_client_info_get_client(cinfo);
if (client == 0) continue;
snd_seq_port_info_set_client(pinfo, client);
snd_seq_port_info_set_port(pinfo, -1);
- while (snd_seq_query_next_port(_midi, pinfo) >= 0) {
+ while (snd_seq_query_next_port(s_midi, pinfo) >= 0) {
if ((snd_seq_port_info_get_capability(pinfo) & (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE)) != (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE)) continue;
/* Most linux installations come with a Midi Through Port.
* This is 'hardware' support that mostly ends up on your serial, which
@@ -67,75 +67,75 @@ bool mpu_init() {
if (!found) {
fprintf(stderr, "No valid MIDI output ports.\n Please install and start Timidity++ like: timidity -iA\n");
- snd_seq_delete_port(_midi, _midiPort);
- snd_seq_close(_midi);
- _midi = NULL;
+ snd_seq_delete_port(s_midi, s_midiPort);
+ snd_seq_close(s_midi);
+ s_midi = NULL;
return false;
}
/* Subscribe ourself to the port */
receiver.client = snd_seq_port_info_get_client(pinfo);
receiver.port = snd_seq_port_info_get_port(pinfo);
- sender.client = snd_seq_client_id(_midi);
- sender.port = _midiPort;
-
- snd_seq_port_subscribe_malloc(&_midiSubscription);
- snd_seq_port_subscribe_set_sender(_midiSubscription, &sender);
- snd_seq_port_subscribe_set_dest(_midiSubscription, &receiver);
- snd_seq_port_subscribe_set_time_update(_midiSubscription, 1);
- snd_seq_port_subscribe_set_time_real(_midiSubscription, 1);
- if (snd_seq_subscribe_port(_midi, _midiSubscription) < 0) {
+ sender.client = snd_seq_client_id(s_midi);
+ sender.port = s_midiPort;
+
+ snd_seq_port_subscribe_malloc(&s_midiSubscription);
+ snd_seq_port_subscribe_set_sender(s_midiSubscription, &sender);
+ snd_seq_port_subscribe_set_dest(s_midiSubscription, &receiver);
+ snd_seq_port_subscribe_set_time_update(s_midiSubscription, 1);
+ snd_seq_port_subscribe_set_time_real(s_midiSubscription, 1);
+ if (snd_seq_subscribe_port(s_midi, s_midiSubscription) < 0) {
fprintf(stderr, "Failed to subscript to MIDI output\n");
- snd_seq_delete_port(_midi, _midiPort);
- snd_seq_close(_midi);
- _midi = NULL;
+ snd_seq_delete_port(s_midi, s_midiPort);
+ snd_seq_close(s_midi);
+ s_midi = NULL;
return false;
}
/* Start the MIDI decoder */
- if (snd_midi_event_new(4, &_midiCoder) < 0) {
+ if (snd_midi_event_new(4, &s_midiCoder) < 0) {
fprintf(stderr, "Failed to initialize MIDI decoder\n");
- snd_seq_delete_port(_midi, _midiPort);
- snd_seq_close(_midi);
- _midi = NULL;
+ snd_seq_delete_port(s_midi, s_midiPort);
+ snd_seq_close(s_midi);
+ s_midi = NULL;
return false;
}
- snd_midi_event_init(_midiCoder);
+ snd_midi_event_init(s_midiCoder);
return true;
}
void mpu_uninit() {
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
- snd_midi_event_free(_midiCoder);
- snd_seq_port_subscribe_free(_midiSubscription);
- snd_seq_delete_port(_midi, _midiPort);
- snd_seq_close(_midi);
+ snd_midi_event_free(s_midiCoder);
+ snd_seq_port_subscribe_free(s_midiSubscription);
+ snd_seq_delete_port(s_midi, s_midiPort);
+ snd_seq_close(s_midi);
- _midi = NULL;
+ s_midi = NULL;
}
void mpu_send(uint32 data)
{
snd_seq_event_t ev;
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
snd_seq_ev_clear(&ev);
- snd_seq_ev_set_source(&ev, _midiPort);
+ snd_seq_ev_set_source(&ev, s_midiPort);
snd_seq_ev_set_subs(&ev);
snd_seq_ev_set_direct(&ev);
- snd_midi_event_encode(_midiCoder, (uint8 *)&data, sizeof(uint32), &ev);
+ snd_midi_event_encode(s_midiCoder, (uint8 *)&data, sizeof(uint32), &ev);
- snd_seq_event_output(_midi, &ev);
- snd_seq_drain_output(_midi);
+ snd_seq_event_output(s_midi, &ev);
+ snd_seq_drain_output(s_midi);
}
void mpu_reset()
{
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
- snd_midi_event_reset_encode(_midiCoder);
+ snd_midi_event_reset_encode(s_midiCoder);
}
View
@@ -8,13 +8,13 @@
#include "types.h"
#include "mpu.h"
-static HMIDIOUT _midi = NULL;
+static HMIDIOUT s_midi = NULL;
bool mpu_init()
{
- if (midiOutOpen(&_midi, 0, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) {
+ if (midiOutOpen(&s_midi, 0, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) {
fprintf(stderr, "Failed to initialize MPU\n");
- _midi = NULL;
+ s_midi = NULL;
return false;
}
@@ -23,24 +23,24 @@ bool mpu_init()
void mpu_uninit()
{
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
- midiOutReset(_midi);
- midiOutClose(_midi);
+ midiOutReset(s_midi);
+ midiOutClose(s_midi);
- _midi = NULL;
+ s_midi = NULL;
}
void mpu_send(uint32 data)
{
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
- midiOutShortMsg(_midi, data);
+ midiOutShortMsg(s_midi, data);
}
void mpu_reset()
{
- if (_midi == NULL) return;
+ if (s_midi == NULL) return;
- midiOutReset(_midi);
+ midiOutReset(s_midi);
}

0 comments on commit 4d314b6

Please sign in to comment.