source: roaraudio/libroaresd/esdstream.c @ 632:468ce09813a2

Last change on this file since 632:468ce09813a2 was 631:105d41577f20, checked in by phi, 16 years ago

don't test for ESD_BITS8 as it is zero :), test for ESD_BITS16

File size: 2.4 KB
Line 
1//esdstream.c:
2
3#include "libroaresd.h"
4
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
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 */
15int esd_play_stream( esd_format_t format, int rate,
16                     const char *host, const char *name ) {
17 int channels;
18 int bits;
19 int codec = ROAR_CODEC_DEFAULT;
20
21 if ( (format & ESD_BITS16) ) {
22  bits  = 16;
23 } else {
24  bits  = 8;
25  codec = CODEC_DEF_8BIT;
26 }
27
28 if ( (format & ESD_MONO) ) {
29  channels = 1;
30 } else {
31  channels = 2;
32 }
33
34 return roar_simple_play(rate, channels, bits, codec, (char*)host, (char*) name);
35}
36
37int esd_play_stream_fallback( esd_format_t format, int rate,
38                              const char *host, const char *name ) {
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);
46}
47
48
49
50int esd_monitor_stream( esd_format_t format, int rate,
51                        const char *host, const char *name ) {
52 int channels;
53 int bits;
54 int codec = ROAR_CODEC_DEFAULT;
55
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 {
61  bits  = 8;
62  codec = CODEC_DEF_8BIT;
63 }
64
65 if ( (format & ESD_MONO) ) {
66  channels = 1;
67 } else {
68  channels = 2;
69 }
70
71 return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name);
72}
73/* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */
74int esd_record_stream( esd_format_t format, int rate,
75                       const char *host, const char *name );
76int esd_record_stream_fallback( esd_format_t format, int rate,
77                                const char *host, const char *name );
78int esd_filter_stream( esd_format_t format, int rate,
79                       const char *host, const char *name ) {
80 int channels;
81 int bits;
82 int codec = ROAR_CODEC_DEFAULT;
83
84 if ( (format & ESD_BITS16) ) {
85  bits  = 16;
86 } else {
87  bits  = 8;
88  codec = CODEC_DEF_8BIT;
89 }
90
91 if ( (format & ESD_MONO) ) {
92  channels = 1;
93 } else {
94  channels = 2;
95 }
96
97 return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name);
98}
99
100
101//ll
Note: See TracBrowser for help on using the repository browser.