bool Mp3PspStream::seek(const Timestamp &where) { DEBUG_ENTER_FUNC(); if (where == _length) { _state = MP3_STATE_EOS; return true; } else if (where > _length) { return false; } const uint32 time = where.msecs(); mad_timer_t destination; mad_timer_set(&destination, time / 1000, time % 1000, 1000); // Important to release and re-init the ME releaseStreamME(); initStreamME(); // Check if we need to rewind if (_state != MP3_STATE_READY || mad_timer_compare(destination, _totalTime) < 0) { initStream(); } // Skip ahead while (mad_timer_compare(destination, _totalTime) > 0 && _state != MP3_STATE_EOS) findValidHeader(); return (_state != MP3_STATE_EOS); }
bool MP3Stream::seek(const Timestamp &where) { if (where == _length) { _state = MP3_STATE_EOS; return true; } else if (where > _length) { return false; } const uint32 time = where.msecs(); mad_timer_t destination; mad_timer_set(&destination, time / 1000, time % 1000, 1000); if (_state != MP3_STATE_READY || mad_timer_compare(destination, _totalTime) < 0) initStream(); while (mad_timer_compare(destination, _totalTime) > 0 && _state != MP3_STATE_EOS) readHeader(); decodeMP3Data(); return (_state != MP3_STATE_EOS); }
int Timestamp::msecsDiff(const Timestamp &ts) const { return msecs() - ts.msecs(); }