commit BT buttons

This commit is contained in:
philippe44
2023-04-05 16:33:39 -07:00
parent f91392e044
commit b4af1e7bef
2 changed files with 9 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ const static actrls_t controls = {
NULL, NULL, // rew, fwd NULL, NULL, // rew, fwd
bt_prev, bt_next, // prev, next bt_prev, bt_next, // prev, next
NULL, NULL, NULL, NULL, // left, right, up, down 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 bt_volume_down, bt_volume_up, bt_toggle// knob left, knob_right, knob push
}; };

View File

@@ -51,7 +51,6 @@ struct opus {
ogg_page page; ogg_page page;
OpusDecoder* decoder; OpusDecoder* decoder;
int rate, gain, pre_skip; int rate, gain, pre_skip;
bool fetch;
size_t overframes; size_t overframes;
u8_t *overbuf; u8_t *overbuf;
int channels; int channels;
@@ -163,14 +162,16 @@ static int get_opus_packet(void) {
static int read_opus_header(void) { static int read_opus_header(void) {
int status = 0; int status = 0;
bool fetch = true;
LOCK_S; LOCK_S;
size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf)); size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
while (bytes && !status) { while (bytes && !status) {
bool fetched = false;
// first fetch a page if we need one // first fetch a page if we need one
if (u->fetch) { if (fetch) {
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);
@@ -180,14 +181,14 @@ static int read_opus_header(void) {
bytes -= consumed; bytes -= consumed;
if (!OG(&gu, sync_pageseek, &u->sync, &u->page)) continue; if (!OG(&gu, sync_pageseek, &u->sync, &u->page)) continue;
u->fetch = false; fetched = true;
} }
//bytes = min(bytes, size);
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_reset_serialno, &u->state, OG(&gu, page_serialno, &u->page));
fetch = false;
break; break;
case OGG_ID_HEADER: case OGG_ID_HEADER:
status = OG(&gu, stream_pagein, &u->state, &u->page); 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); LOG_ERROR("can't create decoder %d (channels:%u)", status, u->channels);
} }
} }
u->fetch = true; fetch = true;
break; break;
case OGG_COMMENT_HEADER: case OGG_COMMENT_HEADER:
// loop until we have consumed VorbisComment and get ready for a new packet // loop until we have consumed VorbisComment and get ready for a new packet
u->fetch = true;
status = OG(&gu, page_packets, &u->page); status = OG(&gu, page_packets, &u->page);
break; break;
default: default:
// just to avoid warning;
fetched = fetched;
break; 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); if (!u->overbuf) u->overbuf = malloc(MAX_OPUS_FRAMES * BYTES_PER_FRAME);
u->status = OGG_SYNC; u->status = OGG_SYNC;
u->fetch = true;
u->overframes = 0; u->overframes = 0;
OG(&gu, sync_init, &u->sync); OG(&gu, sync_init, &u->sync);