summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-03-04 04:16:53 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-03-04 04:16:53 +0000
commit598629c3bf4bf683812c374af7791f06777873f7 (patch)
tree8525f563adc7656a9a00e793fe14e6a9bb48fdef /apps
parenta61a7fa7aea82a2ead1b0c4ac4b476254589b959 (diff)
downloadrockbox-598629c3bf4bf683812c374af7791f06777873f7.tar.gz
rockbox-598629c3bf4bf683812c374af7791f06777873f7.zip
SWCODEC Recording Codecs: Fix problems with hanging recording screen (chiefly on x5) when no voice file present and source is not FMRadio. Caused by extra audio stops causing encoder to unload prematurely. Fix is to have separate stop flags for each codec type to prevent collisions. Also now safe to plug into USB when recording and encoder will stay loaded and not be stopped by the call to audio_stop_playback. Additional discovery: playback will not be able to restart after a USB plug during recording. Probably an old bug. I recommend in the future that recording have higher priority on system resources than playback and playback be denied access explicitly if recording requires them. Codec API becomes incompatible so do full updates.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12579 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs.c5
-rw-r--r--apps/codecs.h5
-rw-r--r--apps/codecs/aiff_enc.c4
-rw-r--r--apps/codecs/mp3_enc.c4
-rw-r--r--apps/codecs/wav_enc.c4
-rw-r--r--apps/codecs/wavpack_enc.c6
-rw-r--r--apps/playback.c20
7 files changed, 19 insertions, 29 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 09fd6e522e..0c6ddd0422 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -215,14 +215,15 @@ struct codec_api ci = {
215#endif 215#endif
216 216
217#if defined(HAVE_RECORDING) && !defined(SIMULATOR) 217#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
218 false, 218 false, /* stop_encoder */
219 0, /* enc_codec_loaded */
219 enc_get_inputs, 220 enc_get_inputs,
220 enc_set_parameters, 221 enc_set_parameters,
221 enc_get_chunk, 222 enc_get_chunk,
222 enc_finish_chunk, 223 enc_finish_chunk,
223 enc_pcm_buf_near_empty, 224 enc_pcm_buf_near_empty,
224 enc_get_pcm_data, 225 enc_get_pcm_data,
225 enc_unget_pcm_data 226 enc_unget_pcm_data,
226#endif 227#endif
227 228
228 /* new stuff at the end, sort into place next time 229 /* new stuff at the end, sort into place next time
diff --git a/apps/codecs.h b/apps/codecs.h
index 3d7ead159e..6710afdc8e 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -90,12 +90,12 @@
90#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ 90#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
91 91
92/* increase this every time the api struct changes */ 92/* increase this every time the api struct changes */
93#define CODEC_API_VERSION 14 93#define CODEC_API_VERSION 15
94 94
95/* update this to latest version if a change to the api struct breaks 95/* update this to latest version if a change to the api struct breaks
96 backwards compatibility (and please take the opportunity to sort in any 96 backwards compatibility (and please take the opportunity to sort in any
97 new function which are "waiting" at the end of the function table) */ 97 new function which are "waiting" at the end of the function table) */
98#define CODEC_MIN_API_VERSION 14 98#define CODEC_MIN_API_VERSION 15
99 99
100/* codec return codes */ 100/* codec return codes */
101enum codec_status { 101enum codec_status {
@@ -303,6 +303,7 @@ struct codec_api {
303#endif 303#endif
304 304
305#if defined(HAVE_RECORDING) && !defined(SIMULATOR) 305#if defined(HAVE_RECORDING) && !defined(SIMULATOR)
306 volatile bool stop_encoder;
306 volatile int enc_codec_loaded; /* <0=error, 0=pending, >0=ok */ 307 volatile int enc_codec_loaded; /* <0=error, 0=pending, >0=ok */
307 void (*enc_get_inputs)(struct enc_inputs *inputs); 308 void (*enc_get_inputs)(struct enc_inputs *inputs);
308 void (*enc_set_parameters)(struct enc_parameters *params); 309 void (*enc_set_parameters)(struct enc_parameters *params);
diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c
index 02d159e52f..1de25a4915 100644
--- a/apps/codecs/aiff_enc.c
+++ b/apps/codecs/aiff_enc.c
@@ -354,7 +354,7 @@ enum codec_status codec_main(void)
354#endif 354#endif
355 355
356 /* main encoding loop */ 356 /* main encoding loop */
357 while(!ci->stop_codec) 357 while(!ci->stop_encoder)
358 { 358 {
359 uint32_t *src; 359 uint32_t *src;
360 360
@@ -362,7 +362,7 @@ enum codec_status codec_main(void)
362 { 362 {
363 struct enc_chunk_hdr *chunk; 363 struct enc_chunk_hdr *chunk;
364 364
365 if (ci->stop_codec) 365 if (ci->stop_encoder)
366 break; 366 break;
367 367
368#ifdef HAVE_ADJUSTABLE_CPU_FREQ 368#ifdef HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c
index 81ea47e56b..daa6cfefa6 100644
--- a/apps/codecs/mp3_enc.c
+++ b/apps/codecs/mp3_enc.c
@@ -2482,7 +2482,7 @@ enum codec_status codec_main(void)
2482#endif 2482#endif
2483 2483
2484 /* main encoding loop */ 2484 /* main encoding loop */
2485 while (!ci->stop_codec) 2485 while (!ci->stop_encoder)
2486 { 2486 {
2487 char *buffer; 2487 char *buffer;
2488 2488
@@ -2490,7 +2490,7 @@ enum codec_status codec_main(void)
2490 { 2490 {
2491 struct enc_chunk_hdr *chunk; 2491 struct enc_chunk_hdr *chunk;
2492 2492
2493 if (ci->stop_codec) 2493 if (ci->stop_encoder)
2494 break; 2494 break;
2495 2495
2496#ifdef HAVE_ADJUSTABLE_CPU_FREQ 2496#ifdef HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c
index 622ff3a6d1..e14b04ddd3 100644
--- a/apps/codecs/wav_enc.c
+++ b/apps/codecs/wav_enc.c
@@ -342,7 +342,7 @@ enum codec_status codec_main(void)
342#endif 342#endif
343 343
344 /* main encoding loop */ 344 /* main encoding loop */
345 while(!ci->stop_codec) 345 while(!ci->stop_encoder)
346 { 346 {
347 uint32_t *src; 347 uint32_t *src;
348 348
@@ -350,7 +350,7 @@ enum codec_status codec_main(void)
350 { 350 {
351 struct enc_chunk_hdr *chunk; 351 struct enc_chunk_hdr *chunk;
352 352
353 if (ci->stop_codec) 353 if (ci->stop_encoder)
354 break; 354 break;
355 355
356#ifdef HAVE_ADJUSTABLE_CPU_FREQ 356#ifdef HAVE_ADJUSTABLE_CPU_FREQ
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c
index 547d309159..de8fe80423 100644
--- a/apps/codecs/wavpack_enc.c
+++ b/apps/codecs/wavpack_enc.c
@@ -408,7 +408,7 @@ enum codec_status codec_main(void)
408#endif 408#endif
409 409
410 /* main encoding loop */ 410 /* main encoding loop */
411 while(!ci->stop_codec) 411 while(!ci->stop_encoder)
412 { 412 {
413 uint8_t *src; 413 uint8_t *src;
414 414
@@ -419,7 +419,7 @@ enum codec_status codec_main(void)
419 uint8_t *dst; 419 uint8_t *dst;
420 uint8_t *src_end; 420 uint8_t *src_end;
421 421
422 if(ci->stop_codec) 422 if(ci->stop_encoder)
423 break; 423 break;
424 424
425 abort_chunk = true; 425 abort_chunk = true;
@@ -455,7 +455,7 @@ enum codec_status codec_main(void)
455 chunk->num_pcm += PCM_SAMP_PER_CHUNK/4; 455 chunk->num_pcm += PCM_SAMP_PER_CHUNK/4;
456 ci->yield(); 456 ci->yield();
457 /* could've been stopped in some way */ 457 /* could've been stopped in some way */
458 abort_chunk = ci->stop_codec || 458 abort_chunk = ci->stop_encoder ||
459 (chunk->flags & CHUNKF_ABORT); 459 (chunk->flags & CHUNKF_ABORT);
460 } 460 }
461 461
diff --git a/apps/playback.c b/apps/playback.c
index d09d672dff..1b7aa68b85 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -138,10 +138,6 @@ enum {
138#if MEM > 8 138#if MEM > 8
139 Q_AUDIO_FILL_BUFFER_IF_ACTIVE_ATA, 139 Q_AUDIO_FILL_BUFFER_IF_ACTIVE_ATA,
140#endif 140#endif
141#ifdef AUDIO_HAVE_RECORDING
142 Q_AUDIO_LOAD_ENCODER,
143#endif
144
145#if 0 141#if 0
146 Q_CODEC_REQUEST_PENDING, 142 Q_CODEC_REQUEST_PENDING,
147#endif 143#endif
@@ -525,8 +521,8 @@ bool audio_load_encoder(int afmt)
525 audio_remove_encoder(); 521 audio_remove_encoder();
526 ci.enc_codec_loaded = 0; /* clear any previous error condition */ 522 ci.enc_codec_loaded = 0; /* clear any previous error condition */
527 523
528 LOGFQUEUE("audio > Q_AUDIO_LOAD_ENCODER"); 524 LOGFQUEUE("codec > Q_ENCODER_LOAD_DISK");
529 queue_post(&audio_queue, Q_AUDIO_LOAD_ENCODER, (intptr_t)enc_fn); 525 queue_post(&codec_queue, Q_ENCODER_LOAD_DISK, (intptr_t)enc_fn);
530 526
531 while (ci.enc_codec_loaded == 0) 527 while (ci.enc_codec_loaded == 0)
532 yield(); 528 yield();
@@ -547,7 +543,7 @@ void audio_remove_encoder(void)
547 if (ci.enc_codec_loaded <= 0) 543 if (ci.enc_codec_loaded <= 0)
548 return; 544 return;
549 545
550 ci.stop_codec = true; 546 ci.stop_encoder = true;
551 while (ci.enc_codec_loaded > 0) 547 while (ci.enc_codec_loaded > 0)
552 yield(); 548 yield();
553#endif 549#endif
@@ -2003,7 +1999,7 @@ static void codec_thread(void)
2003#endif 1999#endif
2004 logf("loading encoder"); 2000 logf("loading encoder");
2005 set_current_codec(CODEC_IDX_AUDIO); 2001 set_current_codec(CODEC_IDX_AUDIO);
2006 ci.stop_codec = false; 2002 ci.stop_encoder = false;
2007 status = codec_load_file((const char *)ev.data, &ci); 2003 status = codec_load_file((const char *)ev.data, &ci);
2008#ifdef PLAYBACK_VOICE 2004#ifdef PLAYBACK_VOICE
2009 mutex_unlock(&mutex_codecthread); 2005 mutex_unlock(&mutex_codecthread);
@@ -3691,14 +3687,6 @@ static void audio_thread(void)
3691 playlist_update_resume_info(audio_current_track()); 3687 playlist_update_resume_info(audio_current_track());
3692 break ; 3688 break ;
3693 3689
3694#ifdef AUDIO_HAVE_RECORDING
3695 case Q_AUDIO_LOAD_ENCODER:
3696 LOGFQUEUE("audio < Q_AUDIO_LOAD_ENCODER");
3697 LOGFQUEUE("audio > codec Q_ENCODER_LOAD_DISK");
3698 queue_post(&codec_queue, Q_ENCODER_LOAD_DISK, ev.data);
3699 break;
3700#endif
3701
3702#ifndef SIMULATOR 3690#ifndef SIMULATOR
3703 case SYS_USB_CONNECTED: 3691 case SYS_USB_CONNECTED:
3704 LOGFQUEUE("audio < SYS_USB_CONNECTED"); 3692 LOGFQUEUE("audio < SYS_USB_CONNECTED");