SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Common::Timestamp start, const Common::Timestamp end, DisposeAfterUse::Flag disposeAfterUse) : _parent(parent, disposeAfterUse), _start(convertTimeToStreamPos(start, getRate(), getChannels())), _pos(0, getRate() * getChannels()), _length(convertTimeToStreamPos(end, getRate(), getChannels()) - _start) { assert(_length.totalNumberOfFrames() % getChannels() == 0); _parent->seek(_start); }
SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse) : _parent(parent), _disposeAfterUse(disposeAfterUse), _start(convertTimeToStreamPos(start, getRate(), isStereo())), _pos(0, getRate() * (isStereo() ? 2 : 1)), _length(convertTimeToStreamPos(end - start, getRate(), isStereo())) { assert(_length.totalNumberOfFrames() % (isStereo() ? 2 : 1) == 0); _parent->seek(_start); }
SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _pos(0, getRate() * (isStereo() ? 2 : 1)), _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), _done(false) { assert(loopStart < loopEnd); if (!_parent->rewind()) _done = true; }
EMISubLoopingAudioStream(Audio::SeekableAudioStream *stream, uint loops, const Audio::Timestamp start, const Audio::Timestamp loopStart, const Audio::Timestamp loopEnd, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) : _parent(stream, disposeAfterUse), _pos(convertTimeToStreamPos(start, getRate(), isStereo())), _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), _done(false), _hasLooped(false) { assert(loopStart < loopEnd); if (!_parent->seek(_pos)) _done = true; }
bool FLACStream::seek(const Timestamp &where) { _sampleCache.bufFill = 0; _sampleCache.bufReadPos = NULL; // FLAC uses the sample pair number, thus we always use "false" for the isStereo parameter // of the convertTimeToStreamPos helper. return seekAbsolute((FLAC__uint64)convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames()); }
bool VorbisStream::seek(const Timestamp &where) { // Vorbisfile uses the sample pair number, thus we always use "false" for the isStereo parameter // of the convertTimeToStreamPos helper. int res = ov_pcm_seek(&_ovFile, convertTimeToStreamPos(where, getRate(), false).totalNumberOfFrames()); if (res) { warning("Error seeking in Vorbis stream (%d)", res); _pos = _bufferEnd; return false; } return refill(); }
bool SubSeekableAudioStream::seek(const Timestamp &where) { _pos = convertTimeToStreamPos(where, getRate(), isStereo()); if (_pos > _length) { _pos = _length; return false; } if (_parent->seek(_pos + _start)) { return true; } else { _pos = _length; return false; } }
bool RawStream<is16Bit, isUnsigned, isLE>::seek(const Timestamp &where) { _endOfData = true; if (where > _playtime) return false; const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames(); _stream->seek(seekSample * (is16Bit ? 2 : 1), SEEK_SET); // In case of an error we will not continue stream playback. if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size()) _endOfData = false; return true; }