| 526 | //----------------------------------------------------------------------------- |
| 527 | |
| 528 | SFXSource* SFXSystem::createSource( SFXTrack* track, |
| 529 | const MatrixF* transform, |
| 530 | const VectorF* velocity ) |
| 531 | { |
| 532 | if( !track ) |
| 533 | return NULL; |
| 534 | |
| 535 | SFXSource* source = NULL; |
| 536 | |
| 537 | // Try creating through a plugin first so that they |
| 538 | // always get the first shot and may override our |
| 539 | // logic here. |
| 540 | |
| 541 | for( U32 i = 0; !source && i < mPlugins.size(); ++ i ) |
| 542 | source = mPlugins[ i ]->createSource( track ); |
| 543 | |
| 544 | // If that failed, try our own logic using the track |
| 545 | // types that we know about. |
| 546 | |
| 547 | if( !source ) |
| 548 | { |
| 549 | if( !mDevice ) |
| 550 | { |
| 551 | Con::errorf( "SFXSystem::createSource() - no device initialized!" ); |
| 552 | return NULL; |
| 553 | } |
| 554 | |
| 555 | if( dynamic_cast< SFXPlayList* >( track ) ) |
| 556 | { |
| 557 | // Create a playback controller for the track. |
| 558 | |
| 559 | SFXPlayList* playList = static_cast< SFXPlayList* >( track ); |
| 560 | source = SFXController::_create( playList ); |
| 561 | } |
| 562 | else if( dynamic_cast< SFXProfile* >( track ) ) |
| 563 | { |
| 564 | // Create a sound. |
| 565 | |
| 566 | SFXProfile* profile = static_cast< SFXProfile* >( track ); |
| 567 | source = SFXSound::_create( mDevice, profile ); |
| 568 | if( !source ) |
| 569 | { |
| 570 | Con::errorf( |
| 571 | "SFXSystem::createSource() - Failed to create sound!\n" |
| 572 | " Profile: %s\n" |
| 573 | " Filename: %s", |
| 574 | profile->getName(), |
| 575 | profile->getSoundFileName().c_str() ); |
| 576 | } |
| 577 | } |
| 578 | else |
| 579 | { |
| 580 | Con::errorf( "SFXSystem::createSource - cannot create source for %i (%s) of type '%s'", |
| 581 | track->getId(), track->getName(), track->getClassName() ); |
| 582 | Con::errorf( "SFXSystem::createSource - maybe you are using the wrong SFX provider for this type of track" ); |
| 583 | return NULL; |
| 584 | } |
| 585 | } |
no test coverage detected