Changeset 816
- Timestamp:
- 01/06/08 03:53:04 (16 years ago)
- Files:
-
- branches/api-cleanup/libffado/ffado.h (modified) (3 diffs)
- branches/api-cleanup/SConstruct (modified) (1 diff)
- branches/api-cleanup/src/ffado.cpp (modified) (1 diff)
- branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (3 diffs)
- branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (9 diffs)
- branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (modified) (1 diff)
- branches/api-cleanup/src/libstreaming/generic/Port.cpp (modified) (4 diffs)
- branches/api-cleanup/src/libstreaming/generic/Port.h (modified) (7 diffs)
- branches/api-cleanup/src/libstreaming/generic/PortManager.cpp (modified) (1 diff)
- branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp (modified) (2 diffs)
- branches/api-cleanup/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (2 diffs)
- branches/api-cleanup/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (3 diffs)
- branches/api-cleanup/src/libstreaming/StreamProcessorManager.cpp (modified) (3 diffs)
- branches/api-cleanup/src/libstreaming/StreamProcessorManager.h (modified) (3 diffs)
- branches/api-cleanup/tests/streaming/teststreaming3.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/api-cleanup/libffado/ffado.h
r809 r816 207 207 /** 208 208 * 209 * Buffertypes known to the API209 * Audio data types known to the API 210 210 * 211 211 */ 212 212 typedef 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; 217 217 218 218 /** … … 338 338 339 339 int 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);341 340 int ffado_streaming_capture_stream_onoff(ffado_device_t *dev, int number, int on); 342 341 … … 354 353 */ 355 354 int 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);357 355 int ffado_streaming_playback_stream_onoff(ffado_device_t *dev, int number, int on); 358 356 357 ffado_streaming_audio_datatype ffado_streaming_get_audio_datatype(ffado_device_t *dev); 358 int ffado_streaming_set_audio_datatype(ffado_device_t *dev, ffado_streaming_audio_datatype t); 359 359 360 360 /** branches/api-cleanup/SConstruct
r809 r816 331 331 env['REVISION'] = '' 332 332 333 env['FFADO_API_VERSION']=" 6"333 env['FFADO_API_VERSION']="7" 334 334 335 335 env['PACKAGE'] = "libffado" 336 env['VERSION'] = "1.999.1 2"336 env['VERSION'] = "1.999.13" 337 337 env['LIBVERSION'] = "1.0.0" 338 338 branches/api-cleanup/src/ffado.cpp
r811 r816 335 335 } 336 336 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 337 int ffado_streaming_set_audio_datatype(ffado_device_t *dev, 338 ffado_streaming_audio_datatype t) { 347 339 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"); 351 356 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 361 ffado_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 380 372 } 381 373 branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r811 r816 336 336 target_event=(quadlet_t *)(data + p->getPosition()); 337 337 338 switch( p->getDataType()) {338 switch(m_StreamProcessorManager.getAudioDataType()) { 339 339 default: 340 debugError("bad type: %d\n", p->getDataType());340 debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 341 341 return -1; 342 case Port::E_Int24:342 case StreamProcessorManager::eADT_Int24: 343 343 { 344 344 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); … … 355 355 } 356 356 break; 357 case Port::E_Float:357 case StreamProcessorManager::eADT_Float: 358 358 { 359 359 const float multiplier = 1.0f / (float)(0x7FFFFF); … … 393 393 unsigned int location = p->getLocation(); 394 394 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 429 420 } 430 421 branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r815 r816 496 496 target_event= ( quadlet_t * ) ( data + p->getPosition() ); 497 497 498 switch ( p->getDataType() )498 switch ( m_StreamProcessorManager.getAudioDataType() ) 499 499 { 500 500 default: 501 debugError("bad type: %d\n", p->getDataType());501 debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 502 502 return -1; 503 case Port::E_Int24:503 case StreamProcessorManager::eADT_Int24: 504 504 { 505 505 quadlet_t *buffer= ( quadlet_t * ) ( p->getBufferAddress() ); … … 517 517 } 518 518 break; 519 case Port::E_Float:519 case StreamProcessorManager::eADT_Float: 520 520 { 521 521 float *buffer= ( float * ) ( p->getBufferAddress() ); … … 555 555 quadlet_t tmpval; 556 556 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 595 586 return 0; 596 587 } … … 605 596 target_event= ( quadlet_t * ) ( data + p->getPosition() ); 606 597 607 switch ( p->getDataType() )598 switch ( m_StreamProcessorManager.getAudioDataType() ) 608 599 { 609 600 default: 610 case Port::E_Int24:611 case Port::E_Float:601 case StreamProcessorManager::eADT_Int24: 602 case StreamProcessorManager::eADT_Float: 612 603 { 613 604 for ( j = 0; j < nevents; j += 1 ) // decode max nsamples … … 632 623 quadlet_t *target_event; 633 624 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 649 631 return 0; 650 632 } … … 671 653 assert(nevents + offset <= p.buffer_size ); 672 654 673 switch ( p.type)674 { 675 case Port::E_Float:655 switch ( m_StreamProcessorManager.getAudioDataType() ) 656 { 657 case StreamProcessorManager::eADT_Float: 676 658 { 677 659 float *buffer = (float *)(p.buffer); … … 689 671 } 690 672 break; 691 case Port::E_Int24:673 case StreamProcessorManager::eADT_Int24: 692 674 { 693 675 uint32_t *buffer = (uint32_t *)(p.buffer); … … 703 685 break; 704 686 default: 705 debugError("bad type: %d\n", m_ audio_ports.at(i).type);687 debugError("bad type: %d\n", m_StreamProcessorManager.getAudioDataType()); 706 688 return false; 707 689 } … … 762 744 // p.position = pinfo->getPosition(); 763 745 p.buffer = NULL; // to be filled by updatePortCache 764 p.type = (*it)->getDataType();765 746 #ifdef DEBUG 766 747 p.buffer_size = (*it)->getBufferSize(); branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h
r815 r816 138 138 struct _MBLA_port_cache { 139 139 AmdtpAudioPort* port; 140 Port::E_DataType type;141 140 void* buffer; 142 141 #ifdef DEBUG branches/api-cleanup/src/libstreaming/generic/Port.cpp
r811 r816 33 33 34 34 Port::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) 36 36 : m_Name( name ) 37 37 , m_disabled( true ) 38 38 , m_buffersize( 0 ) 39 , m_eventsize( 0 )40 , m_DataType( d )41 39 , m_PortType( porttype ) 42 40 , m_Direction( direction ) … … 77 75 } 78 76 79 m_eventsize = getEventSize(); // this won't change, so cache it80 81 77 m_State = E_Initialized; 82 78 return true; … … 109 105 110 106 unsigned 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 156 108 } 157 109 … … 194 146 debugOutput(DEBUG_LEVEL_VERBOSE,"State? : %d\n", m_State); 195 147 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()); 198 149 debugOutput(DEBUG_LEVEL_VERBOSE,"Port Type : %d\n", m_PortType); 199 150 debugOutput(DEBUG_LEVEL_VERBOSE,"Direction : %d\n", m_Direction); branches/api-cleanup/src/libstreaming/generic/Port.h
r809 r816 58 58 59 59 public: 60 /*!61 \brief The datatype of the port buffer62 */63 enum E_DataType {64 E_Float,65 E_Int24,66 E_MidiEvent,67 E_ControlEvent,68 };69 70 60 /*! 71 61 \brief The port type … … 85 75 }; 86 76 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); 88 78 89 79 virtual ~Port(); … … 114 104 unsigned int getEventSize(); 115 105 116 /**117 * \brief sets the event type for the port buffer118 *119 * \note use before calling init()120 */121 virtual bool setDataType(enum E_DataType);122 123 enum E_DataType getDataType() {return m_DataType;};124 125 106 enum E_PortType getPortType() {return m_PortType;}; ///< returns the port type (is fixed) 126 107 enum E_Direction getDirection() {return m_Direction;}; ///< returns the direction (is fixed) … … 160 141 161 142 unsigned int m_buffersize; 162 unsigned int m_eventsize; 163 164 enum E_DataType m_DataType; 143 165 144 enum E_PortType m_PortType; 166 145 enum E_Direction m_Direction; 167 146 168 147 void *m_buffer; 169 148 170 149 PortManager& m_manager; 171 150 … … 195 174 196 175 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) 198 177 {}; 199 178 … … 211 190 212 191 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) 214 193 {}; 215 194 virtual ~MidiPort() {}; … … 226 205 227 206 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) 229 208 {}; 230 209 virtual ~ControlPort() {}; branches/api-cleanup/src/libstreaming/generic/PortManager.cpp
r813 r816 90 90 assert(port); 91 91 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()); 94 94 95 95 port->setVerboseLevel(getDebugLevel()); branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp
r815 r816 980 980 { 981 981 unsigned int j=0; 982 switch(p->get DataType()) {982 switch(p->getPortType()) { 983 983 default: 984 debugError("Invalid port type: %d\n", p->get DataType());984 debugError("Invalid port type: %d\n", p->getPortType()); 985 985 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: 989 988 { 990 989 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); … … 998 997 } 999 998 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 } 1009 1011 } 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; 1010 1025 } 1011 1026 break; branches/api-cleanup/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r809 r816 246 246 src_data = (unsigned char *)data + p->getPosition(); 247 247 248 switch( p->getDataType()) {248 switch(m_StreamProcessorManager.getAudioDataType()) { 249 249 default: 250 case Port::E_Int24:250 case StreamProcessorManager::eADT_Int24: 251 251 { 252 252 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); … … 274 274 } 275 275 break; 276 case Port::E_Float:276 case StreamProcessorManager::eADT_Float: 277 277 { 278 278 const float multiplier = 1.0f / (float)(0x7FFFFF); branches/api-cleanup/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r809 r816 492 492 target = (unsigned char *)data + p->getPosition(); 493 493 494 switch( p->getDataType()) {494 switch(m_StreamProcessorManager.getAudioDataType()) { 495 495 default: 496 case Port::E_Int24:496 case StreamProcessorManager::eADT_Int24: 497 497 { 498 498 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); … … 516 516 } 517 517 break; 518 case Port::E_Float:518 case StreamProcessorManager::eADT_Float: 519 519 { 520 520 const float multiplier = (float)(0x7FFFFF); … … 546 546 unsigned char *target = (unsigned char *)data + p->getPosition(); 547 547 548 switch ( p->getDataType()) {548 switch (m_StreamProcessorManager.getAudioDataType()) { 549 549 default: 550 case Port::E_Int24:551 case Port::E_Float:550 case StreamProcessorManager::eADT_Int24: 551 case StreamProcessorManager::eADT_Float: 552 552 for (j = 0; j < nevents; j++) { 553 553 *target = *(target+1) = *(target+2) = 0; branches/api-cleanup/src/libstreaming/StreamProcessorManager.cpp
r807 r816 41 41 : m_is_slave( false ) 42 42 , m_SyncSource(NULL) 43 , m_xrun_happened( false ) 43 44 , m_nb_buffers( 0 ) 44 45 , m_period( 0 ) 46 , m_audio_datatype( eADT_Float ) 45 47 , m_nominal_framerate ( 0 ) 46 , m_xrun_happened( false )47 48 , m_xruns(0) 48 49 , m_nbperiods(0) … … 54 55 : m_is_slave( false ) 55 56 , m_SyncSource(NULL) 57 , m_xrun_happened( false ) 56 58 , m_nb_buffers(nb_buffers) 57 59 , m_period(period) 60 , m_audio_datatype( eADT_Float ) 58 61 , m_nominal_framerate ( framerate ) 59 62 , m_xruns(0) 60 , m_xrun_happened( false )61 63 , m_nbperiods(0) 62 64 { … … 915 917 debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping StreamProcessorManager information...\n"); 916 918 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")); 917 920 918 921 debugOutputShort( DEBUG_LEVEL_NORMAL, " Receive processors...\n"); branches/api-cleanup/src/libstreaming/StreamProcessorManager.h
r750 r816 50 50 51 51 public: 52 enum eADT_AudioDataType { 53 eADT_Int24, 54 eADT_Float, 55 }; 52 56 53 57 StreamProcessorManager(); … … 71 75 unsigned int getPeriodSize() 72 76 {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;} 73 82 74 83 void setNbBuffers(unsigned int nb_buffers) … … 139 148 unsigned int m_nb_buffers; 140 149 unsigned int m_period; 150 enum eADT_AudioDataType m_audio_datatype; 141 151 unsigned int m_nominal_framerate; 142 152 unsigned int m_xruns; branches/api-cleanup/tests/streaming/teststreaming3.cpp
r815 r816 317 317 exit(-1); 318 318 } 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 } 319 324 320 325 nb_in_channels = ffado_streaming_get_nb_capture_streams(dev); … … 326 331 min_ch_count = nb_out_channels; 327 332 } 328 333 329 334 /* allocate intermediate buffers */ 330 335 audiobuffers_in = (float **)calloc(nb_in_channels, sizeof(float *)); … … 336 341 /* assign the audiobuffer to the stream */ 337 342 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 }343 343 ffado_streaming_capture_stream_onoff(dev, i, 1); 344 344 break; … … 347 347 // note that using a float * buffer for midievents is a HACK 348 348 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);350 349 ffado_streaming_capture_stream_onoff(dev, i, 1); 351 350 default: … … 362 361 /* assign the audiobuffer to the stream */ 363 362 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 }369 363 ffado_streaming_playback_stream_onoff(dev, i, 1); 370 364 break; 371 365 // this is done with read/write routines because the nb of bytes can differ. 372 366 case ffado_stream_type_midi: 373 ffado_streaming_set_playback_buffer_type(dev, i, ffado_buffer_type_midi);374 367 ffado_streaming_set_playback_stream_buffer(dev, i, (char *)(audiobuffers_out[i])); 375 368 ffado_streaming_playback_stream_onoff(dev, i, 1);