lazy init cues

Change-Id: I20e923bcc4be0dd607fb66a63c4f94b96854573e
This commit is contained in:
matthewjheaney 2010-10-08 19:35:32 -04:00
parent 77f61bdd68
commit 9105d61514
2 changed files with 35 additions and 28 deletions

View File

@ -1018,7 +1018,7 @@ long long Segment::ParseHeaders()
assert(m_pos <= stop);
if (m_pInfo == NULL)
if (m_pInfo == NULL) //TODO: liberalize this behavior
return E_FILE_FORMAT_INVALID;
if (m_pTracks == NULL)
@ -1718,8 +1718,35 @@ Cues::Cues(Segment* pSegment, long long start_, long long size_) :
m_preload_count(0),
m_pos(start_)
{
//odbgstream os;
//os << "Cues: ctor (begin)" << endl;
}
Cues::~Cues()
{
const size_t n = m_count + m_preload_count;
CuePoint** p = m_cue_points;
CuePoint** const q = p + n;
while (p != q)
{
CuePoint* const pCP = *p++;
assert(pCP);
delete pCP;
}
delete[] m_cue_points;
}
void Cues::Init()
{
if (m_cue_points)
return;
assert(m_count == 0);
assert(m_preload_count == 0);
IMkvReader* const pReader = m_pSegment->m_pReader;
@ -1754,35 +1781,10 @@ Cues::Cues(Segment* pSegment, long long start_, long long size_) :
assert(pos <= stop);
}
//os << "Cues: ctor (end): preload_count="
// << m_preload_count
// << " cue_points_size="
// << cue_points_size
// << endl;
LoadCuePoint();
}
Cues::~Cues()
{
const size_t n = m_count + m_preload_count;
CuePoint** p = m_cue_points;
CuePoint** const q = p + n;
while (p != q)
{
CuePoint* const pCP = *p++;
assert(pCP);
delete pCP;
}
delete[] m_cue_points;
}
void Cues::PreloadCuePoint(
size_t& cue_points_size,
long long pos)
@ -1875,6 +1877,8 @@ bool Cues::LoadCuePoint()
if (m_pos >= stop)
return false; //nothing else to do
Init();
IMkvReader* const pReader = m_pSegment->m_pReader;
while (m_pos < stop)
@ -1935,6 +1939,8 @@ bool Cues::Find(
assert(time_ns >= 0);
assert(pTrack);
const_cast<Cues*>(this)->Init();
assert(m_cue_points);
assert(m_count > 0);

View File

@ -415,6 +415,7 @@ public:
#endif
private:
void Init();
void PreloadCuePoint(size_t&, long long);
CuePoint** m_cue_points;