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