Changeset 816

Show
Ignore:
Timestamp:
01/06/08 03:53:04 (16 years ago)
Author:
ppalmers
Message:

remove support for per-port datatypes. It's too much hassle and it doesn't add enough value.
It also prevents thorough performance optimizations, especially for larger channel counts (e.g. SSE based).

Audio ports are now either all float or all int24. This can be specified by the ffado_streaming_set_audio_datatype
API function before the streaming is prepared. Hence we can still support the direct conversion to the
clients datatype when demuxing the packets.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/api-cleanup/libffado/ffado.h

    r809 r816  
    207207/** 
    208208 * 
    209  * Buffer types known to the API 
     209 * Audio data types known to the API 
    210210 * 
    211211 */ 
    212212typedef enum { 
    213     ffado_buffer_type_int24           =  0
    214     ffado_buffer_type_float           =  1
    215     ffado_buffer_type_midi            =  2
    216 } ffado_streaming_buffer_type; 
     213    ffado_audio_datatype_error           = -1
     214    ffado_audio_datatype_int24           =  0
     215    ffado_audio_datatype_float           =  1
     216} ffado_streaming_audio_datatype; 
    217217 
    218218/** 
     
    338338 
    339339int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int number, char *buff); 
    340 int ffado_streaming_set_capture_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t); 
    341340int ffado_streaming_capture_stream_onoff(ffado_device_t *dev, int number, int on); 
    342341 
     
    354353 */ 
    355354int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int number, char *buff); 
    356 int ffado_streaming_set_playback_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t); 
    357355int ffado_streaming_playback_stream_onoff(ffado_device_t *dev, int number, int on); 
    358356 
     357ffado_streaming_audio_datatype ffado_streaming_get_audio_datatype(ffado_device_t *dev); 
     358int ffado_streaming_set_audio_datatype(ffado_device_t *dev, ffado_streaming_audio_datatype t); 
    359359 
    360360/** 
  • branches/api-cleanup/SConstruct

    r809 r816  
    331331        env['REVISION'] = '' 
    332332 
    333 env['FFADO_API_VERSION']="6
     333env['FFADO_API_VERSION']="7
    334334 
    335335env['PACKAGE'] = "libffado" 
    336 env['VERSION'] = "1.999.12
     336env['VERSION'] = "1.999.13
    337337env['LIBVERSION'] = "1.0.0" 
    338338 
  • branches/api-cleanup/src/ffado.cpp

    r811 r816  
    335335} 
    336336 
    337 int ffado_streaming_set_stream_buffer_type(ffado_device_t *dev, int i, 
    338     ffado_streaming_buffer_type t, enum Streaming::Port::E_Direction direction) { 
    339  
    340     Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, direction); 
    341     if(!p) { 
    342         debugWarning("Could not get %s port at index %d\n", 
    343             (direction==Streaming::Port::E_Playback?"Playback":"Capture"),i); 
    344         return -1; 
    345     } 
    346  
     337int ffado_streaming_set_audio_datatype(ffado_device_t *dev, 
     338    ffado_streaming_audio_datatype t) { 
    347339    switch(t) { 
    348     case ffado_buffer_type_int24: 
    349         if (!p->setDataType(Streaming::Port::E_Int24)) { 
    350             debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 
     340        case ffado_audio_datatype_int24: 
     341            if(!dev->m_deviceManager->getStreamProcessorManager().setAudioDataType( 
     342               Streaming::StreamProcessorManager::eADT_Int24)) { 
     343                debugError("Could not set datatype\n"); 
     344                return -1; 
     345            } 
     346            break; 
     347        case ffado_audio_datatype_float: 
     348            if(!dev->m_deviceManager->getStreamProcessorManager().setAudioDataType( 
     349               Streaming::StreamProcessorManager::eADT_Float)) { 
     350                debugError("Could not set datatype\n"); 
     351                return -1; 
     352            } 
     353            break; 
     354        default: 
     355            debugError("Invalid audio datatype\n"); 
    351356            return -1; 
    352         } 
    353         break; 
    354     case ffado_buffer_type_float: 
    355         if (!p->setDataType(Streaming::Port::E_Float)) { 
    356             debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 
    357             return -1; 
    358         } 
    359         break; 
    360     case ffado_buffer_type_midi: 
    361         if (!p->setDataType(Streaming::Port::E_MidiEvent)) { 
    362             debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 
    363             return -1; 
    364         } 
    365         break; 
    366     default: 
    367         debugWarning("%s: Unsupported buffer type (%d)\n", p->getName().c_str(), t); 
    368         return -1; 
    369     } 
    370     return 0; 
    371  
    372 
    373  
    374 int ffado_streaming_set_playback_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 
    375     return ffado_streaming_set_stream_buffer_type(dev, i, t, Streaming::Port::E_Playback); 
    376 
    377  
    378 int ffado_streaming_set_capture_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 
    379     return ffado_streaming_set_stream_buffer_type(dev, i, t, Streaming::Port::E_Capture); 
     357    } 
     358    return 0; 
     359
     360 
     361ffado_streaming_audio_datatype ffado_streaming_get_audio_datatype(ffado_device_t *dev) { 
     362    switch(dev->m_deviceManager->getStreamProcessorManager().getAudioDataType()) { 
     363        case Streaming::StreamProcessorManager::eADT_Int24: 
     364            return ffado_audio_datatype_int24; 
     365        case Streaming::StreamProcessorManager::eADT_Float: 
     366            return ffado_audio_datatype_float; 
     367        default: 
     368            debugError("Invalid audio datatype\n"); 
     369            return ffado_audio_datatype_error; 
     370    } 
     371    #warning FIXME 
    380372} 
    381373 
  • branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp

    r811 r816  
    336336    target_event=(quadlet_t *)(data + p->getPosition()); 
    337337 
    338     switch(p->getDataType()) { 
     338    switch(m_StreamProcessorManager.getAudioDataType()) { 
    339339        default: 
    340             debugError("bad type: %d\n", p->getDataType()); 
     340            debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 
    341341            return -1; 
    342         case Port::E_Int24: 
     342        case StreamProcessorManager::eADT_Int24: 
    343343            { 
    344344                quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     
    355355            } 
    356356            break; 
    357         case Port::E_Float: 
     357        case StreamProcessorManager::eADT_Float: 
    358358            { 
    359359                const float multiplier = 1.0f / (float)(0x7FFFFF); 
     
    393393    unsigned int location = p->getLocation(); 
    394394 
    395     switch(p->getDataType()) { 
    396         default: 
    397             debugError("bad type: %d\n", p->getDataType()); 
    398             return -1; 
    399         case Port::E_MidiEvent: 
    400             { 
    401                 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
    402  
    403                 assert(nevents + offset <= p->getBufferSize()); 
    404  
    405                 buffer+=offset; 
    406  
    407                 // clear 
    408                 memset(buffer, 0, nevents * 4); 
    409  
    410                 // assumes that dbc%8 == 0, which is always true if data points to the 
    411                 // start of a packet in blocking mode 
    412                 // midi events that belong to the same time mpx-ed block should all be 
    413                 // timed at the SYT timestamp of the packet. This basically means that they 
    414                 // all correspond to the first audio frame in the packet. 
    415                 for(j = location; j < nevents; j += 8) { 
    416                     target_event=(quadlet_t *)(data + ((j * m_dimension) + position)); 
    417                     sample_int=ntohl(*target_event); 
    418                     // FIXME: this assumes that 2X and 3X speed isn't used, 
    419                     // because only the 1X slot is put into the ringbuffer 
    420                     if(IEC61883_AM824_GET_LABEL(sample_int) != IEC61883_AM824_LABEL_MIDI_NO_DATA) { 
    421                         sample_int=(sample_int >> 16) & 0x000000FF; 
    422                         sample_int |= 0x01000000; // flag that there is a midi event present 
    423                         *buffer = sample_int; 
    424                     } 
    425                     buffer += 8; // skip 8 frames 
    426                 } 
    427             } 
    428             break; 
     395    quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     396 
     397    assert(nevents + offset <= p->getBufferSize()); 
     398 
     399    buffer+=offset; 
     400 
     401    // clear 
     402    memset(buffer, 0, nevents * 4); 
     403 
     404    // assumes that dbc%8 == 0, which is always true if data points to the 
     405    // start of a packet in blocking mode 
     406    // midi events that belong to the same time mpx-ed block should all be 
     407    // timed at the SYT timestamp of the packet. This basically means that they 
     408    // all correspond to the first audio frame in the packet. 
     409    for(j = location; j < nevents; j += 8) { 
     410        target_event=(quadlet_t *)(data + ((j * m_dimension) + position)); 
     411        sample_int=ntohl(*target_event); 
     412        // FIXME: this assumes that 2X and 3X speed isn't used, 
     413        // because only the 1X slot is put into the ringbuffer 
     414        if(IEC61883_AM824_GET_LABEL(sample_int) != IEC61883_AM824_LABEL_MIDI_NO_DATA) { 
     415            sample_int=(sample_int >> 16) & 0x000000FF; 
     416            sample_int |= 0x01000000; // flag that there is a midi event present 
     417            *buffer = sample_int; 
     418        } 
     419        buffer += 8; // skip 8 frames 
    429420    } 
    430421 
  • branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r815 r816  
    496496    target_event= ( quadlet_t * ) ( data + p->getPosition() ); 
    497497 
    498     switch ( p->getDataType() ) 
     498    switch ( m_StreamProcessorManager.getAudioDataType() ) 
    499499    { 
    500500        default: 
    501             debugError("bad type: %d\n", p->getDataType()); 
     501            debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 
    502502            return -1; 
    503         case Port::E_Int24: 
     503        case StreamProcessorManager::eADT_Int24: 
    504504        { 
    505505            quadlet_t *buffer= ( quadlet_t * ) ( p->getBufferAddress() ); 
     
    517517        } 
    518518        break; 
    519         case Port::E_Float: 
     519        case StreamProcessorManager::eADT_Float: 
    520520        { 
    521521            float *buffer= ( float * ) ( p->getBufferAddress() ); 
     
    555555    quadlet_t tmpval; 
    556556 
    557     switch ( p->getDataType() ) 
    558     { 
    559         default: 
    560             debugError("bad type: %d\n", p->getDataType()); 
    561             return -1; 
    562         case Port::E_MidiEvent: 
    563         { 
    564             quadlet_t *buffer = (quadlet_t *)(p->getBufferAddress()); 
    565  
    566             assert(nevents + offset <= p->getBufferSize()); 
    567  
    568             buffer+=offset; 
    569  
    570             for ( j = location; j < nevents; j += 8 ) 
    571             { 
    572                 target_event = (quadlet_t *) (data + ((j * m_dimension) + position)); 
    573  
    574                 if ( *buffer & 0xFF000000 )   // we can send a byte 
    575                 { 
    576                     tmpval = ((*buffer)<<16) & 0x00FF0000; 
    577                     tmpval=IEC61883_AM824_SET_LABEL(tmpval, IEC61883_AM824_LABEL_MIDI_1X); 
    578                     *target_event = htonl(tmpval); 
    579  
    580                     // debugOutput ( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", 
    581                     //            p->getName().c_str(), position, location, nevents, m_dimension ); 
    582                     // debugOutput ( DEBUG_LEVEL_VERBOSE, "base=%p, target=%p, value=%08X\n", 
    583                     //            data, target_event, tmpval ); 
    584                 } else { 
    585                     // can't send a byte, either because there is no byte, 
    586                     // or because this would exceed the maximum rate 
    587                     // FIXME: this can be ifdef optimized since it's a constant 
    588                     *target_event = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    589                 } 
    590                 buffer+=8; 
    591             } 
    592         } 
    593         break; 
    594     } 
     557    quadlet_t *buffer = (quadlet_t *)(p->getBufferAddress()); 
     558 
     559    assert(nevents + offset <= p->getBufferSize()); 
     560 
     561    buffer+=offset; 
     562 
     563    for ( j = location; j < nevents; j += 8 ) 
     564    { 
     565        target_event = (quadlet_t *) (data + ((j * m_dimension) + position)); 
     566 
     567        if ( *buffer & 0xFF000000 )   // we can send a byte 
     568        { 
     569            tmpval = ((*buffer)<<16) & 0x00FF0000; 
     570            tmpval=IEC61883_AM824_SET_LABEL(tmpval, IEC61883_AM824_LABEL_MIDI_1X); 
     571            *target_event = htonl(tmpval); 
     572 
     573            // debugOutput ( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", 
     574            //            p->getName().c_str(), position, location, nevents, m_dimension ); 
     575            // debugOutput ( DEBUG_LEVEL_VERBOSE, "base=%p, target=%p, value=%08X\n", 
     576            //            data, target_event, tmpval ); 
     577        } else { 
     578            // can't send a byte, either because there is no byte, 
     579            // or because this would exceed the maximum rate 
     580            // FIXME: this can be ifdef optimized since it's a constant 
     581            *target_event = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
     582        } 
     583        buffer+=8; 
     584    } 
     585 
    595586    return 0; 
    596587} 
     
    605596    target_event= ( quadlet_t * ) ( data + p->getPosition() ); 
    606597 
    607     switch ( p->getDataType() ) 
     598    switch ( m_StreamProcessorManager.getAudioDataType() ) 
    608599    { 
    609600        default: 
    610         case Port::E_Int24: 
    611         case Port::E_Float: 
     601        case StreamProcessorManager::eADT_Int24: 
     602        case StreamProcessorManager::eADT_Float: 
    612603        { 
    613604            for ( j = 0; j < nevents; j += 1 )   // decode max nsamples 
     
    632623    quadlet_t *target_event; 
    633624 
    634     switch ( p->getDataType() ) 
    635     { 
    636         default: 
    637             debugError("bad type: %d\n", p->getDataType()); 
    638             return -1; 
    639         case Port::E_MidiEvent: 
    640         { 
    641             for ( j = location; j < nevents; j += 8 ) 
    642             { 
    643                 target_event = (quadlet_t *) (data + ((j * m_dimension) + position)); 
    644                 *target_event=htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    645             } 
    646         } 
    647         break; 
    648     } 
     625    for ( j = location; j < nevents; j += 8 ) 
     626    { 
     627        target_event = (quadlet_t *) (data + ((j * m_dimension) + position)); 
     628        *target_event=htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
     629    } 
     630 
    649631    return 0; 
    650632} 
     
    671653        assert(nevents + offset <= p.buffer_size ); 
    672654 
    673         switch ( p.type
    674         { 
    675             case Port::E_Float: 
     655        switch ( m_StreamProcessorManager.getAudioDataType()
     656        { 
     657            case StreamProcessorManager::eADT_Float: 
    676658            { 
    677659                float *buffer = (float *)(p.buffer); 
     
    689671            } 
    690672            break; 
    691             case Port::E_Int24: 
     673            case StreamProcessorManager::eADT_Int24: 
    692674            { 
    693675                uint32_t *buffer = (uint32_t *)(p.buffer); 
     
    703685            break; 
    704686            default: 
    705                 debugError("bad type: %d\n", m_audio_ports.at(i).type); 
     687                debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 
    706688                return false; 
    707689        } 
     
    762744//                p.position = pinfo->getPosition(); 
    763745                p.buffer = NULL; // to be filled by updatePortCache 
    764                 p.type = (*it)->getDataType(); 
    765746#ifdef DEBUG 
    766747                p.buffer_size = (*it)->getBufferSize(); 
  • branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h

    r815 r816  
    138138    struct _MBLA_port_cache { 
    139139        AmdtpAudioPort*     port; 
    140         Port::E_DataType    type; 
    141140        void*               buffer; 
    142141#ifdef DEBUG 
  • branches/api-cleanup/src/libstreaming/generic/Port.cpp

    r811 r816  
    3333 
    3434Port::Port(PortManager& m, std::string name,  
    35            enum E_PortType porttype, enum E_Direction direction, enum E_DataType d
     35           enum E_PortType porttype, enum E_Direction direction
    3636    : m_Name( name ) 
    3737    , m_disabled( true ) 
    3838    , m_buffersize( 0 ) 
    39     , m_eventsize( 0 ) 
    40     , m_DataType( d ) 
    4139    , m_PortType( porttype ) 
    4240    , m_Direction( direction ) 
     
    7775    } 
    7876 
    79     m_eventsize = getEventSize(); // this won't change, so cache it 
    80  
    8177    m_State = E_Initialized; 
    8278    return true; 
     
    109105 
    110106unsigned int Port::getEventSize() { 
    111     switch (m_DataType) { 
    112         case E_Float: 
    113             return sizeof(float); 
    114         case E_Int24: // 24 bit 2's complement, packed in a 32bit integer (LSB's) 
    115             return sizeof(int32_t); 
    116         case E_MidiEvent: 
    117             return sizeof(uint32_t); 
    118         case E_ControlEvent: 
    119             return sizeof(uint32_t); 
    120         default: 
    121             return 0; 
    122     } 
    123 
    124  
    125 bool Port::setDataType(enum E_DataType d) { 
    126     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str()); 
    127     if (m_State != E_Created) { 
    128         debugFatal("Port (%s) not in E_Created state: %d\n",m_Name.c_str(),m_State); 
    129         return false; 
    130     } 
    131  
    132     // do some sanity checks 
    133     bool type_is_ok=false; 
    134     switch (m_PortType) { 
    135         case E_Audio: 
    136             if(d == E_Int24) type_is_ok=true; 
    137             if(d == E_Float) type_is_ok=true; 
    138             break; 
    139         case E_Midi: 
    140             if(d == E_MidiEvent) type_is_ok=true; 
    141             break; 
    142         case E_Control: 
    143             if(d == E_ControlEvent) type_is_ok=true; 
    144             break; 
    145         default: 
    146             break; 
    147     } 
    148  
    149     if(!type_is_ok) { 
    150         debugFatal("Datatype not supported by this type of port!\n"); 
    151         return false; 
    152     } 
    153  
    154     m_DataType=d; 
    155     return true; 
     107    return 4; // whether it's float, int24, midi or control, it's 4 
    156108} 
    157109 
     
    194146    debugOutput(DEBUG_LEVEL_VERBOSE,"State?        : %d\n", m_State); 
    195147    debugOutput(DEBUG_LEVEL_VERBOSE,"Buffer Size   : %d\n", m_buffersize); 
    196     debugOutput(DEBUG_LEVEL_VERBOSE,"Event Size    : %d\n", m_eventsize); 
    197     debugOutput(DEBUG_LEVEL_VERBOSE,"Data Type     : %d\n", m_DataType); 
     148    debugOutput(DEBUG_LEVEL_VERBOSE,"Event Size    : %d\n", getEventSize()); 
    198149    debugOutput(DEBUG_LEVEL_VERBOSE,"Port Type     : %d\n", m_PortType); 
    199150    debugOutput(DEBUG_LEVEL_VERBOSE,"Direction     : %d\n", m_Direction); 
  • branches/api-cleanup/src/libstreaming/generic/Port.h

    r809 r816  
    5858 
    5959public: 
    60     /*! 
    61     \brief The datatype of the port buffer 
    62     */ 
    63     enum E_DataType { 
    64         E_Float, 
    65         E_Int24, 
    66         E_MidiEvent, 
    67         E_ControlEvent, 
    68     }; 
    69  
    7060    /*! 
    7161    \brief The port type 
     
    8575    }; 
    8676 
    87     Port(PortManager&, std::string name, enum E_PortType, enum E_Direction, enum E_DataType); 
     77    Port(PortManager&, std::string name, enum E_PortType, enum E_Direction); 
    8878 
    8979    virtual ~Port(); 
     
    114104    unsigned int getEventSize(); 
    115105 
    116     /** 
    117      * \brief sets the event type for the port buffer 
    118      * 
    119      * \note use before calling init() 
    120      */ 
    121     virtual bool setDataType(enum E_DataType); 
    122  
    123     enum E_DataType getDataType() {return m_DataType;}; 
    124  
    125106    enum E_PortType getPortType() {return m_PortType;}; ///< returns the port type (is fixed) 
    126107    enum E_Direction getDirection() {return m_Direction;}; ///< returns the direction (is fixed) 
     
    160141 
    161142    unsigned int m_buffersize; 
    162     unsigned int m_eventsize; 
    163  
    164     enum E_DataType m_DataType; 
     143 
    165144    enum E_PortType m_PortType; 
    166145    enum E_Direction m_Direction; 
    167146 
    168147    void *m_buffer; 
    169      
     148 
    170149    PortManager& m_manager; 
    171150 
     
    195174 
    196175    AudioPort(PortManager& m, std::string name, enum E_Direction direction) 
    197       : Port(m, name, E_Audio, direction, E_Int24
     176      : Port(m, name, E_Audio, direction
    198177    {}; 
    199178 
     
    211190 
    212191    MidiPort(PortManager& m, std::string name, enum E_Direction direction) 
    213       : Port(m, name, E_Midi, direction, E_MidiEvent
     192      : Port(m, name, E_Midi, direction
    214193    {}; 
    215194    virtual ~MidiPort() {}; 
     
    226205 
    227206    ControlPort(PortManager& m, std::string name, enum E_Direction direction) 
    228       : Port(m, name, E_Control, direction, E_ControlEvent
     207      : Port(m, name, E_Control, direction
    229208    {}; 
    230209    virtual ~ControlPort() {}; 
  • branches/api-cleanup/src/libstreaming/generic/PortManager.cpp

    r813 r816  
    9090    assert(port); 
    9191 
    92     debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s, type: %d, dir: %d, dtype: %d\n", 
    93         port->getName().c_str(), port->getPortType(), port->getDirection(), port->getDataType()); 
     92    debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s, type: %d, dir: %d\n", 
     93        port->getName().c_str(), port->getPortType(), port->getDirection()); 
    9494 
    9595    port->setVerboseLevel(getDebugLevel()); 
  • branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp

    r815 r816  
    980980{ 
    981981    unsigned int j=0; 
    982     switch(p->getDataType()) { 
     982    switch(p->getPortType()) { 
    983983        default: 
    984             debugError("Invalid port type: %d\n", p->getDataType()); 
     984            debugError("Invalid port type: %d\n", p->getPortType()); 
    985985            return -1; 
    986         case Port::E_Int24: 
    987         case Port::E_MidiEvent: 
    988         case Port::E_ControlEvent: 
     986        case Port::E_Midi: 
     987        case Port::E_Control: 
    989988            { 
    990989                quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     
    998997            } 
    999998            break; 
    1000         case Port::E_Float: 
    1001             { 
    1002                 float *buffer=(float *)(p->getBufferAddress()); 
    1003                 assert(nevents + offset <= p->getBufferSize()); 
    1004                 buffer+=offset; 
    1005  
    1006                 for(j = 0; j < nevents; j += 1) { 
    1007                     *buffer = 0.0; 
    1008                     buffer++; 
     999        case Port::E_Audio: 
     1000            switch(m_StreamProcessorManager.getAudioDataType()) { 
     1001            case StreamProcessorManager::eADT_Int24: 
     1002                { 
     1003                    quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     1004                    assert(nevents + offset <= p->getBufferSize()); 
     1005                    buffer+=offset; 
     1006     
     1007                    for(j = 0; j < nevents; j += 1) { 
     1008                        *(buffer)=0; 
     1009                        buffer++; 
     1010                    } 
    10091011                } 
     1012                break; 
     1013            case StreamProcessorManager::eADT_Float: 
     1014                { 
     1015                    float *buffer=(float *)(p->getBufferAddress()); 
     1016                    assert(nevents + offset <= p->getBufferSize()); 
     1017                    buffer+=offset; 
     1018     
     1019                    for(j = 0; j < nevents; j += 1) { 
     1020                        *buffer = 0.0; 
     1021                        buffer++; 
     1022                    } 
     1023                } 
     1024                break; 
    10101025            } 
    10111026            break; 
  • branches/api-cleanup/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp

    r809 r816  
    246246    src_data = (unsigned char *)data + p->getPosition(); 
    247247 
    248     switch(p->getDataType()) { 
     248    switch(m_StreamProcessorManager.getAudioDataType()) { 
    249249        default: 
    250         case Port::E_Int24: 
     250        case StreamProcessorManager::eADT_Int24: 
    251251            { 
    252252                quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     
    274274            } 
    275275            break; 
    276         case Port::E_Float: 
     276        case StreamProcessorManager::eADT_Float: 
    277277            { 
    278278                const float multiplier = 1.0f / (float)(0x7FFFFF); 
  • branches/api-cleanup/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp

    r809 r816  
    492492    target = (unsigned char *)data + p->getPosition(); 
    493493 
    494     switch(p->getDataType()) { 
     494    switch(m_StreamProcessorManager.getAudioDataType()) { 
    495495        default: 
    496         case Port::E_Int24: 
     496        case StreamProcessorManager::eADT_Int24: 
    497497            { 
    498498                quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 
     
    516516            } 
    517517            break; 
    518         case Port::E_Float: 
     518        case StreamProcessorManager::eADT_Float: 
    519519            { 
    520520                const float multiplier = (float)(0x7FFFFF); 
     
    546546    unsigned char *target = (unsigned char *)data + p->getPosition(); 
    547547 
    548     switch (p->getDataType()) { 
     548    switch (m_StreamProcessorManager.getAudioDataType()) { 
    549549    default: 
    550         case Port::E_Int24: 
    551         case Port::E_Float: 
     550        case StreamProcessorManager::eADT_Int24: 
     551        case StreamProcessorManager::eADT_Float: 
    552552        for (j = 0; j < nevents; j++) { 
    553553            *target = *(target+1) = *(target+2) = 0; 
  • branches/api-cleanup/src/libstreaming/StreamProcessorManager.cpp

    r807 r816  
    4141    : m_is_slave( false ) 
    4242    , m_SyncSource(NULL) 
     43    , m_xrun_happened( false ) 
    4344    , m_nb_buffers( 0 ) 
    4445    , m_period( 0 ) 
     46    , m_audio_datatype( eADT_Float ) 
    4547    , m_nominal_framerate ( 0 ) 
    46     , m_xrun_happened( false ) 
    4748    , m_xruns(0) 
    4849    , m_nbperiods(0) 
     
    5455    : m_is_slave( false ) 
    5556    , m_SyncSource(NULL) 
     57    , m_xrun_happened( false ) 
    5658    , m_nb_buffers(nb_buffers) 
    5759    , m_period(period) 
     60    , m_audio_datatype( eADT_Float ) 
    5861    , m_nominal_framerate ( framerate ) 
    5962    , m_xruns(0) 
    60     , m_xrun_happened( false ) 
    6163    , m_nbperiods(0) 
    6264{ 
     
    915917    debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping StreamProcessorManager information...\n"); 
    916918    debugOutputShort( DEBUG_LEVEL_NORMAL, "Period count: %6d\n", m_nbperiods); 
     919    debugOutputShort( DEBUG_LEVEL_NORMAL, "Data type: %s\n", (m_audio_datatype==eADT_Float?"float":"int24")); 
    917920 
    918921    debugOutputShort( DEBUG_LEVEL_NORMAL, " Receive processors...\n"); 
  • branches/api-cleanup/src/libstreaming/StreamProcessorManager.h

    r750 r816  
    5050 
    5151public: 
     52    enum eADT_AudioDataType { 
     53        eADT_Int24, 
     54        eADT_Float, 
     55    }; 
    5256 
    5357    StreamProcessorManager(); 
     
    7175    unsigned int getPeriodSize() 
    7276            {return m_period;}; 
     77 
     78    bool setAudioDataType(enum eADT_AudioDataType t) 
     79        {m_audio_datatype = t; return true;}; 
     80    enum eADT_AudioDataType getAudioDataType() 
     81        {return m_audio_datatype;} 
    7382 
    7483    void setNbBuffers(unsigned int nb_buffers) 
     
    139148    unsigned int m_nb_buffers; 
    140149    unsigned int m_period; 
     150    enum eADT_AudioDataType m_audio_datatype; 
    141151    unsigned int m_nominal_framerate; 
    142152    unsigned int m_xruns; 
  • branches/api-cleanup/tests/streaming/teststreaming3.cpp

    r815 r816  
    317317        exit(-1); 
    318318    } 
     319    if (arguments.audio_buffer_type == 0) { 
     320        ffado_streaming_set_audio_datatype(dev, ffado_audio_datatype_float); 
     321    } else { 
     322        ffado_streaming_set_audio_datatype(dev, ffado_audio_datatype_int24); 
     323    } 
    319324 
    320325    nb_in_channels = ffado_streaming_get_nb_capture_streams(dev); 
     
    326331        min_ch_count = nb_out_channels; 
    327332    } 
    328      
     333 
    329334    /* allocate intermediate buffers */ 
    330335    audiobuffers_in = (float **)calloc(nb_in_channels, sizeof(float *)); 
     
    336341                /* assign the audiobuffer to the stream */ 
    337342                ffado_streaming_set_capture_stream_buffer(dev, i, (char *)(audiobuffers_in[i])); 
    338                 if (arguments.audio_buffer_type == 0) { 
    339                     ffado_streaming_set_capture_buffer_type(dev, i, ffado_buffer_type_float); 
    340                 } else { 
    341                     ffado_streaming_set_capture_buffer_type(dev, i, ffado_buffer_type_int24); 
    342                 } 
    343343                ffado_streaming_capture_stream_onoff(dev, i, 1); 
    344344                break; 
     
    347347                // note that using a float * buffer for midievents is a HACK 
    348348                ffado_streaming_set_capture_stream_buffer(dev, i, (char *)(audiobuffers_in[i])); 
    349                 ffado_streaming_set_capture_buffer_type(dev, i, ffado_buffer_type_midi); 
    350349                ffado_streaming_capture_stream_onoff(dev, i, 1); 
    351350            default: 
     
    362361                /* assign the audiobuffer to the stream */ 
    363362                ffado_streaming_set_playback_stream_buffer(dev, i, (char *)(audiobuffers_out[i])); 
    364                 if (arguments.audio_buffer_type == 0) { 
    365                     ffado_streaming_set_playback_buffer_type(dev, i, ffado_buffer_type_float); 
    366                 } else { 
    367                     ffado_streaming_set_playback_buffer_type(dev, i, ffado_buffer_type_int24); 
    368                 } 
    369363                ffado_streaming_playback_stream_onoff(dev, i, 1); 
    370364                break; 
    371365                // this is done with read/write routines because the nb of bytes can differ. 
    372366            case ffado_stream_type_midi: 
    373                 ffado_streaming_set_playback_buffer_type(dev, i, ffado_buffer_type_midi); 
    374367                ffado_streaming_set_playback_stream_buffer(dev, i, (char *)(audiobuffers_out[i])); 
    375368                ffado_streaming_playback_stream_onoff(dev, i, 1);