[0] | 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 ) { |
---|
[73] | 9 | int channels; |
---|
| 10 | int bits; |
---|
[627] | 11 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 12 | |
---|
| 13 | if ( (format & ESD_BITS8) ) { |
---|
| 14 | bits = 8; |
---|
| 15 | } else { |
---|
| 16 | bits = 16; |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | if ( (format & ESD_MONO) ) { |
---|
| 20 | channels = 1; |
---|
| 21 | } else { |
---|
| 22 | channels = 2; |
---|
| 23 | } |
---|
| 24 | |
---|
[627] | 25 | return roar_simple_play(rate, channels, bits, codec, (char*)host, (char*) name); |
---|
[0] | 26 | } |
---|
| 27 | |
---|
| 28 | int esd_play_stream_fallback( esd_format_t format, int rate, |
---|
| 29 | const char *host, const char *name ) { |
---|
[73] | 30 | int r; |
---|
| 31 | |
---|
| 32 | if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) { |
---|
| 33 | return r; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | return esd_play_stream(format, rate, "+fork", name); |
---|
[0] | 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | int esd_monitor_stream( esd_format_t format, int rate, |
---|
| 42 | const char *host, const char *name ) { |
---|
[73] | 43 | int channels; |
---|
| 44 | int bits; |
---|
[627] | 45 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 46 | |
---|
| 47 | if ( (format & ESD_BITS8) ) { |
---|
| 48 | bits = 8; |
---|
| 49 | } else { |
---|
| 50 | bits = 16; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | if ( (format & ESD_MONO) ) { |
---|
| 54 | channels = 1; |
---|
| 55 | } else { |
---|
| 56 | channels = 2; |
---|
| 57 | } |
---|
| 58 | |
---|
[627] | 59 | return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 60 | } |
---|
| 61 | /* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */ |
---|
| 62 | int esd_record_stream( esd_format_t format, int rate, |
---|
| 63 | const char *host, const char *name ); |
---|
| 64 | int esd_record_stream_fallback( esd_format_t format, int rate, |
---|
| 65 | const char *host, const char *name ); |
---|
| 66 | int esd_filter_stream( esd_format_t format, int rate, |
---|
| 67 | const char *host, const char *name ) { |
---|
[73] | 68 | int channels; |
---|
| 69 | int bits; |
---|
[627] | 70 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 71 | |
---|
| 72 | if ( (format & ESD_BITS8) ) { |
---|
| 73 | bits = 8; |
---|
| 74 | } else { |
---|
| 75 | bits = 16; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | if ( (format & ESD_MONO) ) { |
---|
| 79 | channels = 1; |
---|
| 80 | } else { |
---|
| 81 | channels = 2; |
---|
| 82 | } |
---|
| 83 | |
---|
[627] | 84 | return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 85 | } |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | //ll |
---|