diff options
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 3969972ea8..f1402950a9 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -63,8 +63,8 @@ | |||
63 | #include "pcm_playback.h" | 63 | #include "pcm_playback.h" |
64 | #include "buffer.h" | 64 | #include "buffer.h" |
65 | 65 | ||
66 | #define CHUNK_SIZE 44100 /* Transfer CHUNK_SIZE bytes on | 66 | #define CHUNK_SIZE 0x100000 /* Transfer CHUNK_SIZE bytes on |
67 | each DMA transfer */ | 67 | each DMA transfer */ |
68 | 68 | ||
69 | static unsigned char line = 0; | 69 | static unsigned char line = 0; |
70 | static unsigned char *audio_buffer; | 70 | static unsigned char *audio_buffer; |
@@ -95,9 +95,9 @@ static void puts(const char *fmt, ...) | |||
95 | /* Very basic WAVE-file support.. Just for testing purposes.. */ | 95 | /* Very basic WAVE-file support.. Just for testing purposes.. */ |
96 | int load_wave(char *filename) | 96 | int load_wave(char *filename) |
97 | { | 97 | { |
98 | int f, i; | 98 | int f, i, num; |
99 | unsigned char buf[32]; | 99 | unsigned char buf[32]; |
100 | unsigned short *p; | 100 | unsigned short *p, *end; |
101 | 101 | ||
102 | puts("Loading %s..", filename); | 102 | puts("Loading %s..", filename); |
103 | 103 | ||
@@ -136,10 +136,18 @@ int load_wave(char *filename) | |||
136 | close(f); | 136 | close(f); |
137 | 137 | ||
138 | puts("Changing byte order.."); | 138 | puts("Changing byte order.."); |
139 | end = (unsigned short *)(audio_buffer + audio_size); | ||
139 | p = (unsigned short *)audio_buffer; | 140 | p = (unsigned short *)audio_buffer; |
140 | for (i=0; i<audio_size/2; i++, p++) | 141 | while(p < end) |
141 | { | 142 | { |
142 | *p = SWAB16(*p); | 143 | /* Swap 128k at a time, to allow the other threads to run */ |
144 | num = MIN(0x20000, (int)(end - p)); | ||
145 | for(i = 0;i < num;i++) | ||
146 | { | ||
147 | *p = SWAB16(*p); | ||
148 | p++; | ||
149 | } | ||
150 | yield(); | ||
143 | } | 151 | } |
144 | 152 | ||
145 | return 0; | 153 | return 0; |
@@ -152,20 +160,14 @@ int load_wave(char *filename) | |||
152 | 160 | ||
153 | */ | 161 | */ |
154 | 162 | ||
155 | static void test_get_more(unsigned char **ptr, long *size) | 163 | int test_tracknum; |
164 | static void test_trackchange(void) | ||
156 | { | 165 | { |
157 | static long last_chunk_size = 0; | 166 | test_tracknum++; |
158 | |||
159 | audio_pos += last_chunk_size; | ||
160 | |||
161 | if(audio_pos < audio_size) | ||
162 | { | ||
163 | last_chunk_size = MIN(CHUNK_SIZE, (audio_size - audio_pos)); | ||
164 | *ptr = &audio_buffer[audio_pos]; | ||
165 | *size = last_chunk_size; | ||
166 | } | ||
167 | } | 167 | } |
168 | 168 | ||
169 | extern int pcmbuf_unplayed_bytes; | ||
170 | |||
169 | bool uda1380_test(void) | 171 | bool uda1380_test(void) |
170 | { | 172 | { |
171 | long button; | 173 | long button; |
@@ -173,11 +175,15 @@ bool uda1380_test(void) | |||
173 | bool done = false; | 175 | bool done = false; |
174 | char buf[80]; | 176 | char buf[80]; |
175 | bool play = true; | 177 | bool play = true; |
178 | int sz; | ||
179 | char *ptr; | ||
176 | 180 | ||
177 | lcd_setmargins(0, 0); | 181 | lcd_setmargins(0, 0); |
178 | lcd_clear_display(); | 182 | lcd_clear_display(); |
179 | lcd_update(); | 183 | lcd_update(); |
180 | 184 | ||
185 | test_tracknum = 1; | ||
186 | |||
181 | line = 0; | 187 | line = 0; |
182 | 188 | ||
183 | if (load_wave("/sample.wav") == -1) | 189 | if (load_wave("/sample.wav") == -1) |
@@ -188,10 +194,19 @@ bool uda1380_test(void) | |||
188 | puts("Playing.."); | 194 | puts("Playing.."); |
189 | 195 | ||
190 | audio_pos = 0; | 196 | audio_pos = 0; |
197 | pcm_play_init(); | ||
191 | pcm_set_frequency(44100); | 198 | pcm_set_frequency(44100); |
192 | pcm_set_volume(0xff - vol); | 199 | pcm_set_volume(0xff - vol); |
193 | pcm_play_data(audio_buffer, CHUNK_SIZE, | 200 | |
194 | test_get_more); | 201 | ptr = audio_buffer; |
202 | for(sz = 0;sz < audio_size;sz += CHUNK_SIZE) | ||
203 | { | ||
204 | if(!pcm_play_add_chunk(ptr, CHUNK_SIZE, test_trackchange)) | ||
205 | break; | ||
206 | ptr += MIN(CHUNK_SIZE, (audio_size - sz)); | ||
207 | } | ||
208 | |||
209 | pcm_play_start(); | ||
195 | 210 | ||
196 | while(!done) | 211 | while(!done) |
197 | { | 212 | { |
@@ -205,6 +220,10 @@ bool uda1380_test(void) | |||
205 | lcd_puts(0, line+3, buf); | 220 | lcd_puts(0, line+3, buf); |
206 | snprintf(buf, sizeof(buf), "DSR0: %02x", DSR0); | 221 | snprintf(buf, sizeof(buf), "DSR0: %02x", DSR0); |
207 | lcd_puts(0, line+4, buf); | 222 | lcd_puts(0, line+4, buf); |
223 | snprintf(buf, sizeof(buf), "Track: %d", test_tracknum); | ||
224 | lcd_puts(0, line+5, buf); | ||
225 | snprintf(buf, sizeof(buf), "Unplayed: %08x", pcmbuf_unplayed_bytes); | ||
226 | lcd_puts(0, line+6, buf); | ||
208 | lcd_update(); | 227 | lcd_update(); |
209 | 228 | ||
210 | button = button_get_w_tmo(HZ/2); | 229 | button = button_get_w_tmo(HZ/2); |