source: roaraudio/roard/driver_jack.c @ 4492:150839188b8a

driver_example
Last change on this file since 4492:150839188b8a was 4492:150839188b8a, checked in by phi, 14 years ago

implemented some jack stuff

File size: 4.8 KB
Line 
1//driver_jack.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010
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_LIBJACK
29int driver_jack_open_vio  (struct roar_vio_calls * inst,
30                           char * device,
31                           struct roar_audio_info * info,
32                           int fh,
33                           struct roar_stream_server * sstream) {
34 struct driver_jack * self;
35
36 // we are not FH Safe, return error if fh != -1:
37 if ( fh != -1 )
38  return -1;
39
40 // set up VIO:
41 memset(inst, 0, sizeof(struct roar_vio_calls));
42
43 inst->read     = driver_jack_read;
44 inst->write    = driver_jack_write;
45 inst->lseek    = NULL; // no seeking on this device
46 inst->nonblock = driver_jack_nonblock;
47 inst->sync     = driver_jack_sync;
48 inst->ctl      = driver_jack_ctl;
49 inst->close    = driver_jack_close;
50
51 // set up internal struct:
52 if ( (self = roar_mm_malloc(sizeof(struct driver_jack))) == NULL )
53  return -1;
54
55 memset(self, 0, sizeof(struct driver_jack));
56
57 inst->inst     = self;
58
59 // return -1 on error or 0 on no error.
60 return -1;
61}
62
63ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
64 struct driver_jack * self = vio->inst;
65 // read up to count bytes into buf.
66 // return the number of bits read.
67 return -1;
68}
69
70ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
71 struct driver_jack * self = vio->inst;
72 // write up to count bytes from buf.
73 // return the number of written bytes.
74 return -1;
75}
76
77int     driver_jack_nonblock(struct roar_vio_calls * vio, int state) {
78 struct driver_jack * self = vio->inst;
79 // control if read and write calls should block untill all data is read or written.
80 // state could be:
81 //  ROAR_SOCKET_BLOCK    - Block untill the data is read or written
82 //  ROAR_SOCKET_NONBLOCK - Return as soon as possible
83 return -1;
84}
85
86int     driver_jack_sync    (struct roar_vio_calls * vio) {
87 struct driver_jack * self = vio->inst;
88 // init to sync data to device.
89 // sync does not need to be complet when this function returns.
90 return 0;
91}
92
93int     driver_jack_ctl     (struct roar_vio_calls * vio, int cmd, void * data) {
94 struct driver_jack * self = vio->inst;
95 // function for a lot control features.
96
97 switch (cmd) {
98  case ROAR_VIO_CTL_GET_NAME:
99    if ( data == NULL )
100     return -1;
101
102    *(char**)data = "driver_jack";
103    return 0;
104   break;
105  case ROAR_VIO_CTL_GET_FH:
106  case ROAR_VIO_CTL_GET_READ_FH:
107  case ROAR_VIO_CTL_GET_WRITE_FH:
108  case ROAR_VIO_CTL_GET_SELECT_FH:
109  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
110  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
111/* Return FH if possible:
112    *(int*)data = FH...;
113*/
114    return -1;
115   break;
116  case ROAR_VIO_CTL_SET_NOSYNC:
117    vio->sync = NULL;
118    return 0;
119   break;
120   case ROAR_VIO_CTL_GET_AUINFO:
121   case ROAR_VIO_CTL_SET_AUINFO:
122    // get or set audio info, data is a struct roar_audio_info*.
123    return -1;
124   break;
125   case ROAR_VIO_CTL_GET_DBLKSIZE:
126   case ROAR_VIO_CTL_SET_DBLKSIZE:
127     // get or set block size used, data is uint_least32_t*, number of bytes.
128    return -1;
129   break;
130   case ROAR_VIO_CTL_GET_DBLOCKS:
131   case ROAR_VIO_CTL_SET_DBLOCKS:
132     // get or set number of blocks used, data is uint_least32_t*.
133    return -1;
134   break;
135   case ROAR_VIO_CTL_SET_SSTREAM:
136    // set server stream object for this stream, data is struct roar_stream_server*
137    return -1;
138   break;
139   case ROAR_VIO_CTL_SET_SSTREAMID:
140    // set stream ID for this stream, data is int*
141    return -1;
142   break;
143   case ROAR_VIO_CTL_SET_VOLUME:
144    // set volume for this device, data is struct roar_mixer_settings*
145    return -1;
146   break;
147   case ROAR_VIO_CTL_GET_DELAY:
148    // get delay of this stream, data is uint_least32_t*, in bytes
149    // there is more about delay. please ask.
150    return -1;
151   break;
152  default:
153    return -1;
154   break;
155 }
156}
157
158int     driver_jack_close   (struct roar_vio_calls * vio) {
159 struct driver_jack * self = vio->inst;
160 // close and free everything in here...
161
162 roar_mm_free(self);
163
164 return 0;
165}
166
167#endif
168
169//ll
Note: See TracBrowser for help on using the repository browser.