|
From: th3pr0ph3t <th3...@us...> - 2011-05-25 17:10:21
|
Author: Juan Montoya <juan@storm.(none)>
Date: Wed May 25 09:31:02 2011 -0500
Revert "More precise timecode handling and more tolerance before seeking (workaround for infinite seekloops)."
This reverts commit c0e78b1f19ed2b25c3c37d4cf610939ef33abcab.
---
game/ffmpeg.cc | 5 ++---
game/ffmpeg.hh | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/game/ffmpeg.cc b/game/ffmpeg.cc
index e565a04..1be7d7f 100644
--- a/game/ffmpeg.cc
+++ b/game/ffmpeg.cc
@@ -280,12 +280,11 @@ void FFmpeg::decodeNextFrame() {
std::vector<int16_t> resampled(AVCODEC_MAX_AUDIO_FRAME_SIZE);
int frames = audio_resample(pResampleCtx, &resampled[0], audioFrames, outsize);
resampled.resize(frames * AUDIO_CHANNELS);
- // Use timecode from packet if available
+ // Calculate new positions
if (packet.time() == packet.time()) m_position = packet.time();
+ else m_position += double(resampled.size())/double(audioQueue.getSamplesPerSecond());
// Push to output queue (may block)
audioQueue.push(resampled, m_position);
- // Increment current time
- m_position += double(resampled.size())/double(audioQueue.getSamplesPerSecond());
}
// Audio frames are always finished
frameFinished = 1;
diff --git a/game/ffmpeg.hh b/game/ffmpeg.hh
index a94a8b0..8006df8 100644
--- a/game/ffmpeg.hh
+++ b/game/ffmpeg.hh
@@ -162,7 +162,7 @@ class AudioBuffer {
void setDuration(double seconds) { m_duration = seconds; }
bool wantSeek() {
size_t oldest = m_pos - m_data.size();
- return m_posReq + int64_t(m_sps) * 2.0 /* seconds tolerance */ < int64_t(oldest);
+ return oldest > 0 && m_posReq < int64_t(oldest);
}
private:
bool wantMore() { return int64_t(m_pos) - int64_t(m_data.capacity() / 2) < m_posReq; }
|