decoder/OggUtil: add OggExpectFirstPage() and OggExpectPageIn()
This commit is contained in:
parent
a6301d45f4
commit
9fb5aad157
@ -51,3 +51,28 @@ OggExpectPage(ogg_sync_state &oy, ogg_page &page,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
|
||||
decoder *decoder, input_stream *is)
|
||||
{
|
||||
ogg_page page;
|
||||
if (!OggExpectPage(oy, page, decoder, is))
|
||||
return false;
|
||||
|
||||
ogg_stream_init(&os, ogg_page_serialno(&page));
|
||||
ogg_stream_pagein(&os, &page);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
|
||||
decoder *decoder, input_stream *is)
|
||||
{
|
||||
ogg_page page;
|
||||
if (!OggExpectPage(oy, page, decoder, is))
|
||||
return false;
|
||||
|
||||
ogg_stream_pagein(&os, &page);
|
||||
return true;
|
||||
}
|
||||
|
@ -48,4 +48,24 @@ bool
|
||||
OggExpectPage(ogg_sync_state &oy, ogg_page &page,
|
||||
decoder *decoder, input_stream *input_stream);
|
||||
|
||||
/**
|
||||
* Combines OggExpectPage(), ogg_stream_init() and
|
||||
* ogg_stream_pagein().
|
||||
*
|
||||
* @return true if the stream was initialized and the first page was
|
||||
* delivered to it
|
||||
*/
|
||||
bool
|
||||
OggExpectFirstPage(ogg_sync_state &oy, ogg_stream_state &os,
|
||||
decoder *decoder, input_stream *is);
|
||||
|
||||
/**
|
||||
* Combines OggExpectPage() and ogg_stream_pagein().
|
||||
*
|
||||
* @return true if a page was delivered to the stream
|
||||
*/
|
||||
bool
|
||||
OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os,
|
||||
decoder *decoder, input_stream *is);
|
||||
|
||||
#endif
|
||||
|
@ -269,8 +269,8 @@ mpd_opus_scan_stream(struct input_stream *is,
|
||||
ogg_sync_state oy;
|
||||
ogg_sync_init(&oy);
|
||||
|
||||
ogg_page page;
|
||||
if (!OggExpectPage(oy, page, nullptr, is)) {
|
||||
ogg_stream_state os;
|
||||
if (!OggExpectFirstPage(oy, os, nullptr, is)) {
|
||||
ogg_sync_clear(&oy);
|
||||
return false;
|
||||
}
|
||||
@ -280,10 +280,6 @@ mpd_opus_scan_stream(struct input_stream *is,
|
||||
|
||||
bool result = false;
|
||||
|
||||
ogg_stream_state os;
|
||||
ogg_stream_init(&os, ogg_page_serialno(&page));
|
||||
ogg_stream_pagein(&os, &page);
|
||||
|
||||
ogg_packet packet;
|
||||
while (true) {
|
||||
int r = ogg_stream_packetout(&os, &packet);
|
||||
@ -296,12 +292,11 @@ mpd_opus_scan_stream(struct input_stream *is,
|
||||
if (remaining_pages-- == 0)
|
||||
break;
|
||||
|
||||
if (!OggExpectPage(oy, page, nullptr, is)) {
|
||||
if (!OggExpectPageIn(oy, os, nullptr, is)) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
ogg_stream_pagein(&os, &page);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user