source: roaraudio/libroaresd/esdstream.c @ 5226:3cb3cab29e5e

Last change on this file since 5226:3cb3cab29e5e was 5226:3cb3cab29e5e, checked in by phi, 12 years ago

Removed roarcat2sock as well as roar_simple_stream(), roar_simple_new_stream(), roar_simple_play(), roar_simple_monitor(), roar_simple_record(), roar_simple_filter(), roar_simple_close() and roar_simple_get_standby().

File size: 3.8 KB
Line 
1//esdstream.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
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
25 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
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
40#include "libroaresd.h"
41
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
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 */
52
53static int libroaresd_stream(esd_format_t format, int rate, const char *host, const char *name, int dir) {
54 int channels;
55 int bits;
56 int codec = ROAR_CODEC_DEFAULT;
57 struct roar_stream     s;
58
59 if ( (format & ESD_BITS16) ) {
60  bits  = 16;
61 } else {
62  bits  = 8;
63  codec = CODEC_DEF_8BIT;
64 }
65
66 if ( (format & ESD_MONO) ) {
67  channels = 1;
68 } else {
69  channels = 2;
70 }
71
72 return roar_simple_stream_obj(&s, rate, channels, bits, codec, (char*)host, dir, (char*)name);
73}
74
75int esd_play_stream( esd_format_t format, int rate,
76                     const char *host, const char *name ) {
77 return libroaresd_stream(format, rate, host, name, ROAR_DIR_PLAY);
78}
79
80int esd_play_stream_fallback( esd_format_t format, int rate,
81                              const char *host, const char *name ) {
82 int r;
83
84 if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) {
85  return r;
86 }
87
88 return esd_play_stream(format, rate, "+fork", name);
89}
90
91
92
93int esd_monitor_stream( esd_format_t format, int rate,
94                        const char *host, const char *name ) {
95 return libroaresd_stream(format, rate, host, name, ROAR_DIR_MONITOR);
96}
97/* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */
98int esd_record_stream( esd_format_t format, int rate,
99                       const char *host, const char *name ) {
100 return libroaresd_stream(format, rate, host, name, ROAR_DIR_RECORD);
101}
102int esd_record_stream_fallback( esd_format_t format, int rate,
103                                const char *host, const char *name ) {
104 int r;
105
106 if ( (r = esd_record_stream(format, rate, host, name)) != -1 ) {
107  return r;
108 }
109
110 return esd_record_stream(format, rate, "+fork", name);
111}
112int esd_filter_stream( esd_format_t format, int rate,
113                       const char *host, const char *name ) {
114 return libroaresd_stream(format, rate, host, name, ROAR_DIR_FILTER);
115}
116
117
118//ll
Note: See TracBrowser for help on using the repository browser.