From 547934cbbd4b41e377ed35e3b4367c5285c7219b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 12 Jan 2010 20:25:59 +0000 Subject: [PATCH] Reverted some of my changes with regards to fCurrentTime and added respective TODOs. For now, it is easier for applications to work around the status quo until the TODOs are implemented. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35032 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/media/MediaTrack.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/kits/media/MediaTrack.cpp b/src/kits/media/MediaTrack.cpp index 85c6db57cc..c146a6884c 100644 --- a/src/kits/media/MediaTrack.cpp +++ b/src/kits/media/MediaTrack.cpp @@ -313,8 +313,12 @@ BMediaTrack::ReadFrames(void* buffer, int64* _frameCount, result = fDecoder->Decode(buffer, _frameCount, _header, info); if (result == B_OK) { fCurrentFrame += *_frameCount; - fCurrentTime = _header->start_time - + *_frameCount * 1000000LL / _FrameRate(); + // TODO: This changes the meaning of fCurrentTime from pointing + // to the next chunk start time (i.e. after seeking) to the start time + // of the last chunk. Asking the extractor for the current time will + // not work so well because of the chunk cache. But providing a + // "duration" field in the media_header could be useful. + fCurrentTime = fCurrentTime = _header->start_time; } else { ERROR("BMediaTrack::ReadFrames: decoder returned error 0x%08lx (%s)\n", result, strerror(result)); @@ -520,13 +524,14 @@ BMediaTrack::ReadChunk(char** _buffer, int32* _size, media_header* _header) *_buffer = const_cast(static_cast(buffer)); // TODO: Change the pointer type when we break the API. *_size = size; - // Several chunks may belong to the same frame. If the start time is - // different from the previous chunk's time, the next chunk will belong - // to the next frame. - if (fCurrentTime != _header->start_time) { - fCurrentFrame++; - fCurrentTime = _header->start_time + 1000000LL / _FrameRate(); - } + // TODO: This changes the meaning of fCurrentTime from pointing + // to the next chunk start time (i.e. after seeking) to the start time + // of the last chunk. Asking the extractor for the current time will + // not work so well because of the chunk cache. But providing a + // "duration" field in the media_header could be useful. + fCurrentTime = fCurrentTime = _header->start_time; + fCurrentFrame = fCurrentTime * _FrameRate() / 1000000LL; + } return result;