diff options
Diffstat (limited to 'apps/pcmbuf.c')
-rw-r--r-- | apps/pcmbuf.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index cc454a49ce..ff9b3e16a2 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "settings.h" | 40 | #include "settings.h" |
41 | #include "audio.h" | 41 | #include "audio.h" |
42 | #include "voice_thread.h" | 42 | #include "voice_thread.h" |
43 | #include "dsp_core.h" | ||
44 | 43 | ||
45 | /* This is the target fill size of chunks on the pcm buffer | 44 | /* This is the target fill size of chunks on the pcm buffer |
46 | Can be any number of samples but power of two sizes make for faster and | 45 | Can be any number of samples but power of two sizes make for faster and |
@@ -66,11 +65,11 @@ | |||
66 | chunks */ | 65 | chunks */ |
67 | 66 | ||
68 | /* Return data level in 1/4-second increments */ | 67 | /* Return data level in 1/4-second increments */ |
69 | #define DATA_LEVEL(quarter_secs) (NATIVE_FREQUENCY * (quarter_secs)) | 68 | #define DATA_LEVEL(quarter_secs) (pcmbuf_sampr * (quarter_secs)) |
70 | 69 | ||
71 | /* Number of bytes played per second: | 70 | /* Number of bytes played per second: |
72 | (sample rate * 2 channels * 2 bytes/sample) */ | 71 | (sample rate * 2 channels * 2 bytes/sample) */ |
73 | #define BYTERATE (NATIVE_FREQUENCY * 4) | 72 | #define BYTERATE (pcmbuf_sampr * 2 * 2) |
74 | 73 | ||
75 | #if MEMORYSIZE > 2 | 74 | #if MEMORYSIZE > 2 |
76 | /* Keep watermark high for large memory target - at least (2s) */ | 75 | /* Keep watermark high for large memory target - at least (2s) */ |
@@ -104,6 +103,7 @@ static size_t pcmbuf_size; | |||
104 | static struct chunkdesc *pcmbuf_descriptors; | 103 | static struct chunkdesc *pcmbuf_descriptors; |
105 | static unsigned int pcmbuf_desc_count; | 104 | static unsigned int pcmbuf_desc_count; |
106 | static unsigned int position_key = 1; | 105 | static unsigned int position_key = 1; |
106 | static unsigned int pcmbuf_sampr = 0; | ||
107 | 107 | ||
108 | static size_t chunk_ridx; | 108 | static size_t chunk_ridx; |
109 | static size_t chunk_widx; | 109 | static size_t chunk_widx; |
@@ -111,8 +111,7 @@ static size_t chunk_widx; | |||
111 | static size_t pcmbuf_bytes_waiting; | 111 | static size_t pcmbuf_bytes_waiting; |
112 | static struct chunkdesc *current_desc; | 112 | static struct chunkdesc *current_desc; |
113 | 113 | ||
114 | /* Only written if HAVE_CROSSFADE */ | 114 | static size_t pcmbuf_watermark = 0; |
115 | static size_t pcmbuf_watermark = PCMBUF_WATERMARK; | ||
116 | 115 | ||
117 | static bool low_latency_mode = false; | 116 | static bool low_latency_mode = false; |
118 | 117 | ||
@@ -545,6 +544,8 @@ size_t pcmbuf_init(void *bufend) | |||
545 | } | 544 | } |
546 | 545 | ||
547 | pcmbuf_finish_crossfade_enable(); | 546 | pcmbuf_finish_crossfade_enable(); |
547 | #else | ||
548 | pcmbuf_watermark = PCMBUF_WATERMARK; | ||
548 | #endif /* HAVE_CROSSFADE */ | 549 | #endif /* HAVE_CROSSFADE */ |
549 | 550 | ||
550 | init_buffer_state(); | 551 | init_buffer_state(); |
@@ -1331,3 +1332,13 @@ void pcmbuf_set_low_latency(bool state) | |||
1331 | { | 1332 | { |
1332 | low_latency_mode = state; | 1333 | low_latency_mode = state; |
1333 | } | 1334 | } |
1335 | |||
1336 | void pcmbuf_update_frequency(void) | ||
1337 | { | ||
1338 | pcmbuf_sampr = mixer_get_frequency(); | ||
1339 | } | ||
1340 | |||
1341 | unsigned int pcmbuf_get_frequency(void) | ||
1342 | { | ||
1343 | return pcmbuf_sampr; | ||
1344 | } | ||