Changeset 223
- Timestamp:
- 05/25/06 13:14:18 (18 years ago)
- Files:
-
- branches/libfreebob-2.0/src/bebob_light/bebob_light_avdevice.cpp (modified) (7 diffs)
- branches/libfreebob-2.0/src/bebob_light/bebob_light_avdevice.h (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (8 diffs)
- branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.h (modified) (4 diffs)
- branches/libfreebob-2.0/src/libstreaming/freebob_streaming.cpp (modified) (3 diffs)
- branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/IsoStream.h (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessor.cpp (modified) (3 diffs)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessor.h (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/src/bebob_light/bebob_light_avdevice.cpp
r221 r223 49 49 , m_nodeId( nodeId ) 50 50 , m_verboseLevel( verboseLevel ) 51 , m_receiveProcessor ( 0 ) 52 , m_transmitProcessor ( 0 ) 51 , m_receiveProcessor ( 0 ) 52 , m_receiveProcessorBandwidth ( -1 ) 53 , m_transmitProcessor ( 0 ) 54 , m_transmitProcessorBandwidth ( -1 ) 53 55 { 54 56 if ( m_verboseLevel ) { … … 1857 1859 int plug=0; 1858 1860 int hostplug=-1; 1859 int bandwidth=-1; 1860 1861 1861 1862 switch (i) { 1862 1863 case 0: … … 1868 1869 raw1394_get_local_id (m_1394Service->getHandle()), 1869 1870 &hostplug, 1870 & bandwidth);1871 &m_receiveProcessorBandwidth); 1871 1872 1872 1873 // set the channel obtained by the connection management … … 1881 1882 m_nodeId | 0xffc0, 1882 1883 &plug, 1883 & bandwidth);1884 &m_transmitProcessorBandwidth); 1884 1885 1885 1886 // set the channel obtained by the connection management … … 1900 1901 int plug=0; 1901 1902 int hostplug=-1; 1902 int bandwidth=-1;1903 1903 1904 1904 switch (i) { … … 1912 1912 hostplug, 1913 1913 m_receiveProcessor->getChannel(), 1914 bandwidth);1914 m_receiveProcessorBandwidth); 1915 1915 1916 1916 break; … … 1924 1924 plug, 1925 1925 m_transmitProcessor->getChannel(), 1926 bandwidth);1926 m_transmitProcessorBandwidth); 1927 1927 1928 1928 // set the channel obtained by the connection management branches/libfreebob-2.0/src/bebob_light/bebob_light_avdevice.h
r221 r223 130 130 // streaming stuff 131 131 FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor; 132 int m_receiveProcessorBandwidth; 133 134 FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor; 135 int m_transmitProcessorBandwidth; 136 137 // FIXME: remove this debug line 132 138 FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor2; 133 FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor;139 int m_receiveProcessor2Bandwidth; 134 140 135 141 branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp
r222 r223 54 54 55 55 int AmdtpTransmitStreamProcessor::init() { 56 int fdf=0, syt_interval=0;57 int m_dbs=0;58 56 int err=0; 59 57 … … 62 60 // because this sets the buffersizes from the processormanager 63 61 if((err=TransmitStreamProcessor::init())) { 64 debugFatal("Could not allocate memory event ringbuffer (%d)",err);62 debugFatal("Could not init (%p), err=(%d)",this,err); 65 63 return err; 66 64 } 67 68 69 switch (m_framerate) { 70 case 32000: 71 syt_interval = 8; 72 fdf = IEC61883_FDF_SFC_32KHZ; 73 break; 74 case 44100: 75 syt_interval = 8; 76 fdf = IEC61883_FDF_SFC_44K1HZ; 77 break; 78 default: 79 case 48000: 80 syt_interval = 8; 81 fdf = IEC61883_FDF_SFC_48KHZ; 82 break; 83 case 88200: 84 syt_interval = 16; 85 fdf = IEC61883_FDF_SFC_88K2HZ; 86 break; 87 case 96000: 88 syt_interval = 16; 89 fdf = IEC61883_FDF_SFC_96KHZ; 90 break; 91 case 176400: 92 syt_interval = 32; 93 fdf = IEC61883_FDF_SFC_176K4HZ; 94 break; 95 case 192000: 96 syt_interval = 32; 97 fdf = IEC61883_FDF_SFC_192KHZ; 98 break; 99 } 65 66 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); 67 68 69 debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d, FDF: %d, DBS: %d, SYT: %d\n", 70 m_framerate,m_fdf,m_dimension,m_syt_interval); 100 71 101 72 iec61883_cip_init ( 102 73 &m_cip_status, 103 74 IEC61883_FMT_AMDTP, 104 fdf,75 m_fdf, 105 76 m_framerate, 106 m_d bs,107 syt_interval);77 m_dimension, 78 m_syt_interval); 108 79 109 80 // allocate the event buffer … … 122 93 // return -ENOMEM; 123 94 } 124 125 // call the parent init 126 return TransmitStreamProcessor::init(); 95 96 // we should transfer the port buffer contents to the event buffer 97 int i=m_nb_buffers; 98 while(i--) transfer(); 99 100 return 0; 127 101 } 128 102 … … 159 133 read_size) 160 134 { 161 debugWarning("Transmit buffer underrun\n"); 135 debugWarning("Transmit buffer underrun (cycle %d, FC=%d, PC=%d)\n", 136 cycle, m_framecounter, m_handler->getPacketCount()); 162 137 163 138 // signal underrun … … 197 172 } 198 173 199 voidAmdtpTransmitStreamProcessor::prepare() {174 bool AmdtpTransmitStreamProcessor::prepare() { 200 175 201 176 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 177 178 switch (m_framerate) { 179 case 32000: 180 m_syt_interval = 8; 181 m_fdf = IEC61883_FDF_SFC_32KHZ; 182 break; 183 case 44100: 184 m_syt_interval = 8; 185 m_fdf = IEC61883_FDF_SFC_44K1HZ; 186 break; 187 default: 188 case 48000: 189 m_syt_interval = 8; 190 m_fdf = IEC61883_FDF_SFC_48KHZ; 191 break; 192 case 88200: 193 m_syt_interval = 16; 194 m_fdf = IEC61883_FDF_SFC_88K2HZ; 195 break; 196 case 96000: 197 m_syt_interval = 16; 198 m_fdf = IEC61883_FDF_SFC_96KHZ; 199 break; 200 case 176400: 201 m_syt_interval = 32; 202 m_fdf = IEC61883_FDF_SFC_176K4HZ; 203 break; 204 case 192000: 205 m_syt_interval = 32; 206 m_fdf = IEC61883_FDF_SFC_192KHZ; 207 break; 208 } 202 209 203 210 // prepare all non-device specific stuff … … 205 212 TransmitStreamProcessor::prepare(); 206 213 207 // after preparing, we should transfer the port buffer contents to the event buffer 208 int i=m_nb_buffers; 209 while(i--) transfer(); 214 return true; 210 215 211 216 } … … 336 341 int AmdtpReceiveStreamProcessor::init() { 337 342 int err=0; 343 344 338 345 // call the parent init 339 346 // this has to be done before allocating the buffers, … … 429 436 } 430 437 431 voidAmdtpReceiveStreamProcessor::prepare() {438 bool AmdtpReceiveStreamProcessor::prepare() { 432 439 433 440 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 441 switch (m_framerate) { 442 case 32000: 443 m_syt_interval = 8; 444 break; 445 case 44100: 446 m_syt_interval = 8; 447 break; 448 default: 449 case 48000: 450 m_syt_interval = 8; 451 break; 452 case 88200: 453 m_syt_interval = 16; 454 break; 455 case 96000: 456 m_syt_interval = 16; 457 break; 458 case 176400: 459 m_syt_interval = 32; 460 break; 461 case 192000: 462 m_syt_interval = 32; 463 break; 464 } 434 465 435 466 // prepare all non-device specific stuff 436 467 // i.e. the iso stream and the associated ports 437 ReceiveStreamProcessor::prepare();468 return ReceiveStreamProcessor::prepare(); 438 469 } 439 470 branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.h
r221 r223 62 62 int init(); 63 63 void reset(); 64 voidprepare();64 bool prepare(); 65 65 int transfer(); 66 66 virtual void setVerboseLevel(int l); 67 68 // NOTE: shouldn't this be (4*m_period)/(3*m_syt_interval), because every 3 packets, one empty is sent 69 unsigned int getPacketsPerPeriod() {return m_period/m_syt_interval;}; 70 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 67 71 68 72 protected: … … 73 77 char* m_cluster_buffer; 74 78 int m_dimension; 79 unsigned int m_syt_interval; 80 81 int m_fdf; 75 82 76 83 int transmitBlock(char *data, unsigned int nevents, … … 101 108 int init(); 102 109 void reset(); 103 voidprepare();110 bool prepare(); 104 111 int transfer(); 105 112 … … 114 121 char* m_cluster_buffer; 115 122 int m_dimension; 116 123 unsigned int m_syt_interval; 117 124 DECLARE_DEBUG_MODULE; 118 125 branches/libfreebob-2.0/src/libstreaming/freebob_streaming.cpp
r221 r223 173 173 printf("Could not register receive stream processor with the Processor manager\n"); 174 174 } 175 printf("Registering stream processor %d of device %d with isomanager\n",j,i);176 if (dev->isoManager->registerStream(streamproc)) {177 printf("Could not register receive stream processor with the Iso manager\n");178 }179 175 } 180 176 } … … 194 190 delete dev->processorManager; 195 191 delete dev->isoManager; 196 192 delete dev->m_deviceManager; 197 193 delete dev; 198 194 … … 221 217 device->startStreamByIndex(j); 222 218 } 219 device->getStreamProcessorByIndex(1)->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 223 220 } 224 221 225 222 dev->processorManager->prepare(); 223 224 dev->processorManager->registerStreamProcessors(dev->isoManager); 225 226 226 dev->isoManager->prepare(); 227 227 228 228 229 // start the runner thread 229 230 dev->thread->Start(); 230 231 231 if(dev->isoManager->startHandlers()) { 232 int cycle=0; 233 if(dev->isoManager->startHandlers(cycle)) { 232 234 debugFatal("Could not start handlers\n"); 233 235 return -1; branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp
r221 r223 215 215 { 216 216 raw1394_iso_shutdown(m_handle); 217 218 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso handler\n"); 217 219 218 220 if(raw1394_iso_recv_init(m_handle, iso_receive_handler, branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp
r221 r223 231 231 232 232 if (stream->getType()==IsoStream::EST_Transmit) { 233 IsoXmitHandler *h = new IsoXmitHandler(stream->getPort()); 233 234 // setup the optimal parameters for the raw1394 ISO buffering 235 unsigned int packets_per_period=stream->getPacketsPerPeriod(); 236 // hardware interrupts occur when one DMA block is full, and the size of one DMA 237 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq is 238 // occurs at a period boundary (optimal CPU use) 239 // NOTE: try and use 2 interrupts per period for better latency. 240 unsigned int max_packet_size=getpagesize() / packets_per_period * 2; 241 int irq_interval=packets_per_period / 2; 242 243 if (max_packet_size < stream->getMaxPacketSize()) { 244 max_packet_size=stream->getMaxPacketSize(); 245 } 246 247 /* the transmit buffer size should be as low as possible for latency. 248 */ 249 int buffers=packets_per_period; 250 if (buffers<10) buffers=10; 251 252 // create the actual handler 253 IsoXmitHandler *h = new IsoXmitHandler(stream->getPort(), buffers, 254 max_packet_size, irq_interval); 234 255 235 256 debugOutput( DEBUG_LEVEL_VERBOSE, " registering IsoXmitHandler\n"); branches/libfreebob-2.0/src/libstreaming/IsoStream.h
r221 r223 73 73 enum EStreamType getType() { return m_type;}; 74 74 75 virtual unsigned int getPacketsPerPeriod() {return 1;}; 76 virtual unsigned int getMaxPacketSize() {return 1024;}; //FIXME: arbitrary 77 75 78 virtual int init(); 76 79 branches/libfreebob-2.0/src/libstreaming/StreamProcessor.cpp
r221 r223 86 86 { 87 87 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 88 89 return IsoStream::init(); 90 } 91 92 void StreamProcessor::reset() { 93 94 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 95 96 m_framecounter=0; 97 98 // loop over the ports to reset them 99 PortManager::reset(); 100 101 // reset the iso stream 102 IsoStream::reset(); 103 104 } 105 106 bool StreamProcessor::prepare() { 107 108 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 109 // TODO: implement 110 111 // init the ports 112 88 113 if(!m_manager) { 89 114 debugFatal("Not attached to a manager!\n"); … … 97 122 debugOutputShort( DEBUG_LEVEL_VERBOSE, "Setting m_period : %d\n", m_period); 98 123 99 100 return IsoStream::init();101 }102 103 void StreamProcessor::reset() {104 105 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n");106 107 m_framecounter=0;108 109 // loop over the ports to reset them110 PortManager::reset();111 112 // reset the iso stream113 IsoStream::reset();114 115 }116 117 void StreamProcessor::prepare() {118 119 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");120 // TODO: implement121 122 // init the ports123 124 125 124 // loop over the ports to reset them 126 125 PortManager::prepare(); … … 128 127 // reset the iso stream 129 128 IsoStream::prepare(); 129 130 return true; 130 131 131 132 } branches/libfreebob-2.0/src/libstreaming/StreamProcessor.h
r212 r223 74 74 virtual void reset(); // reset the streams & buffers (e.g. after xrun) 75 75 76 virtual voidprepare(); // prepare the streams & buffers (e.g. prefill)76 virtual bool prepare(); // prepare the streams & buffers (e.g. prefill) 77 77 78 78 virtual void dumpInfo(); branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp
r221 r223 141 141 } 142 142 return count; 143 } 144 145 int StreamProcessorManager::registerStreamProcessors(IsoHandlerManager *m) { 146 147 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 148 it != m_ReceiveProcessors.end(); 149 ++it ) { 150 debugOutput(DEBUG_LEVEL_VERBOSE,"Registering stream processor %p with isomanager\n",*it); 151 if (m->registerStream(*it)) { 152 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register receive stream processor with the Iso manager\n"); 153 } 154 } 155 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 156 it != m_TransmitProcessors.end(); 157 ++it ) { 158 debugOutput(DEBUG_LEVEL_VERBOSE,"Registering stream processor %p with isomanager\n",*it); 159 if (m->registerStream(*it)) { 160 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register transmit stream processor with the Iso manager\n"); 161 } 162 } 163 164 return 0; 143 165 } 144 166 … … 395 417 it != m_ReceiveProcessors.end(); 396 418 ++it ) { 397 if(!(*it)->setPortBuffersize(m_period)) { 398 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not set buffer size...\n"); 399 return false; 419 if(!(*it)->setPortBuffersize(m_period)) { 420 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not set buffer size (%p)...\n",(*it)); 421 return false; 422 423 } 424 if(!(*it)->prepare()) { 425 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not prepare (%p)...\n",(*it)); 426 return false; 427 428 } 429 } 430 431 debugOutputShort( DEBUG_LEVEL_NORMAL, " Transmit processors...\n"); 432 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 433 it != m_TransmitProcessors.end(); 434 ++it ) { 435 if(!(*it)->setPortBuffersize(m_period)) { 436 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not set buffer size (%p)...\n",(*it)); 437 return false; 400 438 401 } 402 } 403 404 debugOutputShort( DEBUG_LEVEL_NORMAL, " Transmit processors...\n"); 405 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 406 it != m_TransmitProcessors.end(); 407 ++it ) { 408 if(!(*it)->setPortBuffersize(m_period)) { 409 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not set buffer size...\n"); 410 return false; 439 } 440 if(!(*it)->prepare()) { 441 debugOutputShort( DEBUG_LEVEL_NORMAL, " could not prepare (%p)...\n",(*it)); 442 return false; 411 443 412 }413 }444 } 445 } 414 446 415 447 return true; branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.h
r221 r223 34 34 #include "Port.h" 35 35 #include "StreamProcessor.h" 36 #include "IsoHandlerManager.h" 36 37 37 38 #include <vector> … … 86 87 void reset(); // reset the streams & buffers (e.g. after xrun) 87 88 89 int registerStreamProcessors(IsoHandlerManager *m); 90 91 88 92 // the ISO-side functions 89 93 protected: