Changeset 3869:c63e1367041c in roaraudio
- Timestamp:
- 05/19/10 22:14:22 (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r3810 r3869 6 6 * Fixed some problems with minimal builds 7 7 * Some Copyright fixes 8 * much better VIO support for connections 8 9 9 10 v. 0.3beta5 - Sun May 02 2010 12:41 CEST -
include/libroar/basic.h
r3836 r3869 47 47 #endif 48 48 49 #define ROAR_CON_FLAGS_NONE 0x00 50 #define ROAR_CON_FLAGS_FH 0x01 51 #define ROAR_CON_FLAGS_VIO 0x02 52 49 53 struct roar_message { 50 54 int cmd; … … 72 76 int roar_get_connection_fh (struct roar_connection * con); 73 77 int roar_get_connection_vio (struct roar_connection * con, struct roar_vio_calls * vio); 78 struct roar_vio_calls * roar_get_connection_vio2 (struct roar_connection * con); 74 79 int roar_disconnect (struct roar_connection * con); 75 80 -
libroar/basic.c
r3836 r3869 231 231 memset(con, 0, sizeof(struct roar_connection)); 232 232 233 con->__fh = fh; 233 con->flags = ROAR_CON_FLAGS_FH; 234 con->__fh = fh; 235 236 if ( roar_vio_open_fh_socket(&(con->viocon), fh) != -1 ) 237 con->flags |= ROAR_CON_FLAGS_VIO; 234 238 235 239 roar_errno = ROAR_ERROR_NONE; … … 238 242 239 243 int roar_get_connection_fh (struct roar_connection * con) { 240 roar_debug_warn_sysio("roar_get_connection_fh", "roar_get_connection_vio ", NULL);244 roar_debug_warn_sysio("roar_get_connection_fh", "roar_get_connection_vio2", NULL); 241 245 242 246 if ( con == NULL ) 243 247 return -1; 244 248 249 if ( !(con->flags & ROAR_CON_FLAGS_FH) ) 250 return -1; 251 245 252 return con->__fh; 246 253 } 247 254 248 255 int roar_get_connection_vio (struct roar_connection * con, struct roar_vio_calls * vio) { 256 roar_debug_warn_obsolete("roar_get_connection_vio", "roar_get_connection_vio2", NULL); 257 249 258 if ( con == NULL || vio == NULL ) 250 259 return -1; 251 260 261 if ( !(con->flags & ROAR_CON_FLAGS_FH) ) 262 return -1; 263 252 264 return roar_vio_open_fh_socket(vio, con->__fh); 253 265 } 254 266 267 struct roar_vio_calls * roar_get_connection_vio2 (struct roar_connection * con) { 268 if ( con == NULL ) 269 return NULL; 270 271 if ( con->flags & ROAR_CON_FLAGS_VIO ) 272 return &(con->viocon); 273 274 // TODO: try to open the VIO. 275 276 return NULL; 277 } 278 255 279 int roar_disconnect (struct roar_connection * con) { 256 struct roar_vio_calls vio;280 struct roar_vio_calls * vio; 257 281 struct roar_message m; 258 282 … … 264 288 roar_req(con, &m, NULL); 265 289 266 if ( roar_get_connection_vio(con, &vio) != -1) {267 roar_vio_close( &vio);290 if ( (vio = roar_get_connection_vio2(con)) != NULL ) { 291 roar_vio_close(vio); 268 292 } 269 293 … … 329 353 #define _ROAR_MESS_BUF_LEN (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */) 330 354 int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) { 331 struct roar_vio_calls vio;332 333 if ( roar_get_connection_vio(con, &vio) == -1)334 return -1; 335 336 return roar_vsend_message( &vio, mes, data);355 struct roar_vio_calls * vio; 356 357 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 358 return -1; 359 360 return roar_vsend_message(vio, mes, data); 337 361 } 338 362 … … 369 393 370 394 int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) { 371 struct roar_vio_calls vio;372 373 if ( roar_get_connection_vio(con, &vio) == -1)374 return -1; 375 376 return roar_vrecv_message( &vio, mes, data);395 struct roar_vio_calls * vio; 396 397 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 398 return -1; 399 400 return roar_vrecv_message(vio, mes, data); 377 401 } 378 402 … … 464 488 465 489 int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) { 466 struct roar_vio_calls vio;467 468 if ( roar_get_connection_vio(con, &vio) == -1)469 return -1; 470 471 return roar_vreq( &vio, mes, data);490 struct roar_vio_calls * vio; 491 492 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 493 return -1; 494 495 return roar_vreq(vio, mes, data); 472 496 } 473 497 -
roard/driver_portaudio.c
r3751 r3869 33 33 #ifdef ROAR_HAVE_LIBPABLIO 34 34 long flags = PABLIO_WRITE; 35 #elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 36 PaError err; 37 PaStreamParameters params; 35 38 #endif 36 39 … … 102 105 103 106 return 0; 107 #elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 108 params.device = Pa_GetDefaultOutputDevice(); 109 params.channelCount = info->channels; 110 params.sampleFormat = fmt; 111 params.suggestedLatency = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency; 112 params.hostApiSpecificStreamInfo = NULL; 113 114 // TODO: FIXME: use libroar for this. 115 self->framesize = info->bits * info->channels / 8; 116 117 // Sets up blocking I/O stream. 118 #if 0 119 err = Pa_OpenStream(&(self->stream), 120 NULL, 121 ¶ms, 122 info->rate, 123 128 /*FIXME:frames*/, 124 paClipOff, 125 NULL, 126 NULL 127 ); 128 #endif 129 130 if ( err != paNoError ) { 131 ROAR_ERR("driver_portaudio_open(*): Could not open PortAudio device: \"%s\".", Pa_GetErrorText(err)); 132 roar_mm_free(self); 133 return -1; 134 } 135 136 err = Pa_StartStream(self->stream); 137 138 if ( err != paNoError ) { 139 ROAR_ERR("driver_portaudio_open(*): Could not start stream: \"%s\".", Pa_GetErrorText(err)); 140 roar_mm_free(self); 141 return -1; 142 } 143 144 return 0; 104 145 #else 105 146 return -1; … … 110 151 struct driver_portaudio * self = vio->inst; 111 152 153 // TODO: cleanup common code. 154 112 155 #ifdef ROAR_HAVE_LIBPABLIO 113 156 CloseAudioStream(self->ostream); … … 116 159 117 160 roar_mm_free(self); 161 162 return 0; 163 #elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 164 if ( (self != NULL) && (self->stream != NULL) ) { 165 Pa_StopStream(self->stream); 166 Pa_CloseStream(self->stream); 167 } 168 169 roar_mm_free(self); 170 171 Pa_Terminate(); 118 172 119 173 return 0; … … 132 186 ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, count=%llu) = ? // PABLIO mode", vio, buf, (long long unsigned int)count); 133 187 return WriteAudioStream(self->ostream, buf, count) * self->ostream->bytesPerFrame; 188 #elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 189 size_t write_frames = count / self->framesize; 190 PaError err; 191 192 ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, size=%llu) = ?", vio, buf, (long long unsigned int)size); 193 194 // I'm not 100% sure if you could write arbitrary number of frames to Pa_WriteStream(), but it seems to be backend dependent. 195 err = Pa_WriteStream(self->stream, buf, write_frames); 196 197 if ( err < 0 && err != paOutputUnderflowed ) 198 return -1; 199 200 // PA always seems to write requested size, or it will error out. 201 return count; 134 202 #else 135 203 return -1; -
roard/include/driver_portaudio.h
r3751 r3869 27 27 #define _DRIVER_PORTAUDIO_H_ 28 28 29 //#undef ROAR_HAVE_LIBPABLIO 30 //#define ROAR_HAVE_LIBPORTAUDIO_V0_19 31 29 32 #ifdef ROAR_HAVE_LIBPORTAUDIO 30 #if defined(ROAR_HAVE_LIBPABLIO) 33 #if defined(ROAR_HAVE_LIBPABLIO) || defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 31 34 #define _DRIVER_PORTAUDIO_CAN_OPERATE 32 35 #endif … … 38 41 #ifdef ROAR_HAVE_LIBPABLIO 39 42 PABLIO_Stream * ostream; 43 #elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 44 PaStream *stream; 45 int framesize; 40 46 #endif 41 47 }; 48 49 typedef struct { 50 /* 51 params.device = Pa_GetDefaultOutputDevice(); 52 params.channelCount = info->channels; 53 params.sampleFormat = fmt; 54 params.suggestedLatency = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency; 55 params.hostApiSpecificStreamInfo = NULL; 56 */ 57 void * device; 58 int channelCount; 59 PaSampleFormat sampleFormat; 60 int suggestedLatency; 61 void * hostApiSpecificStreamInfo; 62 } PaStreamParameters; 63 64 #define paOutputUnderflowed -1 65 66 void * Pa_GetDefaultOutputDevice(void); 67 // Pa_WriteStream(device->stream, buf, write_frames); 68 PaError Pa_WriteStream(PaStream * stream, void *, size_t); 69 PaError Pa_StartStream(PaStream * stream); 70 PaError Pa_StopStream(PaStream * stream); 71 PaError Pa_CloseStream(PaStream * stream); 42 72 43 73 int driver_portaudio_open(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream);
Note: See TracChangeset
for help on using the changeset viewer.