Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

[BugFix] Playback.c OOM with large voice file

with our large voice file being loaded in its entirety to the buffer
there isn't enough room to allocate the required pcm buffer
well prior to this patch we looked for 1k free to allow the talk buffer
to be given away
well the pcm buffer expects something like 5-600 kb on the clipzip
and there is 1k allocatable but not 300 more

so instead get the required pcm buffer size and check against that

Change-Id: I40a056e4170c37bc3429f0cb37af221ae7f812e5

authored by

William Wilgus and committed by
Solomon Peachy
f0c20855 c3f51b5f

+8 -1
+6
apps/pcmbuf.c
··· 580 580 chunk_transidx = INVALID_BUF_INDEX; 581 581 } 582 582 583 + /* call prior to init to get bytes required */ 584 + size_t pcmbuf_size_reqd(void) 585 + { 586 + return get_next_required_pcmbuf_chunks() * PCMBUF_CHUNK_SIZE; 587 + } 588 + 583 589 /* Initialize the PCM buffer. The structure looks like this: 584 590 * ...|---------PCMBUF---------|GUARDBUF|DESCS| */ 585 591 size_t pcmbuf_init(void *bufend)
+1
apps/pcmbuf.h
··· 28 28 void pcmbuf_write_complete(int count, unsigned long elapsed, off_t offset); 29 29 30 30 /* Init */ 31 + size_t pcmbuf_size_reqd(void); 31 32 size_t pcmbuf_init(void *bufend); 32 33 33 34 /* Playback */
+1 -1
apps/playback.c
··· 1040 1040 core_free(audiobuf_handle); 1041 1041 audiobuf_handle = 0; 1042 1042 } 1043 - if (core_allocatable() < (1 << 10)) 1043 + if (core_allocatable() < pcmbuf_size_reqd()) 1044 1044 talk_buffer_set_policy(TALK_BUFFER_LOOSE); /* back off voice buffer */ 1045 1045 audiobuf_handle = core_alloc_maximum(&filebuflen, &ops); 1046 1046