Changeset 235

Show
Ignore:
Timestamp:
05/29/06 13:53:54 (16 years ago)
Author:
pieterpalmers
Message:

- implemented enable/disable for the ports
- improved the C api somewhat

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libfreebob-2.0/libfreebob/freebob_streaming.h

    r233 r235  
    3333#define __FREEBOB_STREAMING_H__ 
    3434 
     35#include <stdlib.h> 
     36 
    3537#ifdef __cplusplus 
    3638extern "C" { 
     
    4244#define FREEBOB_IGNORE_PLAYBACK         (1<<1) 
    4345 
    44 #include <stdlib.h> 
    4546 
    4647/* The basic operation of the API is as follows: 
     
    151152typedef enum { 
    152153        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, 
    154155        freebob_buffer_type_float            =   1, 
     156        freebob_buffer_type_midi            =   2, 
    155157//      freebob_buffer_type_uint32           =   2, 
    156158//      freebob_buffer_type_double           =   3, 
     
    263265 * 
    264266 */ 
     267  
     268  
     269  
    265270/** 
    266271 * Sets the decode buffer for the stream. This allows for zero-copy decoding. 
     
    276281 * @return -1 on error, 0 on success 
    277282 */ 
    278 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int number, char *buff, freebob_streaming_buffer_type t); 
     283 
     284int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int number, char *buff); 
     285int freebob_streaming_set_capture_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t); 
     286int freebob_streaming_capture_stream_onoff(freebob_device_t *dev, int number, int on); 
    279287 
    280288/** 
     
    290298 * @return -1 on error, 0 on success 
    291299 */ 
    292 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int number, char *buff, freebob_streaming_buffer_type t); 
    293  
     300int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int number, char *buff); 
     301int freebob_streaming_set_playback_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t); 
     302int 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  
     313int freebob_streaming_prepare(freebob_device_t *dev); 
    294314 
    295315/** 
  • branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp

    r233 r235  
    492492    { 
    493493 
     494        if((*it)->isDisabled()) {continue;}; 
     495         
    494496                //FIXME: make this into a static_cast when not DEBUG? 
    495497 
     
    10521054          ++it ) 
    10531055    { 
     1056 
     1057        if((*it)->isDisabled()) {continue;}; 
    10541058 
    10551059                //FIXME: make this into a static_cast when not DEBUG? 
  • branches/libfreebob-2.0/src/libstreaming/freebob_streaming.cpp

    r233 r235  
    143143 
    144144        // we are ready! 
    145         freebob_streaming_prepare(dev); 
    146  
     145         
    147146        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n"); 
    148147        return dev; 
     
    150149} 
    151150 
    152 /** 
    153  * preparation should be done after setting all per-stream parameters 
    154  * the way you want them. being buffer data type etc... 
    155  * 
    156  * @param dev  
    157  * @return  
    158  */ 
    159151int freebob_streaming_prepare(freebob_device_t *dev) { 
    160         int i=0
     152        debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n")
    161153         
    162154        dev->processorManager->prepare(); 
     
    374366        } 
    375367} 
    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 
     369int 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 
     418int 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 
     422int 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 
     426int 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 
     442int 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 
     446int 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 
     451int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int i, char *buff) { 
    378452        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    379453         
     
    388462} 
    389463 
    390 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff,  freebob_streaming_buffer_type t) { 
     464int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff) { 
    391465        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    392466        // use an assert here performancewise,  
  • branches/libfreebob-2.0/src/libstreaming/Port.cpp

    r230 r235  
    4040        m_SignalType(E_PeriodSignalled), 
    4141        m_BufferType(E_PointerBuffer), 
    42         m_enabled(true), 
     42        m_disabled(true), 
    4343        m_initialized(false), 
    4444        m_buffersize(0), 
     
    437437} 
    438438 
     439/// Enable the port. (this can be called anytime) 
     440void  
     441Port::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) 
     447void  
     448Port::disable() { 
     449        debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling port %s...\n",m_Name.c_str()); 
     450    m_disabled=false; 
     451}; 
     452 
     453 
    439454/* Private functions */ 
    440455 
  • branches/libfreebob-2.0/src/libstreaming/Port.h

    r230 r235  
    115115         
    116116        /// Enable the port. (this can be called anytime) 
    117         void enable()  {m_enabled=true;}
     117        void enable()
    118118        /// 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 isEnabled() {return m_enabled;}; 
     119        void disable()
     120        /// is the port disabled? (this can be called anytime) 
     121        bool isDisabled() {return m_disabled;}; 
    122122 
    123123        /*! 
     
    275275        enum E_BufferType m_BufferType; ///< Buffer type, [at construction] 
    276276 
    277         bool m_enabled; ///< is the port enabled?, [anytime] 
     277        bool m_disabled; ///< is the port disabled?, [anytime] 
    278278        bool m_initialized; ///< is the port initialized? [after init()] 
    279279