1 #include "osd_win_snd.h"
2 
3 #if defined(ALLEGRO)
4 
osd_snd_set_volume(UChar v)5  void osd_snd_set_volume(UChar v)
6 {
7 	set_volume(v);
8 }
9 
10 #endif // ALLEGRO
11 
12 #if defined(SDL)
13 
14 extern void sdl_fill_audio(void *data, Uint8 *stream, int len);
15 
osd_snd_set_volume(UChar v)16 void osd_snd_set_volume(UChar v)
17 {
18 	#warning implement set volume for sdl
19 }
20 
osd_snd_init_sound(void)21 int osd_snd_init_sound(void)
22 {
23     SDL_AudioSpec wanted, got;
24 
25     if (SDL_InitSubSystem(SDL_INIT_AUDIO))
26     {
27         printf("SDL_InitSubSystem(AUDIO) failed at %s:%d - %s\n", __FILE__, __LINE__, SDL_GetError());
28         return 0;
29     }
30 
31     wanted.freq = option.want_snd_freq;
32     wanted.format = AUDIO_U8;
33     wanted.channels = option.want_stereo + 1;   /* 1 = mono, 2 = stereo */
34     wanted.samples = sbuf_size;  /* Good low-latency value for callback */
35     wanted.callback = sdl_fill_audio;
36     wanted.userdata = main_buf;     /* Open the audio device, forcing the desired format */
37 
38     if ( SDL_OpenAudio(&wanted, &got) < 0 ) {
39         Log("Couldn't open audio: %s\n", SDL_GetError());
40         return(0);
41     }
42 
43     host.sound.stereo = (got.channels == 2);
44     host.sound.sample_size = got.samples;
45     host.sound.freq = got.freq;
46     host.sound.signed_sound = (got.format >= 0x8000);
47 
48     SDL_PauseAudio(SDL_DISABLE);
49 
50     return(1);
51 }
52 
53 
osd_snd_trash_sound(void)54 void osd_snd_trash_sound(void)
55 {
56     UChar chan;
57 
58 	SDL_CloseAudio();
59     SDL_QuitSubSystem(SDL_INIT_AUDIO);
60 
61     for (chan = 0; chan < 6; chan++)
62         memset(sbuf[chan], 0, SBUF_SIZE_BYTE);
63 
64     memset(adpcmbuf, 0, SBUF_SIZE_BYTE);
65 }
66 
67 #endif // SDL
68 
69