Logo Search packages:      
Sourcecode: scummvm version File versions

AudioStream * Audio::AudioStream::openStreamFile ( const Common::String basename,
uint32  startTime = 0,
uint32  duration = 0,
uint  numLoops = 1 
) [static, inherited]

Tries to load a file by trying all available formats. In case of an error, the file handle will be closed, but deleting it is still the responsibilty of the caller.

basename a filename without an extension
startTime the (optional) time offset in milliseconds from which to start playback
duration the (optional) time in milliseconds specifying how long to play
numLoops how often the data shall be looped (0 = infinite)
an Audiostream ready to use in case of success; NULL in case of an error (e.g. invalid/nonexisting file)

Definition at line 77 of file audiostream.cpp.

References Common::String::c_str(), Common::File::isOpen(), and Common::File::open().

      AudioStream* stream = NULL;
      Common::File *fileHandle = new Common::File();

      for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS)-1 && stream == NULL; ++i) {
            Common::String filename = basename + STREAM_FILEFORMATS[i].fileExtension;
            if (fileHandle->isOpen()) {
                  // Create the stream object
                  stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, true, startTime, duration, numLoops);
                  fileHandle = 0;

      delete fileHandle;

      if (stream == NULL) {
            debug(1, "AudioStream: Could not open compressed AudioFile %s", basename.c_str());

      return stream;

Generated by  Doxygen 1.6.0   Back to index