From b4af1e7bef696b908b47f90f7a5685b17fe92b9e Mon Sep 17 00:00:00 2001 From: philippe44 Date: Wed, 5 Apr 2023 16:33:39 -0700 Subject: [PATCH] commit BT buttons --- components/driver_bt/bt_app_sink.c | 2 +- components/squeezelite/opus.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/driver_bt/bt_app_sink.c b/components/driver_bt/bt_app_sink.c index 7a3a866b..70f42fec 100644 --- a/components/driver_bt/bt_app_sink.c +++ b/components/driver_bt/bt_app_sink.c @@ -136,7 +136,7 @@ const static actrls_t controls = { NULL, NULL, // rew, fwd bt_prev, bt_next, // prev, next NULL, NULL, NULL, NULL, // left, right, up, down - NULL, NULL, NULL, NULL, NULL, NULL, // pre1-6 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // pre1-10 bt_volume_down, bt_volume_up, bt_toggle// knob left, knob_right, knob push }; diff --git a/components/squeezelite/opus.c b/components/squeezelite/opus.c index 460c8479..3b6d90c0 100644 --- a/components/squeezelite/opus.c +++ b/components/squeezelite/opus.c @@ -51,7 +51,6 @@ struct opus { ogg_page page; OpusDecoder* decoder; int rate, gain, pre_skip; - bool fetch; size_t overframes; u8_t *overbuf; int channels; @@ -163,14 +162,16 @@ static int get_opus_packet(void) { static int read_opus_header(void) { int status = 0; + bool fetch = true; LOCK_S; size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf)); while (bytes && !status) { + bool fetched = false; // first fetch a page if we need one - if (u->fetch) { + if (fetch) { size_t consumed = min(bytes, 4096); char* buffer = OG(&gu, sync_buffer, &u->sync, consumed); memcpy(buffer, streambuf->readp, consumed); @@ -180,14 +181,14 @@ static int read_opus_header(void) { bytes -= consumed; if (!OG(&gu, sync_pageseek, &u->sync, &u->page)) continue; - u->fetch = false; + fetched = true; } - //bytes = min(bytes, size); switch (u->status) { case OGG_SYNC: u->status = OGG_ID_HEADER; OG(&gu, stream_reset_serialno, &u->state, OG(&gu, page_serialno, &u->page)); + fetch = false; break; case OGG_ID_HEADER: status = OG(&gu, stream_pagein, &u->state, &u->page); @@ -207,14 +208,15 @@ static int read_opus_header(void) { LOG_ERROR("can't create decoder %d (channels:%u)", status, u->channels); } } - u->fetch = true; + fetch = true; break; case OGG_COMMENT_HEADER: // loop until we have consumed VorbisComment and get ready for a new packet - u->fetch = true; status = OG(&gu, page_packets, &u->page); break; default: + // just to avoid warning; + fetched = fetched; break; } } @@ -357,7 +359,6 @@ static void opus_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) { if (!u->overbuf) u->overbuf = malloc(MAX_OPUS_FRAMES * BYTES_PER_FRAME); u->status = OGG_SYNC; - u->fetch = true; u->overframes = 0; OG(&gu, sync_init, &u->sync);