#else
#include "server_defs.h"
#endif /* HAVE_SYS_SOUNDCARD_H */
-#if !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ <= 95
-#include <stdarg.h>
-#endif
#ifdef WIN32
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
};
static size_t m_fwrite(const void *ptr, size_t size);
-#if defined(__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 95)
-#define CARR(...) ((uint8_t []) {__VA_ARGS__})
-#define M_FWRITE(a, ...) m_fwrite(CARR(__VA_ARGS__), sizeof(CARR(__VA_ARGS__)))
-#else
-void M_FWRITE(int n, ...)
-{
- uint8 a;
- va_list ap;
- va_start(ap, n);
- while(n--){
- a=(uint8)va_arg(ap, int);
- m_fwrite(&a, sizeof(uint8));
- };
- va_end(ap);
-}
-
-#endif
-#define M_FWRITE_STR(s) m_fwrite((s), sizeof(s) - 1)
+#define M_FWRITE(...) do { \
+ uint8_t __arg[] = { __VA_ARGS__ }; \
+ m_fwrite(__arg, sizeof(__arg)); \
+} while (0)
+#define M_FWRITE_STR(s) m_fwrite(s, sizeof(s) - 1)
static size_t m_fwrite(const void *ptr, size_t size)
{
static void set_tempo(void)
{
M_FWRITE_STR("\xff\x51\3");
- M_FWRITE(3, tempo >> 16, tempo >> 8, tempo);
+ M_FWRITE(tempo >> 16, tempo >> 8, tempo);
}
static void set_time_sig(void)
for (idx = 0; idx < 3; idx++) {
if (started_printing || c[idx]) {
started_printing = 1;
- M_FWRITE(1, c[idx] | 0x80);
+ M_FWRITE(c[idx] | 0x80);
}
}
- M_FWRITE(1, c[3]);
+ M_FWRITE(c[3]);
}
static void start_midi_track(void)
static void midout_noteon(int chn, int note, int vel, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(3,(chn & 0x0f) | MIDI_NOTEON, note & 0x7f, vel & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_NOTEON, note & 0x7f, vel & 0x7f);
}
static void midout_noteoff(int chn, int note, int vel, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(3, (chn & 0x0f) | MIDI_NOTEOFF, note & 0x7f, vel & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_NOTEOFF, note & 0x7f, vel & 0x7f);
}
static void midout_control(int chn, int control, int value, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(3, (chn & 0x0f) | MIDI_CTL_CHANGE, control & 0x7f, value & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_CTL_CHANGE, control & 0x7f, value & 0x7f);
}
static void midout_keypressure(int chn, int control, int value, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(3, (chn & 0x0f) | MIDI_KEY_PRESSURE, control & 0x7f, value & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_KEY_PRESSURE, control & 0x7f, value & 0x7f);
}
static void midout_channelpressure(int chn, int vel, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(2, (chn & 0x0f) | MIDI_CHN_PRESSURE, vel & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_CHN_PRESSURE, vel & 0x7f);
}
static void midout_bender(int chn, int pitch, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(3, (chn & 0x0f) | MIDI_PITCH_BEND, pitch & 0x7f, (pitch >> 7) & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_PITCH_BEND, pitch & 0x7f, (pitch >> 7) & 0x7f);
}
static void midout_program(int chn, int pgm, int32 time)
{
midout_write_delta_time(time);
- M_FWRITE(2, (chn & 0x0f) | MIDI_PGM_CHANGE, pgm & 0x7f);
+ M_FWRITE((chn & 0x0f) | MIDI_PGM_CHANGE, pgm & 0x7f);
}
static void midout_tempo(int chn, int a, int b, int32 time)
midout_write_delta_time(time);
M_FWRITE_STR("\xff\x58\4");
}
- M_FWRITE(2, a, b);
+ M_FWRITE(a, b);
}
static int do_event(MidiEvent * ev)