source: roaraudio/roard/driver_pulsesimple.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: 3.3 KB
Line 
1//driver_pulsesimple.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
5 *
6 *  This file is part of roard a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "roard.h"
27
28#ifdef ROAR_HAVE_LIBPULSE
29
30int     driver_pulsesimple_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
31 struct driver_pulsesimple * self;
32 pa_stream_direction_t dir = PA_STREAM_PLAYBACK;
33 pa_sample_spec        ss;
34
35//    pa_sample_format_t format;     /**< The sample format */
36
37 switch (info->codec) {
38  case ROAR_CODEC_ALAW:
39    ss.format = PA_SAMPLE_ALAW;
40   break;
41  case ROAR_CODEC_MULAW:
42    ss.format = PA_SAMPLE_ULAW;
43   break;
44  case ROAR_CODEC_PCM_S_LE:
45    switch (info->bits) {
46     case 16:
47       ss.format = PA_SAMPLE_S16LE;
48      break;
49     default:
50       return -1;
51      break;
52    }
53   break;
54  case ROAR_CODEC_PCM_S_BE:
55    switch (info->bits) {
56     case 16:
57       ss.format = PA_SAMPLE_S16BE;
58      break;
59     default:
60       return -1;
61      break;
62    }
63   break;
64  case ROAR_CODEC_PCM_U_LE:
65  case ROAR_CODEC_PCM_U_BE:
66  case ROAR_CODEC_PCM_U_PDP:
67    if ( info->bits == 8 ) {
68     ss.format = PA_SAMPLE_U8;
69    } else {
70     return -1;
71    }
72   break;
73  default:
74    return -1;
75   break;
76 }
77
78 ss.rate     = info->rate;
79 ss.channels = info->channels;
80
81 if ( (self = roar_mm_malloc(sizeof(struct driver_pulsesimple))) == NULL )
82  return -1;
83
84 self->handle = pa_simple_new(device, "roard", dir, NULL, "RoarAudio Sound Server", &ss, NULL, NULL, NULL);
85
86 if ( self->handle == NULL ) {
87  roar_mm_free(self);
88  return -1;
89 }
90
91 memset(inst, 0, sizeof(struct roar_vio_calls));
92
93 inst->inst  = self;
94 inst->close = driver_pulsesimple_close;
95 inst->write = driver_pulsesimple_write;
96 inst->sync  = driver_pulsesimple_sync;
97 inst->ctl   = driver_pulsesimple_ctl;
98
99 return 0;
100}
101
102int     driver_pulsesimple_close        (struct roar_vio_calls * vio) {
103 struct driver_pulsesimple * self = vio->inst;
104
105 pa_simple_free(self->handle);
106
107 roar_mm_free(self);
108
109 return 0;
110}
111
112ssize_t driver_pulsesimple_write        (struct roar_vio_calls * vio, void *buf, size_t count) {
113 struct driver_pulsesimple * self = vio->inst;
114
115 return pa_simple_write(self->handle, buf, count, NULL);
116}
117
118int     driver_pulsesimple_sync         (struct roar_vio_calls * vio) {
119 struct driver_pulsesimple * self = vio->inst;
120
121 return pa_simple_drain(self->handle, NULL);
122}
123
124int     driver_pulsesimple_ctl          (struct roar_vio_calls * vio, int cmd, void * data) {
125 struct driver_pulsesimple * self = vio->inst;
126
127 (void)self;
128
129 return -1;
130}
131
132#endif
133
134//ll
Note: See TracBrowser for help on using the repository browser.