mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
fix ogg (opus & vorbis) playback - release
This commit is contained in:
@@ -138,7 +138,9 @@ static int get_opus_packet(void) {
|
|||||||
size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
|
size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
|
||||||
|
|
||||||
while (!(status = OG(&go, stream_packetout, &u->state, &u->packet)) && bytes) {
|
while (!(status = OG(&go, stream_packetout, &u->state, &u->packet)) && bytes) {
|
||||||
do {
|
|
||||||
|
// if sync_pageout (or sync_pageseek) is not called here, sync builds ups
|
||||||
|
while (!(status = OG(&go, sync_pageout, &u->sync, &u->page)) && bytes) {
|
||||||
size_t consumed = min(bytes, 4096);
|
size_t consumed = min(bytes, 4096);
|
||||||
char* buffer = OG(&gu, sync_buffer, &u->sync, consumed);
|
char* buffer = OG(&gu, sync_buffer, &u->sync, consumed);
|
||||||
memcpy(buffer, streambuf->readp, consumed);
|
memcpy(buffer, streambuf->readp, consumed);
|
||||||
@@ -146,7 +148,7 @@ static int get_opus_packet(void) {
|
|||||||
|
|
||||||
_buf_inc_readp(streambuf, consumed);
|
_buf_inc_readp(streambuf, consumed);
|
||||||
bytes -= consumed;
|
bytes -= consumed;
|
||||||
} while (!(status = OG(&gu, sync_pageseek, &u->sync, &u->page)) && bytes);
|
}
|
||||||
|
|
||||||
// if we have a new page, put it in
|
// if we have a new page, put it in
|
||||||
if (status) OG(&go, stream_pagein, &u->state, &u->page);
|
if (status) OG(&go, stream_pagein, &u->state, &u->page);
|
||||||
@@ -184,7 +186,7 @@ static int read_opus_header(void) {
|
|||||||
switch (u->status) {
|
switch (u->status) {
|
||||||
case OGG_SYNC:
|
case OGG_SYNC:
|
||||||
u->status = OGG_ID_HEADER;
|
u->status = OGG_ID_HEADER;
|
||||||
OG(&gu, stream_reset_serialno, &u->state, OG(&gu, page_serialno, &u->page));
|
OG(&gu, stream_init, &u->state, OG(&gu, page_serialno, &u->page));
|
||||||
fetch = false;
|
fetch = false;
|
||||||
break;
|
break;
|
||||||
case OGG_ID_HEADER:
|
case OGG_ID_HEADER:
|
||||||
@@ -208,7 +210,7 @@ static int read_opus_header(void) {
|
|||||||
fetch = true;
|
fetch = true;
|
||||||
break;
|
break;
|
||||||
case OGG_COMMENT_HEADER:
|
case OGG_COMMENT_HEADER:
|
||||||
// skip pakets to consume VorbisComment. With opus, header packets align on pages
|
// skip packets to consume VorbisComment. With opus, header packets align on pages
|
||||||
status = OG(&gu, page_packets, &u->page);
|
status = OG(&gu, page_packets, &u->page);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ static int get_ogg_packet(void) {
|
|||||||
size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
|
size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
|
||||||
|
|
||||||
while (!(status = OG(&go, stream_packetout, &v->state, &v->packet)) && bytes) {
|
while (!(status = OG(&go, stream_packetout, &v->state, &v->packet)) && bytes) {
|
||||||
do {
|
|
||||||
|
// if sync_pageout (or sync_pageseek) is not called first, sync buffers build ups
|
||||||
|
while (!(status = OG(&go, sync_pageout, &u->sync, &u->page)) && bytes) {
|
||||||
size_t consumed = min(bytes, 4096);
|
size_t consumed = min(bytes, 4096);
|
||||||
char* buffer = OG(&gv, sync_buffer, &v->sync, consumed);
|
char* buffer = OG(&gv, sync_buffer, &v->sync, consumed);
|
||||||
memcpy(buffer, streambuf->readp, consumed);
|
memcpy(buffer, streambuf->readp, consumed);
|
||||||
@@ -146,7 +148,7 @@ static int get_ogg_packet(void) {
|
|||||||
|
|
||||||
_buf_inc_readp(streambuf, consumed);
|
_buf_inc_readp(streambuf, consumed);
|
||||||
bytes -= consumed;
|
bytes -= consumed;
|
||||||
} while (!(status = OG(&go, sync_pageseek, &v->sync, &v->page)) && bytes);
|
}
|
||||||
|
|
||||||
// if we have a new page, put it in
|
// if we have a new page, put it in
|
||||||
if (status) OG(&go, stream_pagein, &v->state, &v->page);
|
if (status) OG(&go, stream_pagein, &v->state, &v->page);
|
||||||
|
|||||||
Reference in New Issue
Block a user