source: roaraudio/plugins/xine/roar.c @ 4042:483e75fb333d

Last change on this file since 4042:483e75fb333d was 4042:483e75fb333d, checked in by phi, 14 years ago

added xine (c)

File size: 5.5 KB
Line 
1//roar.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
5 *      Copyright (C) 2000-2003 the xine project
6 *
7 *  This file is part of the xine RoarAudio plugin a part of RoarAudio,
8 *  a cross-platform sound system for both, home and professional use.
9 *  See README for details.
10 *
11 *  This file is free software; you can redistribute it and/or modify
12 *  it under the terms of the GNU General Public License version 3
13 *  as published by the Free Software Foundation.
14 *
15 *  RoarAudio is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU General Public License for more details.
19 *
20 *  You should have received a copy of the GNU General Public License
21 *  along with this software; see the file COPYING.  If not, write to
22 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 *  Boston, MA 02110-1301, USA.
24 *
25 */
26
27#include <roaraudio.h>
28#include <stdio.h>
29#include <stdlib.h>
30#include <errno.h>
31#include <string.h>
32#ifdef ROAR_HAVE_H_UNISTD
33#include <unistd.h>
34#endif
35#ifdef ROAR_HAVE_H_SIGNAL
36#include <signal.h>
37#endif
38#include <sys/time.h>
39#include <sys/uio.h>
40#include <inttypes.h>
41
42#include <xine/xine_internal.h>
43#include <xine/xineutils.h>
44#include <xine/audio_out.h>
45#include <xine/metronom.h>
46
47#define AO_OUT_ROAR_IFACE_VERSION 8
48
49#define GAP_TOLERANCE         5000
50
51typedef struct esd_driver_s {
52  ao_driver_t      ao_driver;
53
54  xine_t          *xine;
55
56  int              capabilities;
57
58  struct roar_connection con;
59  struct roar_stream     stream;
60  int fh;
61
62} roar_driver_t;
63
64typedef struct {
65  audio_driver_class_t driver_class;
66  xine_t          *xine;
67} roar_class_t;
68
69static int ao_roar_open(ao_driver_t *this_gen,
70                       uint32_t bits, uint32_t rate, int mode) {
71 return -1;
72}
73static void ao_roar_close(ao_driver_t *this_gen) {
74 roar_driver_t *this = (roar_driver_t *) this_gen;
75
76 if ( this->fh != -1 )
77  close(this->fh);
78 this->fh = -1;
79}
80
81static int ao_roar_num_channels(ao_driver_t *this_gen) {
82 return -1;
83}
84
85static int ao_roar_bytes_per_frame(ao_driver_t *this_gen) {
86  roar_driver_t *this = (roar_driver_t *) this_gen;
87  return (this->stream.info.bits * this->stream.info.channels)/8;
88}
89
90static int ao_roar_delay(ao_driver_t *this_gen) {
91 return 0;
92}
93
94static int ao_roar_write(ao_driver_t *this_gen,
95                        int16_t* frame_buffer, uint32_t num_frames) {
96 roar_driver_t *this = (roar_driver_t *) this_gen;
97 int bpf = (this->stream.info.bits * this->stream.info.channels)/8;
98 return write(this->fh, frame_buffer, num_frames*bpf) / bpf;
99}
100static int ao_roar_get_gap_tolerance (ao_driver_t *this_gen) {
101  return GAP_TOLERANCE;
102}
103
104static void ao_roar_exit(ao_driver_t *this_gen) {
105 roar_driver_t *this = (roar_driver_t *) this_gen;
106
107 ao_roar_close(this_gen);
108
109 roar_disconnect(&(this->con));
110
111 free(this);
112}
113
114static int ao_roar_get_property (ao_driver_t *this_gen, int property) {
115 return 0;
116}
117static int ao_roar_set_property (ao_driver_t *this_gen, int property, int value) {
118 return ~value;
119}
120
121static int ao_roar_ctrl(ao_driver_t *this_gen, int cmd, ...) {
122 return 0;
123}
124
125static uint32_t ao_roar_get_capabilities (ao_driver_t *this_gen) {
126  roar_driver_t *this = (roar_driver_t *) this_gen;
127  return this->capabilities;
128}
129
130static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
131                                 const void *data) {
132  roar_driver_t      *this;
133
134  this                     = (roar_driver_t *) xine_xmalloc(sizeof(roar_driver_t));
135  if ( !this )
136   return NULL;
137
138  if ( roar_simple_connect(&(this->con), NULL, "libxine") == -1 ) {
139   free(this);
140   return NULL;
141  }
142
143  this->fh = -1;
144
145  this->capabilities       = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL;
146
147
148  this->ao_driver.get_capabilities    = ao_roar_get_capabilities;
149  this->ao_driver.get_property        = ao_roar_get_property;
150  this->ao_driver.set_property        = ao_roar_set_property;
151  this->ao_driver.open                = ao_roar_open;
152  this->ao_driver.num_channels        = ao_roar_num_channels;
153  this->ao_driver.bytes_per_frame     = ao_roar_bytes_per_frame;
154  this->ao_driver.get_gap_tolerance   = ao_roar_get_gap_tolerance;
155  this->ao_driver.delay               = ao_roar_delay;
156  this->ao_driver.write               = ao_roar_write;
157  this->ao_driver.close               = ao_roar_close;
158  this->ao_driver.exit                = ao_roar_exit;
159  this->ao_driver.control             = ao_roar_ctrl;
160
161  return &(this->ao_driver);
162}
163
164
165static char* get_identifier (audio_driver_class_t *this_gen) {
166  return "roar";
167}
168
169static char* get_description (audio_driver_class_t *this_gen) {
170  return _("xine audio output plugin using RoarAudio");
171}
172
173static void dispose_class (audio_driver_class_t *this_gen) {
174
175  roar_class_t *this = (roar_class_t *) this_gen;
176
177  free (this);
178}
179
180static void *init_class (xine_t *xine, void *data) {
181
182  roar_class_t        *this;
183
184  this = (roar_class_t *) xine_xmalloc(sizeof(roar_class_t));
185
186  this->driver_class.open_plugin     = open_plugin;
187  this->driver_class.get_identifier  = get_identifier;
188  this->driver_class.get_description = get_description;
189  this->driver_class.dispose         = dispose_class;
190
191  this->xine = xine;
192
193  return this;
194}
195
196static const ao_info_t ao_info_roar = {
197  4
198};
199
200const plugin_info_t xine_plugin_info[] = {
201  /* type, API, "name", version, special_info, init_function */
202  { PLUGIN_AUDIO_OUT, AO_OUT_ROAR_IFACE_VERSION, "roar", XINE_VERSION_CODE, &ao_info_roar, init_class },
203  { PLUGIN_NONE, 0, "", 0, NULL, NULL }
204};
205
206//ll
Note: See TracBrowser for help on using the repository browser.