14 #include "../stdafx.h" 21 #include "../safeguards.h" 25 static AUDIOSTREAM *_stream = NULL;
27 static int _buffer_size;
32 if (_stream == NULL)
return;
34 void *data = get_audio_stream_buffer(_stream);
36 if (data == NULL)
return;
39 MxMixSamples(data, _buffer_size);
42 uint16 *snd = (uint16*)data;
43 for (
int i = 0; i < _buffer_size * 2; i++) snd[i] ^= 0x8000;
46 free_audio_stream_buffer(_stream);
53 extern int _allegro_instance_count;
57 if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
58 DEBUG(driver, 0,
"allegro: install_allegro failed '%s'", allegro_error);
59 return "Failed to set up Allegro";
61 _allegro_instance_count++;
64 if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
65 DEBUG(driver, 0,
"allegro: install_sound failed '%s'", allegro_error);
66 return "Failed to set up Allegro sound";
70 if (digi_card == DIGI_NONE) {
71 DEBUG(driver, 0,
"allegro: no sound card found");
72 return "No sound card found";
77 _stream = play_audio_stream(_buffer_size, 16,
true, hz, 255, 128);
84 if (_stream != NULL) {
85 stop_audio_stream(_stream);
90 if (--_allegro_instance_count == 0) allegro_exit();
const char * Start(const char *const *param)
Start this driver.
void Stop()
Stop this driver.
Base fo playing sound via Allegro.
#define DEBUG(name, level,...)
Output a line of debugging information.
Factory for the allegro sound driver.
void MainLoop()
Called once every tick.
int GetDriverParamInt(const char *const *parm, const char *name, int def)
Get an integer parameter the list of parameters.