[0] | 1 | //esdstream.c: |
---|
| 2 | |
---|
| 3 | #include "libroaresd.h" |
---|
| 4 | |
---|
[628] | 5 | #if BYTE_ORDER == BIG_ENDIAN |
---|
| 6 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_BE |
---|
| 7 | #elif BYTE_ORDER == LITTLE_ENDIAN |
---|
| 8 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_LE |
---|
| 9 | #else |
---|
| 10 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_PDP |
---|
| 11 | #endif |
---|
| 12 | |
---|
[0] | 13 | /* open a socket for playing, monitoring, or recording as a stream */ |
---|
| 14 | /* the *_fallback functions try to open /dev/dsp if there's no EsounD */ |
---|
| 15 | int esd_play_stream( esd_format_t format, int rate, |
---|
| 16 | const char *host, const char *name ) { |
---|
[73] | 17 | int channels; |
---|
| 18 | int bits; |
---|
[627] | 19 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 20 | |
---|
[631] | 21 | if ( (format & ESD_BITS16) ) { |
---|
| 22 | bits = 16; |
---|
| 23 | } else { |
---|
[628] | 24 | bits = 8; |
---|
| 25 | codec = CODEC_DEF_8BIT; |
---|
[0] | 26 | } |
---|
| 27 | |
---|
| 28 | if ( (format & ESD_MONO) ) { |
---|
| 29 | channels = 1; |
---|
| 30 | } else { |
---|
| 31 | channels = 2; |
---|
| 32 | } |
---|
| 33 | |
---|
[627] | 34 | return roar_simple_play(rate, channels, bits, codec, (char*)host, (char*) name); |
---|
[0] | 35 | } |
---|
| 36 | |
---|
| 37 | int esd_play_stream_fallback( esd_format_t format, int rate, |
---|
| 38 | const char *host, const char *name ) { |
---|
[73] | 39 | int r; |
---|
| 40 | |
---|
| 41 | if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) { |
---|
| 42 | return r; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | return esd_play_stream(format, rate, "+fork", name); |
---|
[0] | 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | int esd_monitor_stream( esd_format_t format, int rate, |
---|
| 51 | const char *host, const char *name ) { |
---|
[73] | 52 | int channels; |
---|
| 53 | int bits; |
---|
[627] | 54 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 55 | |
---|
[631] | 56 | ROAR_DBG("esd_monitor_stream(format=%x, rate=%i, host='%s', name='%s') = ?", format, rate, host, name); |
---|
| 57 | |
---|
| 58 | if ( (format & ESD_BITS16) ) { |
---|
| 59 | bits = 16; |
---|
| 60 | } else { |
---|
[628] | 61 | bits = 8; |
---|
| 62 | codec = CODEC_DEF_8BIT; |
---|
[0] | 63 | } |
---|
| 64 | |
---|
| 65 | if ( (format & ESD_MONO) ) { |
---|
| 66 | channels = 1; |
---|
| 67 | } else { |
---|
| 68 | channels = 2; |
---|
| 69 | } |
---|
| 70 | |
---|
[627] | 71 | return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 72 | } |
---|
| 73 | /* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */ |
---|
| 74 | int esd_record_stream( esd_format_t format, int rate, |
---|
| 75 | const char *host, const char *name ); |
---|
| 76 | int esd_record_stream_fallback( esd_format_t format, int rate, |
---|
| 77 | const char *host, const char *name ); |
---|
| 78 | int esd_filter_stream( esd_format_t format, int rate, |
---|
| 79 | const char *host, const char *name ) { |
---|
[73] | 80 | int channels; |
---|
| 81 | int bits; |
---|
[627] | 82 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 83 | |
---|
[631] | 84 | if ( (format & ESD_BITS16) ) { |
---|
| 85 | bits = 16; |
---|
| 86 | } else { |
---|
[628] | 87 | bits = 8; |
---|
| 88 | codec = CODEC_DEF_8BIT; |
---|
[0] | 89 | } |
---|
| 90 | |
---|
| 91 | if ( (format & ESD_MONO) ) { |
---|
| 92 | channels = 1; |
---|
| 93 | } else { |
---|
| 94 | channels = 2; |
---|
| 95 | } |
---|
| 96 | |
---|
[627] | 97 | return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | //ll |
---|