summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs.c23
-rw-r--r--apps/codecs.h2
-rw-r--r--apps/playback.c27
3 files changed, 40 insertions, 12 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 400e7fbfcf..dd87ddf0ed 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -56,8 +56,9 @@
56#if CONFIG_HWCODEC == MASNONE 56#if CONFIG_HWCODEC == MASNONE
57static unsigned char codecbuf[CODEC_SIZE]; 57static unsigned char codecbuf[CODEC_SIZE];
58#endif 58#endif
59void *sim_codec_load(char *plugin, int *fd); 59void *sim_codec_load_ram(char* codecptr, int size,
60void sim_codec_close(int fd); 60 void* ptr2, int bufwrap, int *pd);
61void sim_codec_close(int pd);
61#else 62#else
62#define sim_codec_close(x) 63#define sim_codec_close(x)
63extern unsigned char codecbuf[]; 64extern unsigned char codecbuf[];
@@ -245,11 +246,12 @@ struct codec_api ci = {
245 memchr, 246 memchr,
246}; 247};
247 248
248int codec_load_ram(char* codecptr, size_t size, void* ptr2, size_t bufwrap) 249int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap)
249{ 250{
250 enum codec_status (*codec_start)(const struct codec_api* api); 251 enum codec_status (*codec_start)(const struct codec_api* api);
251 int copy_n;
252 int status; 252 int status;
253#ifndef SIMULATOR
254 int copy_n;
253 255
254 if ((char *)&codecbuf[0] != codecptr) { 256 if ((char *)&codecbuf[0] != codecptr) {
255 /* zero out codec buffer to ensure a properly zeroed bss area */ 257 /* zero out codec buffer to ensure a properly zeroed bss area */
@@ -265,8 +267,19 @@ int codec_load_ram(char* codecptr, size_t size, void* ptr2, size_t bufwrap)
265 } 267 }
266 codec_start = (void*)&codecbuf; 268 codec_start = (void*)&codecbuf;
267 269
270#else /* SIMULATOR */
271 int pd;
272
273 codec_start = sim_codec_load_ram(codecptr, size, ptr2, bufwrap, &pd);
274 if (pd < 0)
275 return CODEC_ERROR;
276#endif /* SIMULATOR */
277
268 invalidate_icache(); 278 invalidate_icache();
269 status = codec_start(&ci); 279 status = codec_start(&ci);
280#ifdef SIMULATOR
281 sim_codec_close(pd);
282#endif
270 283
271 return status; 284 return status;
272} 285}
@@ -294,7 +307,7 @@ int codec_load_file(const char *plugin)
294 logf("Codec read error"); 307 logf("Codec read error");
295 return CODEC_ERROR; 308 return CODEC_ERROR;
296 } 309 }
297 310
298 return codec_load_ram(codecbuf, (size_t)rc, NULL, 0); 311 return codec_load_ram(codecbuf, (size_t)rc, NULL, 0);
299} 312}
300 313
diff --git a/apps/codecs.h b/apps/codecs.h
index ea5972968f..73a5709328 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -331,7 +331,7 @@ struct codec_api {
331 331
332/* defined by the codec loader (codec.c) */ 332/* defined by the codec loader (codec.c) */
333#if CONFIG_HWCODEC == MASNONE 333#if CONFIG_HWCODEC == MASNONE
334int codec_load_ram(char* codecptr, size_t size, void* ptr2, size_t bufwrap); 334int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap);
335int codec_load_file(const char* codec); 335int codec_load_file(const char* codec);
336#endif 336#endif
337 337
diff --git a/apps/playback.c b/apps/playback.c
index a1f098b148..e7c1040378 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -191,15 +191,16 @@ void pcm_flush_buffer(long length)
191 191
192void* pcm_request_buffer(long length, long *realsize) 192void* pcm_request_buffer(long length, long *realsize)
193{ 193{
194 (void)length; 194 static char temp_audiobuffer[32768];
195 (void)realsize; 195
196 *realsize = MIN((int)sizeof(temp_audiobuffer), length);
196 197
197 return NULL; 198 return temp_audiobuffer;
198} 199}
199 200
200void audiobuffer_add_event(void (*event_handler)(void)) 201void audiobuffer_add_event(void (*event_handler)(void))
201{ 202{
202 (void)event_handler; 203 event_handler();
203} 204}
204 205
205unsigned int audiobuffer_get_latency() 206unsigned int audiobuffer_get_latency()
@@ -1287,6 +1288,18 @@ void audio_change_track(void)
1287 queue_post(&codec_queue, CODEC_LOAD, 0); 1288 queue_post(&codec_queue, CODEC_LOAD, 0);
1288} 1289}
1289 1290
1291static int get_codec_base_type(int type)
1292{
1293 switch (type) {
1294 case AFMT_MPA_L1:
1295 case AFMT_MPA_L2:
1296 case AFMT_MPA_L3:
1297 return AFMT_MPA_L3;
1298 }
1299
1300 return type;
1301}
1302
1290bool codec_request_next_track_callback(void) 1303bool codec_request_next_track_callback(void)
1291{ 1304{
1292 if (ci.stop_codec || !playing) 1305 if (ci.stop_codec || !playing)
@@ -1361,7 +1374,9 @@ bool codec_request_next_track_callback(void)
1361 1374
1362 ci.reload_codec = false; 1375 ci.reload_codec = false;
1363 1376
1364 if (cur_ti->id3.codectype != tracks[track_ridx].id3.codectype) { 1377 /* Check if the next codec is the same file. */
1378 if (get_codec_base_type(cur_ti->id3.codectype) !=
1379 get_codec_base_type(tracks[track_ridx].id3.codectype)) {
1365 logf("New codec:%d/%d", cur_ti->id3.codectype, 1380 logf("New codec:%d/%d", cur_ti->id3.codectype,
1366 tracks[track_ridx].id3.codectype); 1381 tracks[track_ridx].id3.codectype);
1367 if (--track_ridx < 0) 1382 if (--track_ridx < 0)
@@ -1436,7 +1451,7 @@ void audio_thread(void)
1436 ci.stop_codec = true; 1451 ci.stop_codec = true;
1437 ci.reload_codec = false; 1452 ci.reload_codec = false;
1438 ci.seek_time = 0; 1453 ci.seek_time = 0;
1439 if (!pcm_crossfade_init()) 1454 if (!pcm_crossfade_init() && !pcm_is_crossfade_active())
1440 pcm_flush_audio(); 1455 pcm_flush_audio();
1441 audio_play_start((int)ev.data); 1456 audio_play_start((int)ev.data);
1442 playlist_update_resume_info(audio_current_track()); 1457 playlist_update_resume_info(audio_current_track());