source: roaraudio/plugins/xine/roar.c @ 3095:b9abe0b8991f

Last change on this file since 3095:b9abe0b8991f was 3055:9903e05fc8b0, checked in by phi, 14 years ago

do not include files in case we do not have them

File size: 5.4 KB
Line 
1//roar.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
5 *
6 *  This file is part of the xine RoarAudio plugin 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, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include <roaraudio.h>
26#include <stdio.h>
27#include <stdlib.h>
28#include <errno.h>
29#include <string.h>
30#ifdef ROAR_HAVE_H_UNISTD
31#include <unistd.h>
32#endif
33#ifdef ROAR_HAVE_H_SIGNAL
34#include <signal.h>
35#endif
36#include <sys/time.h>
37#include <sys/uio.h>
38#include <inttypes.h>
39
40#include <xine/xine_internal.h>
41#include <xine/xineutils.h>
42#include <xine/audio_out.h>
43#include <xine/metronom.h>
44
45#define AO_OUT_ROAR_IFACE_VERSION 8
46
47#define GAP_TOLERANCE         5000
48
49typedef struct esd_driver_s {
50  ao_driver_t      ao_driver;
51
52  xine_t          *xine;
53
54  int              capabilities;
55
56  struct roar_connection con;
57  struct roar_stream     stream;
58  int fh;
59
60} roar_driver_t;
61
62typedef struct {
63  audio_driver_class_t driver_class;
64  xine_t          *xine;
65} roar_class_t;
66
67static int ao_roar_open(ao_driver_t *this_gen,
68                       uint32_t bits, uint32_t rate, int mode) {
69 return -1;
70}
71static void ao_roar_close(ao_driver_t *this_gen) {
72 roar_driver_t *this = (roar_driver_t *) this_gen;
73
74 if ( this->fh != -1 )
75  close(this->fh);
76 this->fh = -1;
77}
78
79static int ao_roar_num_channels(ao_driver_t *this_gen) {
80 return -1;
81}
82
83static int ao_roar_bytes_per_frame(ao_driver_t *this_gen) {
84  roar_driver_t *this = (roar_driver_t *) this_gen;
85  return (this->stream.info.bits * this->stream.info.channels)/8;
86}
87
88static int ao_roar_delay(ao_driver_t *this_gen) {
89 return 0;
90}
91
92static int ao_roar_write(ao_driver_t *this_gen,
93                        int16_t* frame_buffer, uint32_t num_frames) {
94 roar_driver_t *this = (roar_driver_t *) this_gen;
95 int bpf = (this->stream.info.bits * this->stream.info.channels)/8;
96 return write(this->fh, frame_buffer, num_frames*bpf) / bpf;
97}
98static int ao_roar_get_gap_tolerance (ao_driver_t *this_gen) {
99  return GAP_TOLERANCE;
100}
101
102static void ao_roar_exit(ao_driver_t *this_gen) {
103 roar_driver_t *this = (roar_driver_t *) this_gen;
104
105 ao_roar_close(this_gen);
106
107 roar_disconnect(&(this->con));
108
109 free(this);
110}
111
112static int ao_roar_get_property (ao_driver_t *this_gen, int property) {
113 return 0;
114}
115static int ao_roar_set_property (ao_driver_t *this_gen, int property, int value) {
116 return ~value;
117}
118
119static int ao_roar_ctrl(ao_driver_t *this_gen, int cmd, ...) {
120 return 0;
121}
122
123static uint32_t ao_roar_get_capabilities (ao_driver_t *this_gen) {
124  roar_driver_t *this = (roar_driver_t *) this_gen;
125  return this->capabilities;
126}
127
128static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
129                                 const void *data) {
130  roar_driver_t      *this;
131
132  this                     = (roar_driver_t *) xine_xmalloc(sizeof(roar_driver_t));
133  if ( !this )
134   return NULL;
135
136  if ( roar_simple_connect(&(this->con), NULL, "libxine") == -1 ) {
137   free(this);
138   return NULL;
139  }
140
141  this->fh = -1;
142
143  this->capabilities       = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL;
144
145
146  this->ao_driver.get_capabilities    = ao_roar_get_capabilities;
147  this->ao_driver.get_property        = ao_roar_get_property;
148  this->ao_driver.set_property        = ao_roar_set_property;
149  this->ao_driver.open                = ao_roar_open;
150  this->ao_driver.num_channels        = ao_roar_num_channels;
151  this->ao_driver.bytes_per_frame     = ao_roar_bytes_per_frame;
152  this->ao_driver.get_gap_tolerance   = ao_roar_get_gap_tolerance;
153  this->ao_driver.delay               = ao_roar_delay;
154  this->ao_driver.write               = ao_roar_write;
155  this->ao_driver.close               = ao_roar_close;
156  this->ao_driver.exit                = ao_roar_exit;
157  this->ao_driver.control             = ao_roar_ctrl;
158
159  return &(this->ao_driver);
160}
161
162
163static char* get_identifier (audio_driver_class_t *this_gen) {
164  return "roar";
165}
166
167static char* get_description (audio_driver_class_t *this_gen) {
168  return _("xine audio output plugin using RoarAudio");
169}
170
171static void dispose_class (audio_driver_class_t *this_gen) {
172
173  roar_class_t *this = (roar_class_t *) this_gen;
174
175  free (this);
176}
177
178static void *init_class (xine_t *xine, void *data) {
179
180  roar_class_t        *this;
181
182  this = (roar_class_t *) xine_xmalloc(sizeof(roar_class_t));
183
184  this->driver_class.open_plugin     = open_plugin;
185  this->driver_class.get_identifier  = get_identifier;
186  this->driver_class.get_description = get_description;
187  this->driver_class.dispose         = dispose_class;
188
189  this->xine = xine;
190
191  return this;
192}
193
194static const ao_info_t ao_info_roar = {
195  4
196};
197
198const plugin_info_t xine_plugin_info[] = {
199  /* type, API, "name", version, special_info, init_function */
200  { PLUGIN_AUDIO_OUT, AO_OUT_ROAR_IFACE_VERSION, "roar", XINE_VERSION_CODE, &ao_info_roar, init_class },
201  { PLUGIN_NONE, 0, "", 0, NULL, NULL }
202};
203
204//ll
Note: See TracBrowser for help on using the repository browser.