Changeset 235
- Timestamp:
- 05/29/06 13:53:54 (18 years ago)
- Files:
-
- branches/libfreebob-2.0/libfreebob/freebob_streaming.h (modified) (6 diffs)
- branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/freebob_streaming.cpp (modified) (4 diffs)
- branches/libfreebob-2.0/src/libstreaming/Port.cpp (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/Port.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/libfreebob/freebob_streaming.h
r233 r235 33 33 #define __FREEBOB_STREAMING_H__ 34 34 35 #include <stdlib.h> 36 35 37 #ifdef __cplusplus 36 38 extern "C" { … … 42 44 #define FREEBOB_IGNORE_PLAYBACK (1<<1) 43 45 44 #include <stdlib.h>45 46 46 47 /* The basic operation of the API is as follows: … … 151 152 typedef enum { 152 153 freebob_buffer_type_per_stream = -1, // use this to use the per-stream read functions 153 freebob_buffer_type_ uint24 = 0,154 freebob_buffer_type_int24 = 0, 154 155 freebob_buffer_type_float = 1, 156 freebob_buffer_type_midi = 2, 155 157 // freebob_buffer_type_uint32 = 2, 156 158 // freebob_buffer_type_double = 3, … … 263 265 * 264 266 */ 267 268 269 265 270 /** 266 271 * Sets the decode buffer for the stream. This allows for zero-copy decoding. … … 276 281 * @return -1 on error, 0 on success 277 282 */ 278 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int number, char *buff, freebob_streaming_buffer_type t); 283 284 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int number, char *buff); 285 int freebob_streaming_set_capture_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t); 286 int freebob_streaming_capture_stream_onoff(freebob_device_t *dev, int number, int on); 279 287 280 288 /** … … 290 298 * @return -1 on error, 0 on success 291 299 */ 292 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int number, char *buff, freebob_streaming_buffer_type t); 293 300 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int number, char *buff); 301 int freebob_streaming_set_playback_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t); 302 int freebob_streaming_playback_stream_onoff(freebob_device_t *dev, int number, int on); 303 304 305 /** 306 * preparation should be done after setting all per-stream parameters 307 * the way you want them. being buffer data type etc... 308 * 309 * @param dev 310 * @return 311 */ 312 313 int freebob_streaming_prepare(freebob_device_t *dev); 294 314 295 315 /** branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp
r233 r235 492 492 { 493 493 494 if((*it)->isDisabled()) {continue;}; 495 494 496 //FIXME: make this into a static_cast when not DEBUG? 495 497 … … 1052 1054 ++it ) 1053 1055 { 1056 1057 if((*it)->isDisabled()) {continue;}; 1054 1058 1055 1059 //FIXME: make this into a static_cast when not DEBUG? branches/libfreebob-2.0/src/libstreaming/freebob_streaming.cpp
r233 r235 143 143 144 144 // we are ready! 145 freebob_streaming_prepare(dev); 146 145 147 146 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n"); 148 147 return dev; … … 150 149 } 151 150 152 /**153 * preparation should be done after setting all per-stream parameters154 * the way you want them. being buffer data type etc...155 *156 * @param dev157 * @return158 */159 151 int freebob_streaming_prepare(freebob_device_t *dev) { 160 int i=0;152 debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 161 153 162 154 dev->processorManager->prepare(); … … 374 366 } 375 367 } 376 // TODO: the way port buffers are set doesn't satisfy me 377 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int i, char *buff, freebob_streaming_buffer_type t) { 368 369 int freebob_streaming_set_stream_buffer_type(freebob_device_t *dev, int i, 370 freebob_streaming_buffer_type t, enum Port::E_Direction direction) { 371 372 Port *p=dev->processorManager->getPortByIndex(i, direction); 373 if(!p) { 374 debugWarning("Could not get %s port at index %d\n", 375 (direction==Port::E_Playback?"Playback":"Capture"),i); 376 return -1; 377 } 378 379 switch(t) { 380 case freebob_buffer_type_int24: 381 if (!p->setDataType(Port::E_Int24)) { 382 debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 383 return -1; 384 } 385 if (!p->setBufferType(Port::E_PointerBuffer)) { 386 debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 387 return -1; 388 } 389 break; 390 case freebob_buffer_type_float: 391 if (!p->setDataType(Port::E_Float)) { 392 debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 393 return -1; 394 } 395 if (!p->setBufferType(Port::E_PointerBuffer)) { 396 debugWarning("%s: Could not set buffer type to Pointerbuffer\n",p->getName().c_str()); 397 return -1; 398 } 399 break; 400 case freebob_buffer_type_midi: 401 if (!p->setDataType(Port::E_MidiEvent)) { 402 debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 403 return -1; 404 } 405 if (!p->setBufferType(Port::E_RingBuffer)) { 406 debugWarning("%s: Could not set buffer type to Ringbuffer\n",p->getName().c_str()); 407 return -1; 408 } 409 break; 410 default: 411 debugWarning("%s: Unsupported buffer type\n",p->getName().c_str()); 412 return -1; 413 } 414 return 0; 415 416 } 417 418 int freebob_streaming_set_playback_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) { 419 return freebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback); 420 } 421 422 int freebob_streaming_set_capture_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) { 423 return freebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture); 424 } 425 426 int freebob_streaming_stream_onoff(freebob_device_t *dev, int i, 427 int on, enum Port::E_Direction direction) { 428 Port *p=dev->processorManager->getPortByIndex(i, direction); 429 if(!p) { 430 debugWarning("Could not get %s port at index %d\n", 431 (direction==Port::E_Playback?"Playback":"Capture"),i); 432 return -1; 433 } 434 if(on) { 435 p->enable(); 436 } else { 437 p->disable(); 438 } 439 return 0; 440 } 441 442 int freebob_streaming_playback_stream_onoff(freebob_device_t *dev, int number, int on) { 443 return freebob_streaming_stream_onoff(dev, number, on, Port::E_Playback); 444 } 445 446 int freebob_streaming_capture_stream_onoff(freebob_device_t *dev, int number, int on) { 447 return freebob_streaming_stream_onoff(dev, number, on, Port::E_Capture); 448 } 449 450 // TODO: the way port buffers are set in the C api doesn't satisfy me 451 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int i, char *buff) { 378 452 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 379 453 … … 388 462 } 389 463 390 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff , freebob_streaming_buffer_type t) {464 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff) { 391 465 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 392 466 // use an assert here performancewise, branches/libfreebob-2.0/src/libstreaming/Port.cpp
r230 r235 40 40 m_SignalType(E_PeriodSignalled), 41 41 m_BufferType(E_PointerBuffer), 42 m_ enabled(true),42 m_disabled(true), 43 43 m_initialized(false), 44 44 m_buffersize(0), … … 437 437 } 438 438 439 /// Enable the port. (this can be called anytime) 440 void 441 Port::enable() { 442 debugOutput(DEBUG_LEVEL_VERBOSE, "Enabling port %s...\n",m_Name.c_str()); 443 m_disabled=false; 444 }; 445 446 /// Disable the port. (this can be called anytime) 447 void 448 Port::disable() { 449 debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling port %s...\n",m_Name.c_str()); 450 m_disabled=false; 451 }; 452 453 439 454 /* Private functions */ 440 455 branches/libfreebob-2.0/src/libstreaming/Port.h
r230 r235 115 115 116 116 /// Enable the port. (this can be called anytime) 117 void enable() {m_enabled=true;};117 void enable(); 118 118 /// Disable the port. (this can be called anytime) 119 void disable() {m_enabled=false;};120 /// is the port enabled? (this can be called anytime)121 bool is Enabled() {return m_enabled;};119 void disable(); 120 /// is the port disabled? (this can be called anytime) 121 bool isDisabled() {return m_disabled;}; 122 122 123 123 /*! … … 275 275 enum E_BufferType m_BufferType; ///< Buffer type, [at construction] 276 276 277 bool m_ enabled; ///< is the port enabled?, [anytime]277 bool m_disabled; ///< is the port disabled?, [anytime] 278 278 bool m_initialized; ///< is the port initialized? [after init()] 279 279