Changeset 777
- Timestamp:
- 12/26/07 13:59:21 (16 years ago)
- Files:
-
- trunk/libffado/SConstruct (modified) (1 diff)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (1 diff)
- trunk/libffado/src/devicemanager.cpp (modified) (13 diffs)
- trunk/libffado/src/devicemanager.h (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (3 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (5 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/SConstruct
r774 r777 285 285 opt_flags.append ("-march=i686") 286 286 287 if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) and build_host_supports_sse: 287 if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \ 288 and build_host_supports_sse and env['ENABLE_OPTIMIZATIONS']: 288 289 opt_flags.extend (["-msse", "-mfpmath=sse"]) 289 290 env['USE_SSE'] = 1 trunk/libffado/src/debugmodule/debugmodule.h
r776 r777 53 53 #define MB_BUFFERSIZE DEBUG_MAX_MESSAGE_LENGTH 54 54 55 #define IMPLEMENT_BACKLOG 55 #ifdef DEBUG 56 #define IMPLEMENT_BACKLOG 57 #endif 58 56 59 #ifdef IMPLEMENT_BACKLOG 57 60 // the backlog is a similar buffer as the message buffer trunk/libffado/src/devicemanager.cpp
r750 r777 81 81 DeviceManager::DeviceManager() 82 82 : Control::Container("devicemanager") 83 , m_processorManager( new Streaming::StreamProcessorManager() ) 83 84 { 84 85 addOption(Util::OptionContainer::Option("slaveMode",false)); … … 88 89 DeviceManager::~DeviceManager() 89 90 { 91 delete m_processorManager; 92 90 93 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 91 94 it != m_avDevices.end(); … … 98 101 } 99 102 103 for ( FunctorVectorIterator it = m_busreset_functors.begin(); 104 it != m_busreset_functors.end(); 105 ++it ) 106 { 107 delete *it; 108 } 109 100 110 for ( Ieee1394ServiceVectorIterator it = m_1394Services.begin(); 101 111 it != m_1394Services.end(); … … 104 114 delete *it; 105 115 } 106 for ( FunctorVectorIterator it = m_busreset_functors.begin();107 it != m_busreset_functors.end();108 ++it )109 {110 delete *it;111 }112 116 } 113 117 114 118 bool 115 119 DeviceManager::setThreadParameters(bool rt, int priority) { 116 if (!m_processorManager .setThreadParameters(rt, priority)) {120 if (!m_processorManager->setThreadParameters(rt, priority)) { 117 121 debugError("Could not set processor manager thread parameters\n"); 118 122 return false; … … 419 423 420 424 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 421 m_processorManager .getNominalRate(), device);425 m_processorManager->getNominalRate(), device); 422 426 423 427 // Set the device's sampling rate to that requested 424 428 // FIXME: does this really belong here? If so we need to handle errors. 425 if (!device->setSamplingFrequency(m_processorManager .getNominalRate())) {429 if (!device->setSamplingFrequency(m_processorManager->getNominalRate())) { 426 430 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 427 m_processorManager .getNominalRate(), device);431 m_processorManager->getNominalRate(), device); 428 432 429 433 // try again: 430 if (!device->setSamplingFrequency(m_processorManager .getNominalRate())) {431 debugFatal("Could not set sampling frequency to %d\n",m_processorManager .getNominalRate());434 if (!device->setSamplingFrequency(m_processorManager->getNominalRate())) { 435 debugFatal("Could not set sampling frequency to %d\n",m_processorManager->getNominalRate()); 432 436 return false; 433 437 } … … 438 442 439 443 // set the sync source 440 if (!m_processorManager .setSyncSource(getSyncSource())) {444 if (!m_processorManager->setSyncSource(getSyncSource())) { 441 445 debugWarning("Could not set processorManager sync source (%p)\n", 442 446 getSyncSource()); … … 448 452 DeviceManager::prepareStreaming() 449 453 { 450 if (!m_processorManager .prepare()) {454 if (!m_processorManager->prepare()) { 451 455 debugFatal("Could not prepare streaming...\n"); 452 456 return false; … … 500 504 } 501 505 502 if(m_processorManager .start()) {506 if(m_processorManager->start()) { 503 507 return true; 504 508 } else { … … 517 521 { 518 522 bool result = true; 519 m_processorManager .stop();523 m_processorManager->stop(); 520 524 521 525 // create the connections for all devices … … 550 554 bool 551 555 DeviceManager::waitForPeriod() { 552 if(m_processorManager .waitForPeriod()) {556 if(m_processorManager->waitForPeriod()) { 553 557 return true; 554 558 } else { 555 559 debugWarning("XRUN detected\n"); 556 560 // do xrun recovery 557 m_processorManager .handleXrun();561 m_processorManager->handleXrun(); 558 562 return false; 559 563 } … … 562 566 bool 563 567 DeviceManager::setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers) { 564 m_processorManager .setPeriodSize(period);565 m_processorManager .setNominalRate(rate);566 m_processorManager .setNbBuffers(nb_buffers);568 m_processorManager->setPeriodSize(period); 569 m_processorManager->setNominalRate(rate); 570 m_processorManager->setNbBuffers(nb_buffers); 567 571 return true; 568 572 } … … 756 760 setDebugLevel(l); 757 761 Control::Element::setVerboseLevel(l); 758 m_processorManager .setVerboseLevel(l);762 m_processorManager->setVerboseLevel(l); 759 763 for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 760 764 it != m_avDevices.end(); … … 810 814 void 811 815 DeviceManager::showStreamingInfo() { 812 m_processorManager .dumpInfo();813 } 816 m_processorManager->dumpInfo(); 817 } trunk/libffado/src/devicemanager.h
r750 r777 117 117 public: // FIXME: this should be better 118 118 Streaming::StreamProcessorManager& getStreamProcessorManager() 119 {return m_processorManager;};119 {return *m_processorManager;}; 120 120 private: 121 Streaming::StreamProcessorManager m_processorManager;121 Streaming::StreamProcessorManager* m_processorManager; 122 122 protected: 123 123 std::vector<std::string> m_SpecStrings; trunk/libffado/src/libieee1394/ieee1394service.cpp
r754 r777 102 102 delete m_pCTRHelper; 103 103 delete m_pIsoManager; 104 delete m_pTimeSource;105 104 stopRHThread(); 106 105 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); … … 116 115 } 117 116 117 delete m_pTimeSource; 118 118 if ( m_handle ) { 119 119 raw1394_destroy_handle( m_handle ); … … 352 352 uint64_t 353 353 Ieee1394Service::getCurrentTimeAsUsecs() { 354 assert(m_pTimeSource); 355 return m_pTimeSource->getCurrentTimeAsUsecs(); 354 if(m_pTimeSource) { 355 return m_pTimeSource->getCurrentTimeAsUsecs(); 356 } else { 357 debugError("No timesource!\n"); 358 return 0; 359 } 356 360 } 357 361 trunk/libffado/src/libieee1394/IsoHandler.cpp
r776 r777 217 217 poll_exit-poll_enter, iter_exit-iter_enter); 218 218 #else 219 // iterate itself blocks if nothingis available219 // iterate blocks if no 1394 data is available 220 220 // so poll'ing is not really necessary 221 221 bool result = iterate(); trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r766 r777 21 21 * 22 22 */ 23 #include "config.h" 23 24 24 25 #include "AmdtpReceiveStreamProcessor.h" … … 250 251 } 251 252 253 #ifdef USE_SSE 254 typedef float v4sf __attribute__ ((vector_size (16))); 255 typedef int v4si __attribute__ ((vector_size (16))); 256 typedef int v2si __attribute__ ((vector_size (8))); 257 252 258 int 253 259 AmdtpReceiveStreamProcessor::decodeMBLAEventsToPort( … … 260 266 target_event=(quadlet_t *)(data + p->getPosition()); 261 267 268 static const float multiplier = 1.0f / (float)(0x7FFFFF); 269 static const float sse_multiplier[4] __attribute__((aligned(16))) = { 270 1.0f / (float)(0x7FFFFF), 271 1.0f / (float)(0x7FFFFF), 272 1.0f / (float)(0x7FFFFF), 273 1.0f / (float)(0x7FFFFF) 274 }; 275 unsigned int tmp[4]; 276 262 277 switch(p->getDataType()) { 263 278 default: … … 279 294 case Port::E_Float: 280 295 { 281 const float multiplier = 1.0f / (float)(0x7FFFFF);282 296 float *buffer=(float *)(p->getBufferAddress()); 283 297 284 298 assert(nevents + offset <= p->getBufferSize()); 285 299 286 buffer+=offset; 287 288 for(j = 0; j < nevents; j += 1) { // decode max nsamples 289 300 buffer += offset; 301 j = 0; 302 if(nevents > 3) { 303 for(j = 0; j < nevents-3; j += 4) { 304 tmp[0] = ntohl(*target_event); 305 target_event += m_dimension; 306 tmp[1] = ntohl(*target_event); 307 target_event += m_dimension; 308 tmp[2] = ntohl(*target_event); 309 target_event += m_dimension; 310 tmp[3] = ntohl(*target_event); 311 target_event += m_dimension; 312 asm("pslld $8, %[in2]\n\t" // sign extend 24th bit 313 "pslld $8, %[in1]\n\t" 314 "psrad $8, %[in2]\n\t" 315 "psrad $8, %[in1]\n\t" 316 "cvtpi2ps %[in2], %%xmm0\n\t" 317 "movlhps %%xmm0, %%xmm0\n\t" 318 "cvtpi2ps %[in1], %%xmm0\n\t" 319 "mulps %[ssemult], %%xmm0\n\t" 320 "movups %%xmm0, %[floatbuff]" 321 : [floatbuff] "=m" (*(v4sf*)buffer) 322 : [in1] "y" (*(v2si*)tmp), 323 [in2] "y" (*(v2si*)(tmp+2)), 324 [ssemult] "x" (*(v4sf*)sse_multiplier) 325 : "xmm0"); 326 buffer += 4; 327 } 328 } 329 for(; j < nevents; ++j) { // decode max nsamples 290 330 unsigned int v = ntohl(*target_event) & 0x00FFFFFF; 291 331 // sign-extend highest bit of 24-bit int 292 332 int tmp = (int)(v << 8) / 256; 293 294 333 *buffer = tmp * multiplier; 295 334 335 buffer++; 336 target_event += m_dimension; 337 } 338 asm volatile("emms"); 339 break; 340 } 341 break; 342 } 343 344 return 0; 345 } 346 347 #else 348 349 int 350 AmdtpReceiveStreamProcessor::decodeMBLAEventsToPort( 351 AmdtpAudioPort *p, quadlet_t *data, 352 unsigned int offset, unsigned int nevents) 353 { 354 unsigned int j=0; 355 quadlet_t *target_event; 356 357 target_event=(quadlet_t *)(data + p->getPosition()); 358 359 switch(p->getDataType()) { 360 default: 361 case Port::E_Int24: 362 { 363 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 364 365 assert(nevents + offset <= p->getBufferSize()); 366 367 buffer+=offset; 368 369 for(j = 0; j < nevents; j += 1) { // decode max nsamples 370 *(buffer)=(ntohl((*target_event) ) & 0x00FFFFFF); 296 371 buffer++; 297 372 target_event+=m_dimension; … … 299 374 } 300 375 break; 376 case Port::E_Float: 377 { 378 const float multiplier = 1.0f / (float)(0x7FFFFF); 379 float *buffer=(float *)(p->getBufferAddress()); 380 381 assert(nevents + offset <= p->getBufferSize()); 382 383 buffer+=offset; 384 385 for(j = 0; j < nevents; j += 1) { // decode max nsamples 386 387 unsigned int v = ntohl(*target_event) & 0x00FFFFFF; 388 // sign-extend highest bit of 24-bit int 389 int tmp = (int)(v << 8) / 256; 390 391 *buffer = tmp * multiplier; 392 393 buffer++; 394 target_event+=m_dimension; 395 } 396 } 397 break; 301 398 } 302 399 303 400 return 0; 304 401 } 402 #endif 305 403 } // end of namespace Streaming trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r776 r777 22 22 */ 23 23 24 #include "config.h" 24 25 #include "AmdtpTransmitStreamProcessor.h" 25 26 #include "AmdtpPort.h" … … 99 100 const int max_cycles_to_transmit_early = 2; 100 101 101 try_block_of_frames:102 102 debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "Try for cycle %d\n", cycle ); 103 103 // check whether the packet buffer has packets for us to send. … … 591 591 } 592 592 593 #ifdef USE_SSE 594 typedef float v4sf __attribute__ ((vector_size (16))); 595 typedef int v4si __attribute__ ((vector_size (16))); 596 typedef int v2si __attribute__ ((vector_size (8))); 597 598 int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents ( AmdtpAudioPort *p, quadlet_t *data, 599 unsigned int offset, unsigned int nevents ) 600 { 601 static const float sse_multiplier[4] __attribute__((aligned(16))) = { 602 (float)(0x7FFFFF00), 603 (float)(0x7FFFFF00), 604 (float)(0x7FFFFF00), 605 (float)(0x7FFFFF00) 606 }; 607 608 static const int sse_mask[4] __attribute__((aligned(16))) = { 609 0x40000000, 0x40000000, 0x40000000, 0x40000000 610 }; 611 612 unsigned int out[4]; 613 614 unsigned int j=0; 615 unsigned int read=0; 616 617 quadlet_t *target_event; 618 619 target_event= ( quadlet_t * ) ( data + p->getPosition() ); 620 621 switch ( p->getDataType() ) 622 { 623 default: 624 case Port::E_Int24: 625 { 626 quadlet_t *buffer= ( quadlet_t * ) ( p->getBufferAddress() ); 627 628 assert ( nevents + offset <= p->getBufferSize() ); 629 630 buffer+=offset; 631 632 for ( j = 0; j < nevents; j += 1 ) // decode max nsamples 633 { 634 *target_event = htonl ( ( * ( buffer ) & 0x00FFFFFF ) | 0x40000000 ); 635 buffer++; 636 target_event += m_dimension; 637 } 638 } 639 break; 640 case Port::E_Float: 641 { 642 const float multiplier = ( float ) ( 0x7FFFFF00 ); 643 float *buffer= ( float * ) ( p->getBufferAddress() ); 644 645 assert ( nevents + offset <= p->getBufferSize() ); 646 647 buffer+=offset; 648 649 j=0; 650 if(read>3) { 651 for (j = 0; j < read-3; j += 4) { 652 asm("movups %[floatbuff], %%xmm0\n\t" 653 "mulps %[ssemult], %%xmm0\n\t" 654 "cvttps2pi %%xmm0, %[out1]\n\t" 655 "movhlps %%xmm0, %%xmm0\n\t" 656 "psrld $8, %[out1]\n\t" 657 "cvttps2pi %%xmm0, %[out2]\n\t" 658 "por %[mmxmask], %[out1]\n\t" 659 "psrld $8, %[out2]\n\t" 660 "por %[mmxmask], %[out2]\n\t" 661 : [out1] "=&y" (*(v2si*)&out[0]), 662 [out2] "=&y" (*(v2si*)&out[2]) 663 : [floatbuff] "m" (*(v4sf*)buffer), 664 [ssemult] "x" (*(v4sf*)sse_multiplier), 665 [mmxmask] "y" (*(v2si*)sse_mask) 666 : "xmm0"); 667 buffer += 4; 668 *target_event = htonl(out[0]); 669 target_event += m_dimension; 670 *target_event = htonl(out[1]); 671 target_event += m_dimension; 672 *target_event = htonl(out[2]); 673 target_event += m_dimension; 674 *target_event = htonl(out[3]); 675 target_event += m_dimension; 676 } 677 } 678 for(; j < read; ++j) { 679 // don't care for overflow 680 float v = *buffer * multiplier; // v: -231 .. 231 681 unsigned int tmp = (int)v; 682 *target_event = htonl((tmp >> 8) | 0x40000000); 683 684 buffer++; 685 target_event += m_dimension; 686 } 687 688 asm volatile("emms"); 689 break; 690 } 691 break; 692 } 693 694 return 0; 695 } 696 697 #else 593 698 594 699 int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents ( AmdtpAudioPort *p, quadlet_t *data, … … 646 751 return 0; 647 752 } 753 #endif 754 648 755 int AmdtpTransmitStreamProcessor::encodeSilencePortToMBLAEvents ( AmdtpAudioPort *p, quadlet_t *data, 649 756 unsigned int offset, unsigned int nevents )