Skip to content

Commit

Permalink
commit BT buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Apr 5, 2023
1 parent f91392e commit b4af1e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/driver_bt/bt_app_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
15 changes: 8 additions & 7 deletions components/squeezelite/opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b4af1e7

Please sign in to comment.