perfect replay

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6276 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2004-01-25 11:55:27 +00:00
parent 170d6e3fbc
commit a511a51332
3 changed files with 37 additions and 3 deletions
@@ -8,6 +8,12 @@ OggFrameInfo::OggFrameInfo(uint page, uint packetonpage, uint packet)
this->packet = packet; this->packet = packet;
} }
void
OggFrameInfo::SetNext(uint page, uint packetonpage, uint packet)
{
nextpage = page;
nextpacketonpage = packetonpage;
}
/* virtual */ /* virtual */
OggFrameInfo::~OggFrameInfo() OggFrameInfo::~OggFrameInfo()
@@ -31,3 +37,21 @@ OggFrameInfo::GetPacket() const
{ {
return packet; return packet;
} }
uint
OggFrameInfo::GetNextPage() const
{
return nextpage;
}
uint
OggFrameInfo::GetNextPacketOnPage() const
{
return nextpacketonpage;
}
uint
OggFrameInfo::GetNextPacket() const
{
return packet+1;
}
@@ -7,14 +7,21 @@ class OggFrameInfo {
public: public:
OggFrameInfo(uint page, uint packetonpage, uint packet); OggFrameInfo(uint page, uint packetonpage, uint packet);
virtual ~OggFrameInfo(); virtual ~OggFrameInfo();
void SetNext(uint page, uint packetonpage, uint packet);
uint GetPage() const; uint GetPage() const;
uint GetPacketOnPage() const; uint GetPacketOnPage() const;
uint GetPacket() const; uint GetPacket() const;
uint GetNextPage() const;
uint GetNextPacketOnPage() const;
uint GetNextPacket() const;
private: private:
uint page; // the page the frame started on uint page; // the page the frame started on
uint packetonpage; // of all the packets on that page which packet is this uint packetonpage; // of all the packets on that page which packet is this
uint packet; // the packet the frame started on uint packet; // the packet the frame started on
uint nextpage; // the next page after this page
uint nextpacketonpage; // of all the packets on next page which packet is the next
uint nextpacket; // the next packet after this packet
}; };
#endif _OGG_FRAME_INFO_H #endif _OGG_FRAME_INFO_H
+6 -3
View File
@@ -200,9 +200,9 @@ OggStream::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
fSeekStreamState = seekStreamState; fSeekStreamState = seekStreamState;
// we notably do not clear our temporary stream // we notably do not clear our temporary stream
// instead we just let it go out of scope // instead we just let it go out of scope
fCurrentPage = fOggFrameInfos[*frame].GetPage(); fCurrentPage = fOggFrameInfos[*frame].GetNextPage();
fPacketOnCurrentPage = fOggFrameInfos[*frame].GetPacketOnPage(); fPacketOnCurrentPage = fOggFrameInfos[*frame].GetNextPacketOnPage();
fCurrentPacket = fOggFrameInfos[*frame].GetPacket(); fCurrentPacket = fOggFrameInfos[*frame].GetNextPacket();
} else if (seekTo & B_MEDIA_SEEK_TO_TIME) { } else if (seekTo & B_MEDIA_SEEK_TO_TIME) {
*frame = *time/50000; *frame = *time/50000;
return Seek(B_MEDIA_SEEK_TO_FRAME,frame,time); return Seek(B_MEDIA_SEEK_TO_FRAME,frame,time);
@@ -221,6 +221,9 @@ OggStream::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
fOggFrameInfos.push_back(info); fOggFrameInfos.push_back(info);
} }
status_t result = GetPacket(&packet); status_t result = GetPacket(&packet);
if (fCurrentPacket - fHeaderPackets.size() == fOggFrameInfos.size()) {
fOggFrameInfos[fOggFrameInfos.size()-1].SetNext(fEndPage,fPacketOnEndPage,fEndPacket);
}
if (result != B_OK) { if (result != B_OK) {
TRACE("OggStream::GetNextChunk failed: GetPacket = %s\n", strerror(result)); TRACE("OggStream::GetNextChunk failed: GetPacket = %s\n", strerror(result));
return result; return result;