source: roaraudio/libroaresd/esdstream.c @ 4708:c9d40761088a

Last change on this file since 4708:c9d40761088a was 4708:c9d40761088a, checked in by phi, 13 years ago

updated copyright statements

File size: 4.5 KB
RevLine 
[0]1//esdstream.c:
2
[705]3/*
[4708]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
[705]5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from EsounD.
7 *  They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude)
8 *  <ericmit@ix.netcom.com>. For more information see AUTHORS.esd.
9 *
10 *  This file is part of libroaresd a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
[3517]25 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
[705]27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 *
33 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
34 *  or libpulse*:
35 *  The libs libroaresd, libroararts and libroarpulse link this libroar
36 *  and are therefore GPL. Because of this it may be illigal to use
37 *  them with any software that uses libesd, libartsc or libpulse*.
38 */
39
[0]40#include "libroaresd.h"
41
[628]42#if BYTE_ORDER == BIG_ENDIAN
43#define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_BE
44#elif BYTE_ORDER == LITTLE_ENDIAN
45#define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_LE
46#else
47#define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_PDP
48#endif
49
[0]50/* open a socket for playing, monitoring, or recording as a stream */
51/* the *_fallback functions try to open /dev/dsp if there's no EsounD */
52int esd_play_stream( esd_format_t format, int rate,
53                     const char *host, const char *name ) {
[73]54 int channels;
55 int bits;
[627]56 int codec = ROAR_CODEC_DEFAULT;
[0]57
[631]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_play(rate, channels, bits, codec, (char*)host, (char*) name);
[0]72}
73
74int esd_play_stream_fallback( esd_format_t format, int rate,
75                              const char *host, const char *name ) {
[73]76 int r;
77
78 if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) {
79  return r;
80 }
81
82 return esd_play_stream(format, rate, "+fork", name);
[0]83}
84
85
86
87int esd_monitor_stream( esd_format_t format, int rate,
88                        const char *host, const char *name ) {
[73]89 int channels;
90 int bits;
[627]91 int codec = ROAR_CODEC_DEFAULT;
[0]92
[631]93 ROAR_DBG("esd_monitor_stream(format=%x, rate=%i, host='%s', name='%s') = ?", format, rate, host, name);
94
95 if ( (format & ESD_BITS16) ) {
96  bits  = 16;
97 } else {
[628]98  bits  = 8;
99  codec = CODEC_DEF_8BIT;
[0]100 }
101
102 if ( (format & ESD_MONO) ) {
103  channels = 1;
104 } else {
105  channels = 2;
106 }
107
[627]108 return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name);
[0]109}
110/* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */
111int esd_record_stream( esd_format_t format, int rate,
[3649]112                       const char *host, const char *name ) {
113 int channels;
114 int bits;
115 int codec = ROAR_CODEC_DEFAULT;
116
117 ROAR_DBG("esd_record_stream(format=%x, rate=%i, host='%s', name='%s') = ?", format, rate, host, name);
118
119 if ( (format & ESD_BITS16) ) {
120  bits  = 16;
121 } else {
122  bits  = 8;
123  codec = CODEC_DEF_8BIT;
124 }
125
126 if ( (format & ESD_MONO) ) {
127  channels = 1;
128 } else {
129  channels = 2;
130 }
131
132 return roar_simple_record(rate, channels, bits, codec, (char*)host, (char*)name);
133}
[0]134int esd_record_stream_fallback( esd_format_t format, int rate,
[3649]135                                const char *host, const char *name ) {
136 int r;
137
138 if ( (r = esd_record_stream(format, rate, host, name)) != -1 ) {
139  return r;
140 }
141
142 return esd_record_stream(format, rate, "+fork", name);
143}
[0]144int esd_filter_stream( esd_format_t format, int rate,
145                       const char *host, const char *name ) {
[73]146 int channels;
147 int bits;
[627]148 int codec = ROAR_CODEC_DEFAULT;
[0]149
[631]150 if ( (format & ESD_BITS16) ) {
151  bits  = 16;
152 } else {
[628]153  bits  = 8;
154  codec = CODEC_DEF_8BIT;
[0]155 }
156
157 if ( (format & ESD_MONO) ) {
158  channels = 1;
159 } else {
160  channels = 2;
161 }
162
[627]163 return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name);
[0]164}
165
166
167//ll
Note: See TracBrowser for help on using the repository browser.