source: roaraudio/plugins/xine/roar.c @ 468:528afaf72bd6

Last change on this file since 468:528afaf72bd6 was 468:528afaf72bd6, checked in by phi, 16 years ago

done some basic structure

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