1 | //esdstream.c: |
---|
2 | |
---|
3 | #include "libroaresd.h" |
---|
4 | |
---|
5 | /* open a socket for playing, monitoring, or recording as a stream */ |
---|
6 | /* the *_fallback functions try to open /dev/dsp if there's no EsounD */ |
---|
7 | int esd_play_stream( esd_format_t format, int rate, |
---|
8 | const char *host, const char *name ) { |
---|
9 | int channels; |
---|
10 | int bits; |
---|
11 | |
---|
12 | if ( (format & ESD_BITS8) ) { |
---|
13 | bits = 8; |
---|
14 | } else { |
---|
15 | bits = 16; |
---|
16 | } |
---|
17 | |
---|
18 | if ( (format & ESD_MONO) ) { |
---|
19 | channels = 1; |
---|
20 | } else { |
---|
21 | channels = 2; |
---|
22 | } |
---|
23 | |
---|
24 | return roar_simple_play(rate, channels, bits, ROAR_CODEC_DEFAULT, (char*)host, (char*) name); |
---|
25 | } |
---|
26 | |
---|
27 | int esd_play_stream_fallback( esd_format_t format, int rate, |
---|
28 | const char *host, const char *name ) { |
---|
29 | int r; |
---|
30 | |
---|
31 | if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) { |
---|
32 | return r; |
---|
33 | } |
---|
34 | |
---|
35 | return esd_play_stream(format, rate, "+fork", name); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | int esd_monitor_stream( esd_format_t format, int rate, |
---|
41 | const char *host, const char *name ) { |
---|
42 | int channels; |
---|
43 | int bits; |
---|
44 | |
---|
45 | if ( (format & ESD_BITS8) ) { |
---|
46 | bits = 8; |
---|
47 | } else { |
---|
48 | bits = 16; |
---|
49 | } |
---|
50 | |
---|
51 | if ( (format & ESD_MONO) ) { |
---|
52 | channels = 1; |
---|
53 | } else { |
---|
54 | channels = 2; |
---|
55 | } |
---|
56 | |
---|
57 | return roar_simple_monitor(rate, channels, bits, ROAR_CODEC_DEFAULT, (char*)host, (char*)name); |
---|
58 | } |
---|
59 | /* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */ |
---|
60 | int esd_record_stream( esd_format_t format, int rate, |
---|
61 | const char *host, const char *name ); |
---|
62 | int esd_record_stream_fallback( esd_format_t format, int rate, |
---|
63 | const char *host, const char *name ); |
---|
64 | int esd_filter_stream( esd_format_t format, int rate, |
---|
65 | const char *host, const char *name ) { |
---|
66 | int channels; |
---|
67 | int bits; |
---|
68 | |
---|
69 | if ( (format & ESD_BITS8) ) { |
---|
70 | bits = 8; |
---|
71 | } else { |
---|
72 | bits = 16; |
---|
73 | } |
---|
74 | |
---|
75 | if ( (format & ESD_MONO) ) { |
---|
76 | channels = 1; |
---|
77 | } else { |
---|
78 | channels = 2; |
---|
79 | } |
---|
80 | |
---|
81 | return roar_simple_filter(rate, channels, bits, ROAR_CODEC_DEFAULT, (char*)host, (char*)name); |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | //ll |
---|