3 Quick and Dirty Game Development Framework (QDGDF)
5 Copyright (C) 2001/2005 Angel Ortega <angel@triptico.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 http://www.triptico.com
27 #include "qdgdf_audio.h"
41 /* sound sample ids */
42 #define MAX_SAMPLES 512
44 int _sample_ids
[MAX_SAMPLES
];
50 static int _qdgdfa_load_sound(char *wavfile
)
54 snd
= esd_file_cache(_esd_fd
, "qdgdfa", wavfile
);
57 _sample_ids
[_sample_idx
++] = snd
;
63 static int _qdgdfa_dup_sound(int snd
)
65 /* sounds cannot be duplicated with esound,
66 but seems not necessary as sounds can
67 be directly played many times; so, return
68 the same sample id. Does esound allows
69 a sample to be freed many times without crashing? */
75 static void _qdgdfa_play_sound(int snd
, int loop
)
77 esd_sample_stop(_esd_fd
, snd
);
79 /* Esd is crap. I just can't force it to stop
80 big files played in loops, nor unload them,
81 nor kill them; looped sounds are played
82 forever. So, looped sounds are disabled
85 esd_sample_play(_esd_fd
, snd
);
89 static void _qdgdfa_respawn_sound(int snd
)
91 esd_sample_play(_esd_fd
, snd
);
95 static void _qdgdfa_stop_sound(int snd
)
97 esd_sample_stop(_esd_fd
, snd
);
101 static void _qdgdfa_set_pan(int snd
, int pan
)
103 int left
= 256, right
= 256;
110 esd_set_default_sample_pan(_esd_fd
, snd
, left
, right
);
114 static void _qdgdfa_set_attenuation(int snd
, int att
)
120 static void _qdgdfa_reset(void)
124 for (n
= 0; n
< _sample_idx
; n
++) {
125 qdgdfa_stop_sound(_sample_ids
[n
]);
127 esd_sample_free(_esd_fd
, _sample_ids
[n
]);
136 static void _qdgdfa_pause(int p
)
139 esd_standby(_esd_fd
);
145 static int _qdgdfa_startup(void)
147 _esd_fd
= esd_open_sound(NULL
);
157 static void _qdgdfa_shutdown(void)
165 /* driver information */
167 static struct _qdgdfa_driver drv
= {
173 _qdgdfa_respawn_sound
,
177 _qdgdfa_set_attenuation
,
185 struct _qdgdfa_driver
*esd_drv_detect(void)
186 /* detection function */
188 if (_qdgdfa_startup())
194 #endif /* CONFOPT_ESD */