1 /*
2  * OpenBOR - http://www.LavaLit.com
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
5  *
6  * Copyright (c) 2004 - 2011 OpenBOR Team
7  */
8 
9 #include "kos.h"
10 #include "soundmix.h"
11 
12 static unsigned short buffer[8192];
13 static snd_stream_hnd_t handle = -1;
14 
SB_thread(void * arg)15 int SB_thread(void *arg)
16 {
17 	while(1)
18 	{
19 		snd_stream_poll(handle);
20 		thd_pass();
21 	}
22 	return 0;
23 }
24 
SB_callback(snd_stream_hnd_t hnd,int smp_req,int * smp_recv)25 void *SB_callback(snd_stream_hnd_t hnd, int smp_req, int *smp_recv)
26 {
27 	update_sample((unsigned char*)buffer, smp_req);
28 	*smp_recv = smp_req;
29 	return buffer;
30 }
31 
SB_playstart(int bits,int samplerate)32 int SB_playstart(int bits, int samplerate)
33 {
34 	if(handle == -1)
35 	{
36 		snd_stream_init();
37 		handle = snd_stream_alloc(*SB_callback, 8192);
38 		thd_create(1, (void*)SB_thread, NULL);
39 	}
40 	if(handle == -1) return 0;
41 	snd_stream_start(handle, samplerate, 1);
42 	return 1;
43 }
44 
SB_playstop()45 void SB_playstop()
46 {
47 	if(handle == -1) return;
48 	snd_stream_stop(handle);
49 }
50 
SB_setvolume(char dev,char volume)51 void SB_setvolume(char dev, char volume)
52 {
53 }
54 
SB_updatevolume(int volume)55 void SB_updatevolume(int volume)
56 {
57 }
58