diff options
-rw-r--r-- | apps/buffering.c | 25 | ||||
-rw-r--r-- | apps/codecs/aac.c | 2 | ||||
-rw-r--r-- | apps/codecs/aiff.c | 1 | ||||
-rw-r--r-- | apps/codecs/alac.c | 2 | ||||
-rw-r--r-- | apps/codecs/ape.c | 2 | ||||
-rw-r--r-- | apps/codecs/asap.c | 3 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/decoder.h | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/demac.h | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter_1280_15.c | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter_16_11.c | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter_256_13.c | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter_32_10.c | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/filter_64_11.c | 2 | ||||
-rw-r--r-- | apps/codecs/demac/wavwrite.h | 2 | ||||
-rw-r--r-- | apps/codecs/flac.c | 2 | ||||
-rw-r--r-- | apps/codecs/mod.c | 3 | ||||
-rw-r--r-- | apps/codecs/shorten.c | 2 | ||||
-rw-r--r-- | apps/codecs/sid.c | 3 | ||||
-rw-r--r-- | apps/codecs/spc.c | 2 | ||||
-rw-r--r-- | apps/codecs/wav.c | 1 | ||||
-rw-r--r-- | apps/codecs/wavpack.c | 2 | ||||
-rw-r--r-- | apps/codecs/wma.c | 2 | ||||
-rw-r--r-- | apps/debug_menu.c | 10 | ||||
-rw-r--r-- | apps/dsp.h | 3 | ||||
-rw-r--r-- | apps/pcmbuf.c | 59 | ||||
-rw-r--r-- | apps/pcmbuf.h | 6 | ||||
-rw-r--r-- | apps/playback.c | 60 |
27 files changed, 85 insertions, 121 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 1e643c5771..d715456efb 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -56,11 +56,7 @@ | |||
56 | #include "albumart.h" | 56 | #include "albumart.h" |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #if MEM > 1 | ||
60 | #define GUARD_BUFSIZE (32*1024) | 59 | #define GUARD_BUFSIZE (32*1024) |
61 | #else | ||
62 | #define GUARD_BUFSIZE (8*1024) | ||
63 | #endif | ||
64 | 60 | ||
65 | /* Define LOGF_ENABLE to enable logf output in this file */ | 61 | /* Define LOGF_ENABLE to enable logf output in this file */ |
66 | /*#define LOGF_ENABLE*/ | 62 | /*#define LOGF_ENABLE*/ |
@@ -88,11 +84,9 @@ | |||
88 | #endif | 84 | #endif |
89 | 85 | ||
90 | /* default point to start buffer refill */ | 86 | /* default point to start buffer refill */ |
91 | #define BUFFERING_DEFAULT_WATERMARK (1024*512) | 87 | #define BUFFERING_DEFAULT_WATERMARK (1024*128) |
92 | /* amount of data to read in one read() call */ | 88 | /* amount of data to read in one read() call */ |
93 | #define BUFFERING_DEFAULT_FILECHUNK (1024*32) | 89 | #define BUFFERING_DEFAULT_FILECHUNK (1024*32) |
94 | /* point at which the file buffer will fight for CPU time */ | ||
95 | #define BUFFERING_CRITICAL_LEVEL (1024*128) | ||
96 | 90 | ||
97 | #define BUF_HANDLE_MASK 0x7FFFFFFF | 91 | #define BUF_HANDLE_MASK 0x7FFFFFFF |
98 | 92 | ||
@@ -173,7 +167,6 @@ enum { | |||
173 | Q_BASE_HANDLE, /* Set the reference handle for buf_useful_data */ | 167 | Q_BASE_HANDLE, /* Set the reference handle for buf_useful_data */ |
174 | 168 | ||
175 | /* Configuration: */ | 169 | /* Configuration: */ |
176 | Q_SET_WATERMARK, | ||
177 | Q_START_FILL, /* Request that the buffering thread initiate a buffer | 170 | Q_START_FILL, /* Request that the buffering thread initiate a buffer |
178 | fill at its earliest convenience */ | 171 | fill at its earliest convenience */ |
179 | Q_HANDLE_ADDED, /* Inform the buffering thread that a handle was added, | 172 | Q_HANDLE_ADDED, /* Inform the buffering thread that a handle was added, |
@@ -555,7 +548,7 @@ static void update_data_counters(void) | |||
555 | static inline bool buffer_is_low(void) | 548 | static inline bool buffer_is_low(void) |
556 | { | 549 | { |
557 | update_data_counters(); | 550 | update_data_counters(); |
558 | return data_counters.useful < BUFFERING_CRITICAL_LEVEL; | 551 | return data_counters.useful < (conf_watermark / 2); |
559 | } | 552 | } |
560 | 553 | ||
561 | /* Buffer data for the given handle. | 554 | /* Buffer data for the given handle. |
@@ -1313,8 +1306,7 @@ size_t buf_used(void) | |||
1313 | 1306 | ||
1314 | void buf_set_watermark(size_t bytes) | 1307 | void buf_set_watermark(size_t bytes) |
1315 | { | 1308 | { |
1316 | LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", (long)bytes); | 1309 | conf_watermark = bytes; |
1317 | queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); | ||
1318 | } | 1310 | } |
1319 | 1311 | ||
1320 | static void shrink_buffer_inner(struct memory_handle *h) | 1312 | static void shrink_buffer_inner(struct memory_handle *h) |
@@ -1386,17 +1378,6 @@ void buffering_thread(void) | |||
1386 | base_handle_id = (int)ev.data; | 1378 | base_handle_id = (int)ev.data; |
1387 | break; | 1379 | break; |
1388 | 1380 | ||
1389 | case Q_SET_WATERMARK: | ||
1390 | LOGFQUEUE("buffering < Q_SET_WATERMARK"); | ||
1391 | conf_watermark = (size_t)ev.data; | ||
1392 | if (conf_watermark < BUFFERING_DEFAULT_FILECHUNK) | ||
1393 | { | ||
1394 | logf("wmark<chunk %ld<%d", | ||
1395 | (long)conf_watermark, BUFFERING_DEFAULT_FILECHUNK); | ||
1396 | conf_watermark = BUFFERING_DEFAULT_FILECHUNK; | ||
1397 | } | ||
1398 | break; | ||
1399 | |||
1400 | #ifndef SIMULATOR | 1381 | #ifndef SIMULATOR |
1401 | case SYS_USB_CONNECTED: | 1382 | case SYS_USB_CONNECTED: |
1402 | LOGFQUEUE("buffering < SYS_USB_CONNECTED"); | 1383 | LOGFQUEUE("buffering < SYS_USB_CONNECTED"); |
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index b781102469..60460355da 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c | |||
@@ -55,8 +55,6 @@ enum codec_status codec_main(void) | |||
55 | unsigned char c = 0; | 55 | unsigned char c = 0; |
56 | 56 | ||
57 | /* Generic codec initialisation */ | 57 | /* Generic codec initialisation */ |
58 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
59 | |||
60 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); | 58 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); |
61 | ci->configure(DSP_SET_SAMPLE_DEPTH, 29); | 59 | ci->configure(DSP_SET_SAMPLE_DEPTH, 29); |
62 | 60 | ||
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c index 53593fcaa8..9a675415e2 100644 --- a/apps/codecs/aiff.c +++ b/apps/codecs/aiff.c | |||
@@ -66,7 +66,6 @@ enum codec_status codec_main(void) | |||
66 | 66 | ||
67 | /* Generic codec initialisation */ | 67 | /* Generic codec initialisation */ |
68 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | 68 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); |
69 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
70 | 69 | ||
71 | next_track: | 70 | next_track: |
72 | if (codec_init()) { | 71 | if (codec_init()) { |
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c index 367be14824..fdc6748a95 100644 --- a/apps/codecs/alac.c +++ b/apps/codecs/alac.c | |||
@@ -44,8 +44,6 @@ enum codec_status codec_main(void) | |||
44 | int retval; | 44 | int retval; |
45 | 45 | ||
46 | /* Generic codec initialisation */ | 46 | /* Generic codec initialisation */ |
47 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
48 | |||
49 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); | 47 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); |
50 | ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1); | 48 | ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1); |
51 | 49 | ||
diff --git a/apps/codecs/ape.c b/apps/codecs/ape.c index dbe6e0fc9e..6c829c3863 100644 --- a/apps/codecs/ape.c +++ b/apps/codecs/ape.c | |||
@@ -147,8 +147,6 @@ enum codec_status codec_main(void) | |||
147 | size_t resume_offset; | 147 | size_t resume_offset; |
148 | 148 | ||
149 | /* Generic codec initialisation */ | 149 | /* Generic codec initialisation */ |
150 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
151 | |||
152 | ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1); | 150 | ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1); |
153 | 151 | ||
154 | next_track: | 152 | next_track: |
diff --git a/apps/codecs/asap.c b/apps/codecs/asap.c index 9e2228bf84..bb627ad06c 100644 --- a/apps/codecs/asap.c +++ b/apps/codecs/asap.c | |||
@@ -38,9 +38,6 @@ enum codec_status codec_main(void) | |||
38 | char* module; | 38 | char* module; |
39 | int bytesPerSample =2; | 39 | int bytesPerSample =2; |
40 | 40 | ||
41 | /* Generic codec initialisation */ | ||
42 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
43 | |||
44 | next_track: | 41 | next_track: |
45 | if (codec_init()) { | 42 | if (codec_init()) { |
46 | DEBUGF("codec init failed\n"); | 43 | DEBUGF("codec init failed\n"); |
diff --git a/apps/codecs/demac/libdemac/decoder.h b/apps/codecs/demac/libdemac/decoder.h index 0c3bd15b37..aeac569509 100644 --- a/apps/codecs/demac/libdemac/decoder.h +++ b/apps/codecs/demac/libdemac/decoder.h | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/demac.h b/apps/codecs/demac/libdemac/demac.h index d1bb361574..696b2aba73 100644 --- a/apps/codecs/demac/libdemac/demac.h +++ b/apps/codecs/demac/libdemac/demac.h | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/filter_1280_15.c b/apps/codecs/demac/libdemac/filter_1280_15.c index edf1ce1bb1..7077e0ee8e 100644 --- a/apps/codecs/demac/libdemac/filter_1280_15.c +++ b/apps/codecs/demac/libdemac/filter_1280_15.c | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/filter_16_11.c b/apps/codecs/demac/libdemac/filter_16_11.c index 07e4b96dc2..94c56e247f 100644 --- a/apps/codecs/demac/libdemac/filter_16_11.c +++ b/apps/codecs/demac/libdemac/filter_16_11.c | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/filter_256_13.c b/apps/codecs/demac/libdemac/filter_256_13.c index 370dec1d5a..69cf638903 100644 --- a/apps/codecs/demac/libdemac/filter_256_13.c +++ b/apps/codecs/demac/libdemac/filter_256_13.c | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/filter_32_10.c b/apps/codecs/demac/libdemac/filter_32_10.c index b585de98a4..5ec85089db 100644 --- a/apps/codecs/demac/libdemac/filter_32_10.c +++ b/apps/codecs/demac/libdemac/filter_32_10.c | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/libdemac/filter_64_11.c b/apps/codecs/demac/libdemac/filter_64_11.c index 8b8d326d1d..cd74fa5f6b 100644 --- a/apps/codecs/demac/libdemac/filter_64_11.c +++ b/apps/codecs/demac/libdemac/filter_64_11.c | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | libdemac - A Monkey's Audio decoder | 3 | libdemac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/demac/wavwrite.h b/apps/codecs/demac/wavwrite.h index eba8ac7e31..a124353229 100644 --- a/apps/codecs/demac/wavwrite.h +++ b/apps/codecs/demac/wavwrite.h | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | demac - A Monkey's Audio decoder | 3 | demac - A Monkey's Audio decoder |
4 | 4 | ||
5 | $Id:$ | 5 | $Id$ |
6 | 6 | ||
7 | Copyright (C) Dave Chapman 2007 | 7 | Copyright (C) Dave Chapman 2007 |
8 | 8 | ||
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index 3a23d0b951..00d2c16993 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c | |||
@@ -423,8 +423,6 @@ enum codec_status codec_main(void) | |||
423 | int retval; | 423 | int retval; |
424 | 424 | ||
425 | /* Generic codec initialisation */ | 425 | /* Generic codec initialisation */ |
426 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
427 | |||
428 | ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1); | 426 | ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1); |
429 | 427 | ||
430 | next_track: | 428 | next_track: |
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c index 91b5955b40..523e1c7d0b 100644 --- a/apps/codecs/mod.c +++ b/apps/codecs/mod.c | |||
@@ -1229,9 +1229,6 @@ enum codec_status codec_main(void) | |||
1229 | 1229 | ||
1230 | int bytesdone; | 1230 | int bytesdone; |
1231 | 1231 | ||
1232 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
1233 | |||
1234 | |||
1235 | next_track: | 1232 | next_track: |
1236 | if (codec_init()) { | 1233 | if (codec_init()) { |
1237 | return CODEC_ERROR; | 1234 | return CODEC_ERROR; |
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c index 4e00b9a579..9b5c2e2f17 100644 --- a/apps/codecs/shorten.c +++ b/apps/codecs/shorten.c | |||
@@ -47,8 +47,6 @@ enum codec_status codec_main(void) | |||
47 | size_t bytesleft; | 47 | size_t bytesleft; |
48 | 48 | ||
49 | /* Generic codec initialisation */ | 49 | /* Generic codec initialisation */ |
50 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
51 | |||
52 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); | 50 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); |
53 | ci->configure(DSP_SET_SAMPLE_DEPTH, SHN_OUTPUT_DEPTH-1); | 51 | ci->configure(DSP_SET_SAMPLE_DEPTH, SHN_OUTPUT_DEPTH-1); |
54 | 52 | ||
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c index 087ad754fb..c00aa22142 100644 --- a/apps/codecs/sid.c +++ b/apps/codecs/sid.c | |||
@@ -1215,9 +1215,6 @@ enum codec_status codec_main(void) | |||
1215 | int nSamplesPerCall = 882; /* This is PAL SID single speed (44100/50Hz) */ | 1215 | int nSamplesPerCall = 882; /* This is PAL SID single speed (44100/50Hz) */ |
1216 | int nSamplesToRender = 0; | 1216 | int nSamplesToRender = 0; |
1217 | 1217 | ||
1218 | /* Generic codec initialisation */ | ||
1219 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
1220 | |||
1221 | next_track: | 1218 | next_track: |
1222 | if (codec_init()) { | 1219 | if (codec_init()) { |
1223 | return CODEC_ERROR; | 1220 | return CODEC_ERROR; |
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index 14d28dfca8..5ac594431a 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c | |||
@@ -559,8 +559,6 @@ enum codec_status codec_main(void) | |||
559 | 559 | ||
560 | /* Read the entire file */ | 560 | /* Read the entire file */ |
561 | DEBUGF("SPC: request initial buffer\n"); | 561 | DEBUGF("SPC: request initial buffer\n"); |
562 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, ci->filesize); | ||
563 | |||
564 | ci->seek_buffer(0); | 562 | ci->seek_buffer(0); |
565 | size_t buffersize; | 563 | size_t buffersize; |
566 | uint8_t* buffer = ci->request_buffer(&buffersize, ci->filesize); | 564 | uint8_t* buffer = ci->request_buffer(&buffersize, ci->filesize); |
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index 4657891595..b3efbc10ce 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c | |||
@@ -228,7 +228,6 @@ enum codec_status codec_main(void) | |||
228 | 228 | ||
229 | /* Generic codec initialisation */ | 229 | /* Generic codec initialisation */ |
230 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | 230 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); |
231 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
232 | 231 | ||
233 | next_track: | 232 | next_track: |
234 | if (codec_init()) { | 233 | if (codec_init()) { |
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c index c93e2e0dcd..c85c254580 100644 --- a/apps/codecs/wavpack.c +++ b/apps/codecs/wavpack.c | |||
@@ -44,8 +44,6 @@ enum codec_status codec_main(void) | |||
44 | int retval; | 44 | int retval; |
45 | 45 | ||
46 | /* Generic codec initialisation */ | 46 | /* Generic codec initialisation */ |
47 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
48 | |||
49 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); | 47 | ci->configure(DSP_SET_SAMPLE_DEPTH, 28); |
50 | 48 | ||
51 | next_track: | 49 | next_track: |
diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c index 93f4e27136..b5dfa4cb00 100644 --- a/apps/codecs/wma.c +++ b/apps/codecs/wma.c | |||
@@ -468,8 +468,6 @@ enum codec_status codec_main(void) | |||
468 | int errcount = 0; | 468 | int errcount = 0; |
469 | 469 | ||
470 | /* Generic codec initialisation */ | 470 | /* Generic codec initialisation */ |
471 | ci->configure(CODEC_SET_FILEBUF_WATERMARK, 1024*512); | ||
472 | |||
473 | ci->configure(DSP_SET_SAMPLE_DEPTH, 29); | 471 | ci->configure(DSP_SET_SAMPLE_DEPTH, 29); |
474 | 472 | ||
475 | next_track: | 473 | next_track: |
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 7567c64a21..10d69b018c 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -329,14 +329,14 @@ static bool dbg_buffering_thread(void) | |||
329 | 329 | ||
330 | bufused = bufsize - pcmbuf_free(); | 330 | bufused = bufsize - pcmbuf_free(); |
331 | 331 | ||
332 | snprintf(buf, sizeof(buf), "pcm: %7ld/%7ld", (long) bufused, (long) bufsize); | 332 | snprintf(buf, sizeof(buf), "pcm: %6ld/%ld", (long) bufused, (long) bufsize); |
333 | lcd_puts(0, line++, buf); | 333 | lcd_puts(0, line++, buf); |
334 | 334 | ||
335 | gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, | 335 | gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, |
336 | bufsize, 0, bufused, HORIZONTAL); | 336 | bufsize, 0, bufused, HORIZONTAL); |
337 | line++; | 337 | line++; |
338 | 338 | ||
339 | snprintf(buf, sizeof(buf), "alloc: %8ld/%8ld", audio_filebufused(), | 339 | snprintf(buf, sizeof(buf), "alloc: %6ld/%ld", audio_filebufused(), |
340 | (long) filebuflen); | 340 | (long) filebuflen); |
341 | lcd_puts(0, line++, buf); | 341 | lcd_puts(0, line++, buf); |
342 | 342 | ||
@@ -345,7 +345,7 @@ static bool dbg_buffering_thread(void) | |||
345 | filebuflen, 0, audio_filebufused(), HORIZONTAL); | 345 | filebuflen, 0, audio_filebufused(), HORIZONTAL); |
346 | line++; | 346 | line++; |
347 | 347 | ||
348 | snprintf(buf, sizeof(buf), "real: %8ld/%8ld", (long)d.buffered_data, | 348 | snprintf(buf, sizeof(buf), "real: %6ld/%ld", (long)d.buffered_data, |
349 | (long)filebuflen); | 349 | (long)filebuflen); |
350 | lcd_puts(0, line++, buf); | 350 | lcd_puts(0, line++, buf); |
351 | 351 | ||
@@ -354,7 +354,7 @@ static bool dbg_buffering_thread(void) | |||
354 | line++; | 354 | line++; |
355 | #endif | 355 | #endif |
356 | 356 | ||
357 | snprintf(buf, sizeof(buf), "usefl: %8ld/%8ld", (long)(d.useful_data), | 357 | snprintf(buf, sizeof(buf), "usefl: %6ld/%ld", (long)(d.useful_data), |
358 | (long)filebuflen); | 358 | (long)filebuflen); |
359 | lcd_puts(0, line++, buf); | 359 | lcd_puts(0, line++, buf); |
360 | 360 | ||
@@ -383,7 +383,7 @@ static bool dbg_buffering_thread(void) | |||
383 | { | 383 | { |
384 | int boostquota = boost_ticks * 1000 / ticks; /* in 0.1 % */ | 384 | int boostquota = boost_ticks * 1000 / ticks; /* in 0.1 % */ |
385 | int avgclock = freq_sum * 10 / ticks; /* in 100 kHz */ | 385 | int avgclock = freq_sum * 10 / ticks; /* in 100 kHz */ |
386 | snprintf(buf, sizeof(buf), "boost ratio: %3d.%d%% (%2d.%dMHz)", | 386 | snprintf(buf, sizeof(buf), "boost:%3d.%d%% (%d.%dMHz)", |
387 | boostquota/10, boostquota%10, avgclock/10, avgclock%10); | 387 | boostquota/10, boostquota%10, avgclock/10, avgclock%10); |
388 | lcd_puts(0, line++, buf); | 388 | lcd_puts(0, line++, buf); |
389 | } | 389 | } |
diff --git a/apps/dsp.h b/apps/dsp.h index 1746a5cccc..c3239360b0 100644 --- a/apps/dsp.h +++ b/apps/dsp.h | |||
@@ -42,8 +42,7 @@ enum | |||
42 | 42 | ||
43 | enum | 43 | enum |
44 | { | 44 | { |
45 | CODEC_SET_FILEBUF_WATERMARK = 1, | 45 | DSP_MYDSP = 1, |
46 | DSP_MYDSP, | ||
47 | DSP_SET_FREQUENCY, | 46 | DSP_SET_FREQUENCY, |
48 | DSP_SWITCH_FREQUENCY, | 47 | DSP_SWITCH_FREQUENCY, |
49 | DSP_SET_SAMPLE_DEPTH, | 48 | DSP_SET_SAMPLE_DEPTH, |
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 095b5209eb..c8ed91e21a 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c | |||
@@ -48,8 +48,12 @@ static inline int32_t clip_sample_16(int32_t sample) | |||
48 | return sample; | 48 | return sample; |
49 | } | 49 | } |
50 | 50 | ||
51 | #if MEMORYSIZE > 2 | ||
51 | /* Keep watermark high for iPods at least (2s) */ | 52 | /* Keep watermark high for iPods at least (2s) */ |
52 | #define PCMBUF_WATERMARK (NATIVE_FREQUENCY * 4 * 2) | 53 | #define PCMBUF_WATERMARK (NATIVE_FREQUENCY * 4 * 2) |
54 | #else | ||
55 | #define PCMBUF_WATERMARK (NATIVE_FREQUENCY * 1) /* 0.25 seconds */ | ||
56 | #endif | ||
53 | 57 | ||
54 | /* Structure we can use to queue pcm chunks in memory to be played | 58 | /* Structure we can use to queue pcm chunks in memory to be played |
55 | * by the driver code. */ | 59 | * by the driver code. */ |
@@ -125,7 +129,7 @@ extern unsigned int codec_thread_id; | |||
125 | (pcmbuf_unplayed_bytes < NATIVE_FREQUENCY * quarter_secs) | 129 | (pcmbuf_unplayed_bytes < NATIVE_FREQUENCY * quarter_secs) |
126 | 130 | ||
127 | static bool prepare_insert(size_t length); | 131 | static bool prepare_insert(size_t length); |
128 | static void pcmbuf_under_watermark(void); | 132 | static void pcmbuf_under_watermark(bool under); |
129 | static bool pcmbuf_flush_fillpos(void); | 133 | static bool pcmbuf_flush_fillpos(void); |
130 | 134 | ||
131 | #define CALL_IF_EXISTS(function, args...) if (function) function(args) | 135 | #define CALL_IF_EXISTS(function, args...) if (function) function(args) |
@@ -194,7 +198,7 @@ static void pcmbuf_set_watermark_bytes(void) | |||
194 | pcmbuf_watermark = (crossfade_enabled && pcmbuf_size) ? | 198 | pcmbuf_watermark = (crossfade_enabled && pcmbuf_size) ? |
195 | /* If crossfading, try to keep the buffer full other than 1 second */ | 199 | /* If crossfading, try to keep the buffer full other than 1 second */ |
196 | (pcmbuf_size - (NATIVE_FREQUENCY * 4 * 1)) : | 200 | (pcmbuf_size - (NATIVE_FREQUENCY * 4 * 1)) : |
197 | /* Otherwise, just keep it above 2 second */ | 201 | /* Otherwise, just use the default */ |
198 | PCMBUF_WATERMARK; | 202 | PCMBUF_WATERMARK; |
199 | } | 203 | } |
200 | 204 | ||
@@ -271,7 +275,7 @@ static void boost_codec_thread(bool boost) | |||
271 | } | 275 | } |
272 | #endif /* HAVE_PRIORITY_SCHEDULING */ | 276 | #endif /* HAVE_PRIORITY_SCHEDULING */ |
273 | 277 | ||
274 | static void pcmbuf_under_watermark(void) | 278 | static void pcmbuf_under_watermark(bool under) |
275 | { | 279 | { |
276 | /* Only codec thread initiates boost - voice boosts the cpu when playing | 280 | /* Only codec thread initiates boost - voice boosts the cpu when playing |
277 | a clip */ | 281 | a clip */ |
@@ -279,13 +283,21 @@ static void pcmbuf_under_watermark(void) | |||
279 | if (thread_get_current() == codec_thread_id) | 283 | if (thread_get_current() == codec_thread_id) |
280 | #endif /* SIMULATOR */ | 284 | #endif /* SIMULATOR */ |
281 | { | 285 | { |
286 | if (under) | ||
287 | { | ||
282 | #ifdef HAVE_PRIORITY_SCHEDULING | 288 | #ifdef HAVE_PRIORITY_SCHEDULING |
283 | /* If buffer is critically low, override UI priority, else | 289 | /* If buffer is critically low, override UI priority, else |
284 | set back to the original priority. */ | 290 | set back to the original priority. */ |
285 | boost_codec_thread(LOW_DATA(2) && pcm_is_playing()); | 291 | boost_codec_thread(LOW_DATA(2) && pcm_is_playing()); |
286 | #endif | 292 | #endif |
287 | /* Fill audio buffer by boosting cpu */ | 293 | /* Fill audio buffer by boosting cpu */ |
288 | trigger_cpu_boost(); | 294 | trigger_cpu_boost(); |
295 | } | ||
296 | else | ||
297 | { | ||
298 | boost_codec_thread(false); | ||
299 | cancel_cpu_boost(); | ||
300 | } | ||
289 | } | 301 | } |
290 | 302 | ||
291 | /* Disable crossfade if < .5s of audio */ | 303 | /* Disable crossfade if < .5s of audio */ |
@@ -318,8 +330,13 @@ bool pcmbuf_is_lowdata(void) | |||
318 | crossfade_init || crossfade_active) | 330 | crossfade_init || crossfade_active) |
319 | return false; | 331 | return false; |
320 | 332 | ||
333 | #if MEMORYSIZE > 2 | ||
321 | /* 1 seconds of buffer is low data */ | 334 | /* 1 seconds of buffer is low data */ |
322 | return LOW_DATA(4); | 335 | return LOW_DATA(4); |
336 | #else | ||
337 | /* under watermark is low data */ | ||
338 | return (pcmbuf_unplayed_bytes < pcmbuf_watermark); | ||
339 | #endif | ||
323 | } | 340 | } |
324 | 341 | ||
325 | /* Amount of bytes left in the buffer. */ | 342 | /* Amount of bytes left in the buffer. */ |
@@ -421,20 +438,18 @@ static void pcmbuf_init_pcmbuffers(void) | |||
421 | 438 | ||
422 | static size_t pcmbuf_get_next_required_pcmbuf_size(void) | 439 | static size_t pcmbuf_get_next_required_pcmbuf_size(void) |
423 | { | 440 | { |
424 | #if MEM > 1 | ||
425 | size_t seconds = 1; | 441 | size_t seconds = 1; |
426 | 442 | ||
427 | if (crossfade_enabled_pending) | 443 | if (crossfade_enabled_pending) |
428 | seconds += global_settings.crossfade_fade_out_delay | 444 | seconds += global_settings.crossfade_fade_out_delay |
429 | + global_settings.crossfade_fade_out_duration; | 445 | + global_settings.crossfade_fade_out_duration; |
430 | 446 | ||
447 | #if MEMORYSIZE > 2 | ||
431 | /* Buffer has to be at least 2s long. */ | 448 | /* Buffer has to be at least 2s long. */ |
432 | seconds += 2; | 449 | seconds += 2; |
433 | logf("pcmbuf len: %ld", seconds); | ||
434 | return seconds * (NATIVE_FREQUENCY*4); | ||
435 | #else | ||
436 | return NATIVE_FREQUENCY*2; | ||
437 | #endif | 450 | #endif |
451 | logf("pcmbuf len: %ld", seconds); | ||
452 | return seconds * (NATIVE_FREQUENCY*4); /* 2 channels + 2 bytes/sample */ | ||
438 | } | 453 | } |
439 | 454 | ||
440 | static char *pcmbuf_calc_audiobuffer_ptr(size_t bufsize) | 455 | static char *pcmbuf_calc_audiobuffer_ptr(size_t bufsize) |
@@ -817,8 +832,7 @@ static bool prepare_insert(size_t length) | |||
817 | if (low_latency_mode) | 832 | if (low_latency_mode) |
818 | { | 833 | { |
819 | /* 1/4s latency. */ | 834 | /* 1/4s latency. */ |
820 | if (pcmbuf_unplayed_bytes > NATIVE_FREQUENCY * 4 / 2 | 835 | if (!LOW_DATA(1) && pcm_is_playing()) |
821 | && pcm_is_playing()) | ||
822 | return false; | 836 | return false; |
823 | } | 837 | } |
824 | 838 | ||
@@ -830,11 +844,11 @@ static bool prepare_insert(size_t length) | |||
830 | { | 844 | { |
831 | trigger_cpu_boost(); | 845 | trigger_cpu_boost(); |
832 | 846 | ||
833 | /* Pre-buffer 1s. */ | 847 | /* Pre-buffer up to watermark */ |
834 | #if MEM <= 1 | 848 | #if MEMORYSIZE > 2 |
835 | if (!LOW_DATA(1)) | ||
836 | #else | ||
837 | if (!LOW_DATA(4)) | 849 | if (!LOW_DATA(4)) |
850 | #else | ||
851 | if (pcmbuf_unplayed_bytes > pcmbuf_watermark) | ||
838 | #endif | 852 | #endif |
839 | { | 853 | { |
840 | logf("pcm starting"); | 854 | logf("pcm starting"); |
@@ -842,8 +856,8 @@ static bool prepare_insert(size_t length) | |||
842 | pcmbuf_play_start(); | 856 | pcmbuf_play_start(); |
843 | } | 857 | } |
844 | } | 858 | } |
845 | else if (pcmbuf_unplayed_bytes <= pcmbuf_watermark) | 859 | else |
846 | pcmbuf_under_watermark(); | 860 | pcmbuf_under_watermark(pcmbuf_unplayed_bytes <= pcmbuf_watermark); |
847 | 861 | ||
848 | return true; | 862 | return true; |
849 | } | 863 | } |
@@ -1119,11 +1133,8 @@ void pcmbuf_write_voice_complete(int count) | |||
1119 | 1133 | ||
1120 | void pcmbuf_crossfade_enable(bool on_off) | 1134 | void pcmbuf_crossfade_enable(bool on_off) |
1121 | { | 1135 | { |
1122 | #if MEM > 1 | ||
1123 | /* Next setting to be used, not applied now */ | 1136 | /* Next setting to be used, not applied now */ |
1124 | crossfade_enabled_pending = on_off; | 1137 | crossfade_enabled_pending = on_off; |
1125 | #endif | ||
1126 | (void)on_off; | ||
1127 | } | 1138 | } |
1128 | 1139 | ||
1129 | void pcmbuf_crossfade_enable_finished(void) | 1140 | void pcmbuf_crossfade_enable_finished(void) |
diff --git a/apps/pcmbuf.h b/apps/pcmbuf.h index 8c448884f9..b4e551f74d 100644 --- a/apps/pcmbuf.h +++ b/apps/pcmbuf.h | |||
@@ -21,18 +21,12 @@ | |||
21 | #ifndef PCMBUF_H | 21 | #ifndef PCMBUF_H |
22 | #define PCMBUF_H | 22 | #define PCMBUF_H |
23 | 23 | ||
24 | #if MEM > 1 | ||
25 | #define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks | 24 | #define PCMBUF_TARGET_CHUNK 32768 /* This is the target fill size of chunks |
26 | on the pcm buffer */ | 25 | on the pcm buffer */ |
27 | #define PCMBUF_MINAVG_CHUNK 24576 /* This is the minimum average size of | 26 | #define PCMBUF_MINAVG_CHUNK 24576 /* This is the minimum average size of |
28 | chunks on the pcm buffer (or we run out | 27 | chunks on the pcm buffer (or we run out |
29 | of buffer descriptors, which is | 28 | of buffer descriptors, which is |
30 | non-fatal) */ | 29 | non-fatal) */ |
31 | #else | ||
32 | #define PCMBUF_TARGET_CHUNK 16384 | ||
33 | #define PCMBUF_MINAVG_CHUNK 12288 | ||
34 | #endif | ||
35 | |||
36 | #define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than | 30 | #define PCMBUF_MIN_CHUNK 4096 /* We try to never feed a chunk smaller than |
37 | this to the DMA */ | 31 | this to the DMA */ |
38 | #define PCMBUF_MIX_CHUNK 8192 /* This is the maximum size of one packet | 32 | #define PCMBUF_MIX_CHUNK 8192 /* This is the maximum size of one packet |
diff --git a/apps/playback.c b/apps/playback.c index e81b32dbf9..c98455ccb0 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -88,8 +88,6 @@ | |||
88 | 88 | ||
89 | #define PLAYBACK_VOICE | 89 | #define PLAYBACK_VOICE |
90 | 90 | ||
91 | /* default point to start buffer refill */ | ||
92 | #define AUDIO_DEFAULT_WATERMARK (1024*512) | ||
93 | /* amount of guess-space to allow for codecs that must hunt and peck | 91 | /* amount of guess-space to allow for codecs that must hunt and peck |
94 | * for their correct seeek target, 32k seems a good size */ | 92 | * for their correct seeek target, 32k seems a good size */ |
95 | #define AUDIO_REBUFFER_GUESS_SIZE (1024*32) | 93 | #define AUDIO_REBUFFER_GUESS_SIZE (1024*32) |
@@ -162,20 +160,12 @@ enum filling_state { | |||
162 | STATE_FINISHED, /* all remaining tracks are fully buffered */ | 160 | STATE_FINISHED, /* all remaining tracks are fully buffered */ |
163 | }; | 161 | }; |
164 | 162 | ||
165 | #if MEM > 1 | ||
166 | #define MAX_TRACK 128 | 163 | #define MAX_TRACK 128 |
167 | #else | ||
168 | #define MAX_TRACK 32 | ||
169 | #endif | ||
170 | 164 | ||
171 | #define MAX_TRACK_MASK (MAX_TRACK-1) | 165 | #define MAX_TRACK_MASK (MAX_TRACK-1) |
172 | 166 | ||
173 | /* As defined in plugins/lib/xxx2wav.h */ | 167 | /* As defined in plugins/lib/xxx2wav.h */ |
174 | #if MEM > 1 | ||
175 | #define GUARD_BUFSIZE (32*1024) | 168 | #define GUARD_BUFSIZE (32*1024) |
176 | #else | ||
177 | #define GUARD_BUFSIZE (8*1024) | ||
178 | #endif | ||
179 | 169 | ||
180 | /* As defined in plugin.lds */ | 170 | /* As defined in plugin.lds */ |
181 | #if defined(CPU_PP) | 171 | #if defined(CPU_PP) |
@@ -277,11 +267,13 @@ static bool track_load_started = false; | |||
277 | */ | 267 | */ |
278 | static bool codec_requested_stop = false; | 268 | static bool codec_requested_stop = false; |
279 | 269 | ||
270 | #ifdef HAVE_DISK_STORAGE | ||
280 | static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */ | 271 | static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */ |
272 | #endif | ||
281 | 273 | ||
282 | /* Multiple threads */ | 274 | /* Multiple threads */ |
283 | /* Set the watermark to trigger buffer fill (A/C) FIXME */ | 275 | /* Set the watermark to trigger buffer fill (A/C) */ |
284 | static void set_filebuf_watermark(int seconds, size_t max); | 276 | static void set_filebuf_watermark(void); |
285 | 277 | ||
286 | /* Audio thread */ | 278 | /* Audio thread */ |
287 | static struct event_queue audio_queue SHAREDBSS_ATTR; | 279 | static struct event_queue audio_queue SHAREDBSS_ATTR; |
@@ -797,7 +789,7 @@ void audio_set_buffer_margin(int setting) | |||
797 | static const int lookup[] = {5, 15, 30, 60, 120, 180, 300, 600}; | 789 | static const int lookup[] = {5, 15, 30, 60, 120, 180, 300, 600}; |
798 | buffer_margin = lookup[setting]; | 790 | buffer_margin = lookup[setting]; |
799 | logf("buffer margin: %ld", (long)buffer_margin); | 791 | logf("buffer margin: %ld", (long)buffer_margin); |
800 | set_filebuf_watermark(buffer_margin, 0); | 792 | set_filebuf_watermark(); |
801 | } | 793 | } |
802 | #endif | 794 | #endif |
803 | 795 | ||
@@ -843,16 +835,35 @@ void audio_set_crossfade(int enable) | |||
843 | 835 | ||
844 | /* --- Routines called from multiple threads --- */ | 836 | /* --- Routines called from multiple threads --- */ |
845 | 837 | ||
846 | static void set_filebuf_watermark(int seconds, size_t max) | 838 | static void set_filebuf_watermark(void) |
847 | { | 839 | { |
848 | size_t bytes; | ||
849 | |||
850 | if (!filebuf) | 840 | if (!filebuf) |
851 | return; /* Audio buffers not yet set up */ | 841 | return; /* Audio buffers not yet set up */ |
852 | 842 | ||
853 | bytes = seconds?MAX(curtrack_id3.bitrate * seconds * (1000/8), max):max; | 843 | #ifdef HAVE_FLASH_STORAGE |
854 | bytes = MIN(bytes, filebuflen / 2); | 844 | int seconds = 1; |
845 | #else | ||
846 | int seconds; | ||
847 | int spinup = ata_spinup_time(); | ||
848 | if (spinup) | ||
849 | seconds = (spinup / HZ) + 1; | ||
850 | else | ||
851 | seconds = 3; | ||
852 | #endif | ||
853 | |||
854 | /* bitrate of last track in buffer dictates watermark */ | ||
855 | struct mp3entry* id3 = NULL; | ||
856 | if (tracks[track_widx].taginfo_ready) | ||
857 | id3 = bufgetid3(tracks[track_widx].id3_hid); | ||
858 | else | ||
859 | id3 = bufgetid3(tracks[track_widx-1].id3_hid); | ||
860 | if (!id3) { | ||
861 | logf("fwmark: No id3 for last track (r%d/w%d), aborting!", track_ridx, track_widx); | ||
862 | return; | ||
863 | } | ||
864 | size_t bytes = id3->bitrate * (1000/8) * seconds; | ||
855 | buf_set_watermark(bytes); | 865 | buf_set_watermark(bytes); |
866 | logf("fwmark: %d", bytes); | ||
856 | } | 867 | } |
857 | 868 | ||
858 | const char *get_codec_filename(int cod_spec) | 869 | const char *get_codec_filename(int cod_spec) |
@@ -1106,10 +1117,6 @@ static bool codec_seek_buffer_callback(size_t newpos) | |||
1106 | static void codec_configure_callback(int setting, intptr_t value) | 1117 | static void codec_configure_callback(int setting, intptr_t value) |
1107 | { | 1118 | { |
1108 | switch (setting) { | 1119 | switch (setting) { |
1109 | case CODEC_SET_FILEBUF_WATERMARK: | ||
1110 | set_filebuf_watermark(buffer_margin, value); | ||
1111 | break; | ||
1112 | |||
1113 | default: | 1120 | default: |
1114 | if (!dsp_configure(ci.dsp, setting, value)) | 1121 | if (!dsp_configure(ci.dsp, setting, value)) |
1115 | { logf("Illegal key:%d", setting); } | 1122 | { logf("Illegal key:%d", setting); } |
@@ -1709,7 +1716,7 @@ static bool audio_load_track(size_t offset, bool start_play) | |||
1709 | /* Set default values */ | 1716 | /* Set default values */ |
1710 | if (start_play) | 1717 | if (start_play) |
1711 | { | 1718 | { |
1712 | buf_set_watermark(AUDIO_DEFAULT_WATERMARK); | 1719 | buf_set_watermark(filebuflen/2); |
1713 | dsp_configure(ci.dsp, DSP_RESET, 0); | 1720 | dsp_configure(ci.dsp, DSP_RESET, 0); |
1714 | track_changed = true; | 1721 | track_changed = true; |
1715 | playlist_update_resume_info(audio_current_track()); | 1722 | playlist_update_resume_info(audio_current_track()); |
@@ -2223,10 +2230,6 @@ static void audio_play_start(size_t offset) | |||
2223 | /* Officially playing */ | 2230 | /* Officially playing */ |
2224 | queue_reply(&audio_queue, 1); | 2231 | queue_reply(&audio_queue, 1); |
2225 | 2232 | ||
2226 | #ifdef HAVE_DISK_STORAGE | ||
2227 | set_filebuf_watermark(buffer_margin, 0); | ||
2228 | #endif | ||
2229 | |||
2230 | audio_fill_file_buffer(true, offset); | 2233 | audio_fill_file_buffer(true, offset); |
2231 | 2234 | ||
2232 | add_event(BUFFER_EVENT_BUFFER_LOW, false, buffering_low_buffer_callback); | 2235 | add_event(BUFFER_EVENT_BUFFER_LOW, false, buffering_low_buffer_callback); |
@@ -2358,11 +2361,13 @@ static void audio_reset_buffer(void) | |||
2358 | 2361 | ||
2359 | /* Subtract whatever the pcm buffer says it used plus the guard buffer */ | 2362 | /* Subtract whatever the pcm buffer says it used plus the guard buffer */ |
2360 | const size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) +GUARD_BUFSIZE; | 2363 | const size_t pcmbuf_size = pcmbuf_init(filebuf + filebuflen) +GUARD_BUFSIZE; |
2364 | |||
2361 | #ifdef DEBUG | 2365 | #ifdef DEBUG |
2362 | if(pcmbuf_size > filebuflen) | 2366 | if(pcmbuf_size > filebuflen) |
2363 | panicf("Not enough memory for pcmbuf_init() : %d > %d", | 2367 | panicf("Not enough memory for pcmbuf_init() : %d > %d", |
2364 | (int)pcmbuf_size, (int)filebuflen); | 2368 | (int)pcmbuf_size, (int)filebuflen); |
2365 | #endif | 2369 | #endif |
2370 | |||
2366 | filebuflen -= pcmbuf_size; | 2371 | filebuflen -= pcmbuf_size; |
2367 | 2372 | ||
2368 | /* Make sure filebuflen is a longword multiple after adjustment - filebuf | 2373 | /* Make sure filebuflen is a longword multiple after adjustment - filebuf |
@@ -2414,6 +2419,7 @@ static void audio_thread(void) | |||
2414 | case Q_AUDIO_FILL_BUFFER: | 2419 | case Q_AUDIO_FILL_BUFFER: |
2415 | LOGFQUEUE("audio < Q_AUDIO_FILL_BUFFER %d", (int)ev.data); | 2420 | LOGFQUEUE("audio < Q_AUDIO_FILL_BUFFER %d", (int)ev.data); |
2416 | audio_fill_file_buffer((bool)ev.data, 0); | 2421 | audio_fill_file_buffer((bool)ev.data, 0); |
2422 | set_filebuf_watermark(); | ||
2417 | break; | 2423 | break; |
2418 | 2424 | ||
2419 | case Q_AUDIO_FINISH_LOAD: | 2425 | case Q_AUDIO_FINISH_LOAD: |