summaryrefslogtreecommitdiff
path: root/apps/codec_thread.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
commit7ad2cad173ffa094bb285112582afee1c9aea4e5 (patch)
treece23e816cfdffb1767ebe44f4f960c304d8a5fb9 /apps/codec_thread.c
parent463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08 (diff)
downloadrockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.tar.gz
rockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.zip
Commit work started in FS#12153 to put timing/position information in PCM
buffer chunks. * Samples and position indication is closely associated with audio data instead of compensating by a latency constant. Alleviates problems with using the elapsed as a track indicator where it could be off by several steps. * Timing is accurate throughout track even if resampling for pitch shift, whereas before it updated during transition latency at the normal 1:1 rate. * Simpler PCM buffer with a constant chunk size, no linked lists. In converting crossfade, a minor change was made to not change the WPS until the fade-in of the incoming track, whereas before it would change upon the start of the fade-out of the outgoing track possibly having the WPS change with far too much lead time. Codec changes are to set elapsed times *before* writing next PCM frame because time and position data last set are saved in the next committed PCM chunk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30366 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codec_thread.c')
-rw-r--r--apps/codec_thread.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index 945f0b0605..199bb0e742 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -77,9 +77,10 @@ struct codec_load_info
77static int codec_type = AFMT_UNKNOWN; /* Codec type (C,A-) */ 77static int codec_type = AFMT_UNKNOWN; /* Codec type (C,A-) */
78 78
79/* Private interfaces to main playback control */ 79/* Private interfaces to main playback control */
80extern void audio_codec_update_elapsed(unsigned long value); 80extern void audio_codec_update_elapsed(unsigned long elapsed);
81extern void audio_codec_update_offset(size_t value); 81extern void audio_codec_update_offset(size_t offset);
82extern void audio_queue_post(long id, intptr_t data); 82extern void audio_codec_complete(int status);
83extern void audio_codec_seek_complete(void);
83extern struct codec_api ci; /* from codecs.c */ 84extern struct codec_api ci; /* from codecs.c */
84 85
85/* Codec thread */ 86/* Codec thread */
@@ -251,7 +252,7 @@ static void codec_pcmbuf_insert_callback(
251 if (out_count <= 0) 252 if (out_count <= 0)
252 return; 253 return;
253 254
254 pcmbuf_write_complete(out_count); 255 pcmbuf_write_complete(out_count, ci.id3->elapsed, ci.id3->offset);
255 256
256 count -= inp_count; 257 count -= inp_count;
257 } 258 }
@@ -334,9 +335,11 @@ static void codec_seek_complete_callback(void)
334 /* Clear DSP */ 335 /* Clear DSP */
335 dsp_configure(ci.dsp, DSP_FLUSH, 0); 336 dsp_configure(ci.dsp, DSP_FLUSH, 0);
336 337
338 /* Sync position */
339 audio_codec_update_offset(ci.curpos);
340
337 /* Post notification to audio thread */ 341 /* Post notification to audio thread */
338 LOGFQUEUE("audio > Q_AUDIO_CODEC_SEEK_COMPLETE"); 342 audio_codec_seek_complete();
339 audio_queue_post(Q_AUDIO_CODEC_SEEK_COMPLETE, 0);
340 343
341 /* Wait for urgent or go message */ 344 /* Wait for urgent or go message */
342 do 345 do
@@ -521,8 +524,7 @@ static void run_codec(void)
521 524
522 /* Notify audio that we're done for better or worse - advise of the 525 /* Notify audio that we're done for better or worse - advise of the
523 status */ 526 status */
524 LOGFQUEUE("codec > audio Q_AUDIO_CODEC_COMPLETE: %d", status); 527 audio_codec_complete(status);
525 audio_queue_post(Q_AUDIO_CODEC_COMPLETE, status);
526 } 528 }
527} 529}
528 530