mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
don't allocate segments - release
This commit is contained in:
@@ -227,6 +227,7 @@ static int read_opus_header(void) {
|
||||
} else if (u->status == OGG_COMMENT_HEADER) {
|
||||
// don't consume VorbisComment which could be a huge packet, just skip it
|
||||
if (!OG(&go, page_packets, &u->page)) continue;
|
||||
LOG_INFO("[%p]: comment skipped successfully", ctx);
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ struct streamstate {
|
||||
struct {
|
||||
enum { STREAM_OGG_OFF, STREAM_OGG_SYNC, STREAM_OGG_HEADER, STREAM_OGG_SEGMENTS, STREAM_OGG_PAGE } state;
|
||||
u32_t want, miss, match;
|
||||
u8_t* data;
|
||||
u8_t* data, segments[255];
|
||||
#pragma pack(push, 1)
|
||||
struct {
|
||||
char pattern[4];
|
||||
|
||||
@@ -59,7 +59,7 @@ is enough and much faster than a mutex
|
||||
static bool polling;
|
||||
static sockfd fd;
|
||||
|
||||
struct streamstate stream;
|
||||
struct EXT_RAM_ATTR streamstate stream;
|
||||
|
||||
#if USE_SSL
|
||||
static SSL_CTX *SSLctx;
|
||||
@@ -148,7 +148,7 @@ static bool running = true;
|
||||
static void _disconnect(stream_state state, disconnect_code disconnect) {
|
||||
stream.state = state;
|
||||
stream.disconnect = disconnect;
|
||||
if (stream.ogg.state == STREAM_OGG_HEADER && stream.ogg.data) free(stream.ogg.data);
|
||||
if (stream.ogg.state == STREAM_OGG_PAGE && stream.ogg.data) free(stream.ogg.data);
|
||||
stream.ogg.data = NULL;
|
||||
#if USE_SSL
|
||||
if (ssl) {
|
||||
@@ -205,7 +205,7 @@ static void stream_ogg(size_t n) {
|
||||
case STREAM_OGG_HEADER:
|
||||
if (!memcmp(stream.ogg.header.pattern, "OggS", 4)) {
|
||||
stream.ogg.miss = stream.ogg.want = stream.ogg.header.count;
|
||||
stream.ogg.data = malloc(stream.ogg.miss);
|
||||
stream.ogg.data = stream.ogg.segments;
|
||||
stream.ogg.state = STREAM_OGG_SEGMENTS;
|
||||
} else {
|
||||
stream.ogg.state = STREAM_OGG_SYNC;
|
||||
@@ -220,11 +220,10 @@ static void stream_ogg(size_t n) {
|
||||
if (stream.ogg.header.granule == 0) {
|
||||
// granule 0 means a new stream, so let's look into it
|
||||
stream.ogg.state = STREAM_OGG_PAGE;
|
||||
stream.ogg.data = realloc(stream.ogg.data, stream.ogg.want);
|
||||
stream.ogg.data = malloc(stream.ogg.want);
|
||||
} else {
|
||||
// otherwise, jump over data
|
||||
stream.ogg.state = STREAM_OGG_SYNC;
|
||||
free(stream.ogg.data);
|
||||
stream.ogg.data = NULL;
|
||||
}
|
||||
break;
|
||||
@@ -726,7 +725,7 @@ bool stream_disconnect(void) {
|
||||
disc = true;
|
||||
}
|
||||
stream.state = STOPPED;
|
||||
if (stream.ogg.state == STREAM_OGG_HEADER && stream.ogg.data) free(stream.ogg.data);
|
||||
if (stream.ogg.state == STREAM_OGG_PAGE && stream.ogg.data) free(stream.ogg.data);
|
||||
stream.ogg.data = NULL;
|
||||
UNLOCK;
|
||||
return disc;
|
||||
|
||||
@@ -242,7 +242,7 @@ static int read_vorbis_header(void) {
|
||||
OV(&gv, comment_init, &v->comment);
|
||||
v->comment.vendor = "N/A";
|
||||
fetch = true;
|
||||
LOG_INFO("comment skipped succesfully");
|
||||
LOG_INFO("comment skipped successfully");
|
||||
|
||||
// because of lack of page alignment, we might have the setup page already fully in
|
||||
if (packets == 1) continue;
|
||||
|
||||
Reference in New Issue
Block a user