diff options
-rw-r--r-- | apps/mpeg.c | 12 | ||||
-rw-r--r-- | firmware/buflib.c | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/apps/mpeg.c b/apps/mpeg.c index 2a2821bcda..b7db602120 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c | |||
@@ -558,8 +558,10 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) | |||
558 | { | 558 | { |
559 | (void)talk_buf; /* always grab the voice buffer for now */ | 559 | (void)talk_buf; /* always grab the voice buffer for now */ |
560 | 560 | ||
561 | if (buffer_size) /* special case for talk_init() */ | 561 | audio_hard_stop(); |
562 | audio_hard_stop(); | 562 | |
563 | if (!buffer_size) /* special case for talk_init() */ | ||
564 | return NULL; | ||
563 | 565 | ||
564 | if (!audiobuf_handle) | 566 | if (!audiobuf_handle) |
565 | { | 567 | { |
@@ -571,9 +573,9 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size) | |||
571 | *buffer_size = audiobuflen; | 573 | *buffer_size = audiobuflen; |
572 | } | 574 | } |
573 | mpeg_audiobuf = core_get_data(audiobuf_handle); | 575 | mpeg_audiobuf = core_get_data(audiobuf_handle); |
574 | 576 | /* tell talk about the new buffer, don't re-enable just yet because the | |
575 | if (!buffer_size) /* special case for talk_init() */ | 577 | * buffer is stolen */ |
576 | talkbuf_init(mpeg_audiobuf); | 578 | talkbuf_init(mpeg_audiobuf); |
577 | 579 | ||
578 | return mpeg_audiobuf; | 580 | return mpeg_audiobuf; |
579 | } | 581 | } |
diff --git a/firmware/buflib.c b/firmware/buflib.c index d82acd77d3..4ffd6cfce3 100644 --- a/firmware/buflib.c +++ b/firmware/buflib.c | |||
@@ -628,7 +628,11 @@ buflib_alloc_maximum(struct buflib_context* ctx, const char* name, size_t *size, | |||
628 | { | 628 | { |
629 | /* limit name to 16 since that's what buflib_available() accounts for it */ | 629 | /* limit name to 16 since that's what buflib_available() accounts for it */ |
630 | char buf[16]; | 630 | char buf[16]; |
631 | |||
631 | *size = buflib_available(ctx); | 632 | *size = buflib_available(ctx); |
633 | if (*size <= 0) /* OOM */ | ||
634 | return -1; | ||
635 | |||
632 | strlcpy(buf, name, sizeof(buf)); | 636 | strlcpy(buf, name, sizeof(buf)); |
633 | 637 | ||
634 | return buflib_alloc_ex(ctx, *size, buf, ops); | 638 | return buflib_alloc_ex(ctx, *size, buf, ops); |