| 114 | } |
| 115 | |
| 116 | SoundFileReader* SoundFileFactory::createReaderFromStream( IOStream& stream ) { |
| 117 | // Register the built-in readers/writers on first call |
| 118 | ensureDefaultReadersWritersRegistered(); |
| 119 | |
| 120 | // Test the stream for all the registered factories |
| 121 | for ( ReaderFactoryArray::const_iterator it = s_readers.begin(); it != s_readers.end(); ++it ) { |
| 122 | stream.seek( 0 ); |
| 123 | if ( it->check( stream ) ) |
| 124 | return it->create(); |
| 125 | } |
| 126 | |
| 127 | // No suitable reader found |
| 128 | Log::error( "Failed to open sound file from stream (format not supported)" ); |
| 129 | return NULL; |
| 130 | } |
| 131 | |
| 132 | SoundFileWriter* SoundFileFactory::createWriterFromFilename( const std::string& filename ) { |
| 133 | // Register the built-in readers/writers on first call |