[0] | 1 | //esdstream.c: |
---|
| 2 | |
---|
[705] | 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 |
---|
| 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 26 | * |
---|
| 27 | * NOTE for everyone want's to change something and send patches: |
---|
| 28 | * read README and HACKING! There a addition information on |
---|
| 29 | * the license of this document you need to read before you send |
---|
| 30 | * any patches. |
---|
| 31 | * |
---|
| 32 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 33 | * or libpulse*: |
---|
| 34 | * The libs libroaresd, libroararts and libroarpulse link this libroar |
---|
| 35 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 36 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 37 | */ |
---|
| 38 | |
---|
[0] | 39 | #include "libroaresd.h" |
---|
| 40 | |
---|
[628] | 41 | #if BYTE_ORDER == BIG_ENDIAN |
---|
| 42 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_BE |
---|
| 43 | #elif BYTE_ORDER == LITTLE_ENDIAN |
---|
| 44 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_LE |
---|
| 45 | #else |
---|
| 46 | #define CODEC_DEF_8BIT ROAR_CODEC_PCM_U_PDP |
---|
| 47 | #endif |
---|
| 48 | |
---|
[0] | 49 | /* open a socket for playing, monitoring, or recording as a stream */ |
---|
| 50 | /* the *_fallback functions try to open /dev/dsp if there's no EsounD */ |
---|
| 51 | int esd_play_stream( esd_format_t format, int rate, |
---|
| 52 | const char *host, const char *name ) { |
---|
[73] | 53 | int channels; |
---|
| 54 | int bits; |
---|
[627] | 55 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 56 | |
---|
[631] | 57 | if ( (format & ESD_BITS16) ) { |
---|
| 58 | bits = 16; |
---|
| 59 | } else { |
---|
[628] | 60 | bits = 8; |
---|
| 61 | codec = CODEC_DEF_8BIT; |
---|
[0] | 62 | } |
---|
| 63 | |
---|
| 64 | if ( (format & ESD_MONO) ) { |
---|
| 65 | channels = 1; |
---|
| 66 | } else { |
---|
| 67 | channels = 2; |
---|
| 68 | } |
---|
| 69 | |
---|
[627] | 70 | return roar_simple_play(rate, channels, bits, codec, (char*)host, (char*) name); |
---|
[0] | 71 | } |
---|
| 72 | |
---|
| 73 | int esd_play_stream_fallback( esd_format_t format, int rate, |
---|
| 74 | const char *host, const char *name ) { |
---|
[73] | 75 | int r; |
---|
| 76 | |
---|
| 77 | if ( (r = esd_play_stream(format, rate, host, name)) != -1 ) { |
---|
| 78 | return r; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | return esd_play_stream(format, rate, "+fork", name); |
---|
[0] | 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | int esd_monitor_stream( esd_format_t format, int rate, |
---|
| 87 | const char *host, const char *name ) { |
---|
[73] | 88 | int channels; |
---|
| 89 | int bits; |
---|
[627] | 90 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 91 | |
---|
[631] | 92 | ROAR_DBG("esd_monitor_stream(format=%x, rate=%i, host='%s', name='%s') = ?", format, rate, host, name); |
---|
| 93 | |
---|
| 94 | if ( (format & ESD_BITS16) ) { |
---|
| 95 | bits = 16; |
---|
| 96 | } else { |
---|
[628] | 97 | bits = 8; |
---|
| 98 | codec = CODEC_DEF_8BIT; |
---|
[0] | 99 | } |
---|
| 100 | |
---|
| 101 | if ( (format & ESD_MONO) ) { |
---|
| 102 | channels = 1; |
---|
| 103 | } else { |
---|
| 104 | channels = 2; |
---|
| 105 | } |
---|
| 106 | |
---|
[627] | 107 | return roar_simple_monitor(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 108 | } |
---|
| 109 | /* int esd_monitor_stream_fallback( esd_format_t format, int rate ); */ |
---|
| 110 | int esd_record_stream( esd_format_t format, int rate, |
---|
| 111 | const char *host, const char *name ); |
---|
| 112 | int esd_record_stream_fallback( esd_format_t format, int rate, |
---|
| 113 | const char *host, const char *name ); |
---|
| 114 | int esd_filter_stream( esd_format_t format, int rate, |
---|
| 115 | const char *host, const char *name ) { |
---|
[73] | 116 | int channels; |
---|
| 117 | int bits; |
---|
[627] | 118 | int codec = ROAR_CODEC_DEFAULT; |
---|
[0] | 119 | |
---|
[631] | 120 | if ( (format & ESD_BITS16) ) { |
---|
| 121 | bits = 16; |
---|
| 122 | } else { |
---|
[628] | 123 | bits = 8; |
---|
| 124 | codec = CODEC_DEF_8BIT; |
---|
[0] | 125 | } |
---|
| 126 | |
---|
| 127 | if ( (format & ESD_MONO) ) { |
---|
| 128 | channels = 1; |
---|
| 129 | } else { |
---|
| 130 | channels = 2; |
---|
| 131 | } |
---|
| 132 | |
---|
[627] | 133 | return roar_simple_filter(rate, channels, bits, codec, (char*)host, (char*)name); |
---|
[0] | 134 | } |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | //ll |
---|