source: roaraudio/roard/sources.c @ 66:a75c2005faeb

Last change on this file since 66:a75c2005faeb was 65:65d45c7144e1, checked in by phi, 16 years ago

done some coding to support sources

File size: 1.0 KB
Line 
1//sources.c:
2
3#include "roard.h"
4
5int sources_init (void) {
6 g_source_client = -1;
7 return 0;
8}
9
10int sources_set_client (int client) {
11 if ( client >= 0 ) {
12  g_source_client = client;
13  return 0;
14 } else {
15  return -1;
16 }
17}
18
19int sources_free (void) {
20 return 0;
21}
22
23int sources_add (char * driver, char * device, char * container, char * options, int primary) {
24 if ( strcmp(driver, "raw") == 0 )
25  return sources_add_raw(driver, device, container, options, primary);
26
27 return -1;
28}
29
30int sources_add_raw (char * driver, char * device, char * container, char * options, int primary) {
31 int stream;
32 int fh;
33 struct roar_stream * s;
34
35 if ( (fh = open(device, O_RDONLY, 0644)) == -1 ) {
36  return -1;
37 }
38
39 if ( (stream = streams_new()) == -1 ) {
40  close(fh);
41  return -1;
42 }
43
44 streams_get(stream, (struct roar_stream_server **)&s);
45
46 memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));
47
48 s->dir        = ROAR_DIR_PLAY;
49 s->pos_rel_id = -1;
50
51 streams_set_fh(stream, fh);
52
53 client_stream_add(g_source_client, stream);
54
55 return 0;
56}
57
58//ll
Note: See TracBrowser for help on using the repository browser.