source: roaraudio/libroaresd/esdstream.c @ 628:a5bf996c115d

Last change on this file since 628:a5bf996c115d was 628:a5bf996c115d, checked in by phi, 16 years ago

use diffrent (unsigned) codec for 8 bit

File size: 2.2 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_BITS8) ) {
22  bits  = 8;
23  codec = CODEC_DEF_8BIT;
24 } else {
25  bits = 16;
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 if ( (format & ESD_BITS8) ) {
57  bits  = 8;
58  codec = CODEC_DEF_8BIT;
59 } else {
60  bits = 16;
61 }
62
63 if ( (format & ESD_MONO) ) {
64  channels = 1;
65 } else {
66  channels = 2;
67 }
68
69 return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name);
70}
71/* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */
72int esd_record_stream( esd_format_t format, int rate,
73                       const char *host, const char *name );
74int esd_record_stream_fallback( esd_format_t format, int rate,
75                                const char *host, const char *name );
76int esd_filter_stream( esd_format_t format, int rate,
77                       const char *host, const char *name ) {
78 int channels;
79 int bits;
80 int codec = ROAR_CODEC_DEFAULT;
81
82 if ( (format & ESD_BITS8) ) {
83  bits  = 8;
84  codec = CODEC_DEF_8BIT;
85 } else {
86  bits = 16;
87 }
88
89 if ( (format & ESD_MONO) ) {
90  channels = 1;
91 } else {
92  channels = 2;
93 }
94
95 return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name);
96}
97
98
99//ll
Note: See TracBrowser for help on using the repository browser.