source: roaraudio/libroarpulse/libroarpulse.c @ 4559:4660942db9dc

Last change on this file since 4559:4660942db9dc was 3811:49db840fb4f4, checked in by phi, 14 years ago

fixed some copyright statements

File size: 3.7 KB
Line 
1//libroarpulse.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from libpulse*. They are mostly copyrighted by:
7 *  Lennart Poettering <poettering@users.sourceforge.net> and
8 *  Pierre Ossman <drzeus@drzeus.cx>
9 *
10 *  This file is part of libroarpulse 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 <libroarpulse/libroarpulse.h>
41
42int roar_codec_pulse2roar (int codec) {
43 return ROAR_CODEC_DEFAULT;
44}
45
46int roar_pa_sspec2auinfo (struct roar_audio_info * info, const pa_sample_spec * ss) {
47 if ( ss == NULL || info == NULL )
48  return -1;
49
50 info->rate     = ss->rate;
51 info->channels = ss->channels;
52
53 switch (ss->format) {
54  case PA_SAMPLE_U8:
55    info->bits  = 8;
56    info->codec = ROAR_CODEC_PCM_U_LE;
57   break;
58  case PA_SAMPLE_ALAW:
59    info->bits  = 8;
60    info->codec = ROAR_CODEC_ALAW;
61   break;
62  case PA_SAMPLE_ULAW:
63    info->bits  = 8;
64    info->codec = ROAR_CODEC_MULAW;
65   break;
66  case PA_SAMPLE_S16LE:
67    info->bits  = 16;
68    info->codec = ROAR_CODEC_PCM_S_LE;
69   break;
70  case PA_SAMPLE_S16BE:
71    info->bits  = 16;
72    info->codec = ROAR_CODEC_PCM_S_BE;
73   break;
74  // invalid and not supported ones follow:
75  case PA_SAMPLE_INVALID:
76  case PA_SAMPLE_MAX:
77  case PA_SAMPLE_FLOAT32LE:
78  case PA_SAMPLE_FLOAT32BE:
79  default:
80    return -1;
81   break;
82 }
83
84 return 0;
85}
86
87int roar_pa_auinfo2sspec (pa_sample_spec * ss, const struct roar_audio_info * info) {
88 if ( ss == NULL || info == NULL )
89  return -1;
90
91 ss->rate       = info->rate;
92 ss->channels   = info->channels;
93
94 switch (info->codec) {
95  case ROAR_CODEC_ALAW:
96    ss->format = PA_SAMPLE_ALAW;
97   break;
98  case ROAR_CODEC_MULAW:
99    ss->format = PA_SAMPLE_ULAW;
100   break;
101  case ROAR_CODEC_PCM_S_LE:
102    if ( info->bits != 16 )
103     return -1;
104    ss->format = PA_SAMPLE_S16LE;
105   break;
106  case ROAR_CODEC_PCM_S_BE:
107    if ( info->bits != 16 )
108     return -1;
109    ss->format = PA_SAMPLE_S16BE;
110   break;
111  case ROAR_CODEC_PCM_U_LE:
112  case ROAR_CODEC_PCM_U_BE:
113  case ROAR_CODEC_PCM_U_PDP:
114    if ( info->bits != 8 )
115     return -1;
116    ss->format = PA_SAMPLE_U8;
117   break;
118  default:
119    return -1;
120   break;
121 }
122
123 return 0;
124}
125
126char * roar_pa_find_server (char * server) {
127 struct roar_x11_connection * x11con;
128
129 if ( server == NULL )
130  server = getenv("PULSE_SERVER");
131
132 if ( server == NULL ) {
133  if ( (x11con = roar_x11_connect(NULL)) != NULL ) {
134   server = roar_x11_get_prop(x11con, "PULSE_SERVER");
135   roar_x11_disconnect(x11con);
136  }
137 }
138
139 return server;
140}
141
142//ll
Note: See TracBrowser for help on using the repository browser.