source: roaraudio/roard/driver_jack.c @ 4493:e5e48378a3f3

Last change on this file since 4493:e5e48378a3f3 was 4493:e5e48378a3f3, checked in by phi, 13 years ago

some basic jack infrastrcuture

File size: 4.9 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 if ( (self->client = jack_client_new("roard")) == NULL ) {
60  roar_mm_free(self);
61  return -1;
62 }
63
64 // return -1 on error or 0 on no error.
65 return 0;
66}
67
68ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count) {
69 struct driver_jack * self = vio->inst;
70 // read up to count bytes into buf.
71 // return the number of bits read.
72 return -1;
73}
74
75ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count) {
76 struct driver_jack * self = vio->inst;
77 // write up to count bytes from buf.
78 // return the number of written bytes.
79 return -1;
80}
81
82int     driver_jack_nonblock(struct roar_vio_calls * vio, int state) {
83 struct driver_jack * self = vio->inst;
84 // control if read and write calls should block untill all data is read or written.
85 // state could be:
86 //  ROAR_SOCKET_BLOCK    - Block untill the data is read or written
87 //  ROAR_SOCKET_NONBLOCK - Return as soon as possible
88 return -1;
89}
90
91int     driver_jack_sync    (struct roar_vio_calls * vio) {
92 struct driver_jack * self = vio->inst;
93 // init to sync data to device.
94 // sync does not need to be complet when this function returns.
95 return 0;
96}
97
98int     driver_jack_ctl     (struct roar_vio_calls * vio, int cmd, void * data) {
99 struct driver_jack * self = vio->inst;
100 // function for a lot control features.
101
102 switch (cmd) {
103  case ROAR_VIO_CTL_GET_NAME:
104    if ( data == NULL )
105     return -1;
106
107    *(char**)data = "driver_jack";
108    return 0;
109   break;
110  case ROAR_VIO_CTL_GET_FH:
111  case ROAR_VIO_CTL_GET_READ_FH:
112  case ROAR_VIO_CTL_GET_WRITE_FH:
113  case ROAR_VIO_CTL_GET_SELECT_FH:
114  case ROAR_VIO_CTL_GET_SELECT_READ_FH:
115  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH:
116/* Return FH if possible:
117    *(int*)data = FH...;
118*/
119    return -1;
120   break;
121  case ROAR_VIO_CTL_SET_NOSYNC:
122    vio->sync = NULL;
123    return 0;
124   break;
125   case ROAR_VIO_CTL_GET_AUINFO:
126   case ROAR_VIO_CTL_SET_AUINFO:
127    // get or set audio info, data is a struct roar_audio_info*.
128    return -1;
129   break;
130   case ROAR_VIO_CTL_GET_DBLKSIZE:
131   case ROAR_VIO_CTL_SET_DBLKSIZE:
132     // get or set block size used, data is uint_least32_t*, number of bytes.
133    return -1;
134   break;
135   case ROAR_VIO_CTL_GET_DBLOCKS:
136   case ROAR_VIO_CTL_SET_DBLOCKS:
137     // get or set number of blocks used, data is uint_least32_t*.
138    return -1;
139   break;
140   case ROAR_VIO_CTL_SET_SSTREAM:
141    // set server stream object for this stream, data is struct roar_stream_server*
142    return -1;
143   break;
144   case ROAR_VIO_CTL_SET_SSTREAMID:
145    // set stream ID for this stream, data is int*
146    return -1;
147   break;
148   case ROAR_VIO_CTL_SET_VOLUME:
149    // set volume for this device, data is struct roar_mixer_settings*
150    return -1;
151   break;
152   case ROAR_VIO_CTL_GET_DELAY:
153    // get delay of this stream, data is uint_least32_t*, in bytes
154    // there is more about delay. please ask.
155    return -1;
156   break;
157  default:
158    return -1;
159   break;
160 }
161}
162
163int     driver_jack_close   (struct roar_vio_calls * vio) {
164 struct driver_jack * self = vio->inst;
165 // close and free everything in here...
166
167 jack_client_close(self->client);
168
169 roar_mm_free(self);
170
171 return 0;
172}
173
174#endif
175
176//ll
Note: See TracBrowser for help on using the repository browser.