summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/apps/playback.c b/apps/playback.c
index a245091d91..d591998bec 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -733,13 +733,24 @@ static void scratch_mem_init(void *mem)
733} 733}
734 734
735static int audiobuf_handle; 735static int audiobuf_handle;
736#define AUDIO_BUFFER_RESERVE (256*1024)
736static size_t filebuflen; 737static size_t filebuflen;
737 738
739
740size_t audio_buffer_size(void)
741{
742 if (audiobuf_handle > 0)
743 return filebuflen - AUDIO_BUFFER_RESERVE;
744 return 0;
745}
746
738size_t audio_buffer_available(void) 747size_t audio_buffer_available(void)
739{ 748{
740 if (audiobuf_handle > 0) /* if allocated return what we got */ 749 size_t size = 0;
741 return filebuflen; 750 size_t core_size = core_available();
742 return core_available(); 751 if (audiobuf_handle > 0) /* if allocated return what we can give */
752 size = filebuflen - AUDIO_BUFFER_RESERVE - 128;
753 return MAX(core_size, size);
743} 754}
744 755
745/* Set up the audio buffer for playback 756/* Set up the audio buffer for playback
@@ -840,7 +851,7 @@ static int shrink_callback(int handle, unsigned hints, void* start, size_t old_s
840 size_t wanted_size = (hints & BUFLIB_SHRINK_SIZE_MASK); 851 size_t wanted_size = (hints & BUFLIB_SHRINK_SIZE_MASK);
841 ssize_t size = (ssize_t)old_size - wanted_size; 852 ssize_t size = (ssize_t)old_size - wanted_size;
842 /* keep at least 256K for the buffering */ 853 /* keep at least 256K for the buffering */
843 if ((size - extradata_size) < 256*1024) 854 if ((size - extradata_size) < AUDIO_BUFFER_RESERVE)
844 return BUFLIB_CB_CANNOT_SHRINK; 855 return BUFLIB_CB_CANNOT_SHRINK;
845 856
846 857