From 9a625ef7ac544976f45734d62294a52ef32cfe66 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 24 Sep 2005 12:35:18 +0000 Subject: Add yield() calls inside the monolithic ALAC decode_frame() function - improves responsiveness of UI during ALAC decoding git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7557 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libalac/alac.c | 17 ++++++++++++++++- apps/codecs/libalac/decomp.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'apps/codecs/libalac') diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c index ae1b413eab..bdfb714a57 100644 --- a/apps/codecs/libalac/alac.c +++ b/apps/codecs/libalac/alac.c @@ -645,7 +645,8 @@ void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, int16_t* decode_frame(alac_file *alac, unsigned char *inbuffer, - int *outputsize) + int *outputsize, + void (*yield)(void)) { int channels; int16_t* outbuffer; @@ -730,6 +731,8 @@ int16_t* decode_frame(alac_file *alac, //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); } + yield(); + basterdised_rice_decompress(alac, predicterror_buffer_a, outputsamples, @@ -739,6 +742,8 @@ int16_t* decode_frame(alac_file *alac, ricemodifier * alac->setinfo_rice_historymult / 4, (1 << alac->setinfo_rice_kmodifier) - 1); + yield(); + if (prediction_type == 0) { /* adaptive fir */ predictor_decompress_fir_adapt(predicterror_buffer_a, @@ -796,6 +801,8 @@ int16_t* decode_frame(alac_file *alac, /* wasted_bytes = 0; // unused */ } + yield(); + switch(alac->setinfo_sample_size) { case 16: @@ -853,6 +860,7 @@ int16_t* decode_frame(alac_file *alac, readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1; + yield(); if (!isnotcompressed) { /* compressed */ int predictor_coef_num_a; @@ -902,6 +910,7 @@ int16_t* decode_frame(alac_file *alac, //fprintf(stderr, "FIXME: unimplemented, unhandling of wasted_bytes\n"); } + yield(); /* channel 1 */ basterdised_rice_decompress(alac, predicterror_buffer_a, @@ -912,6 +921,7 @@ int16_t* decode_frame(alac_file *alac, ricemodifier_a * alac->setinfo_rice_historymult / 4, (1 << alac->setinfo_rice_kmodifier) - 1); + yield(); if (prediction_type_a == 0) { /* adaptive fir */ predictor_decompress_fir_adapt(predicterror_buffer_a, @@ -927,6 +937,8 @@ int16_t* decode_frame(alac_file *alac, //fprintf(stderr, "FIXME: unhandled predicition type: %i\n", prediction_type_a); } + yield(); + /* channel 2 */ basterdised_rice_decompress(alac, predicterror_buffer_b, @@ -937,6 +949,7 @@ int16_t* decode_frame(alac_file *alac, ricemodifier_b * alac->setinfo_rice_historymult / 4, (1 << alac->setinfo_rice_kmodifier) - 1); + yield(); if (prediction_type_b == 0) { /* adaptive fir */ predictor_decompress_fir_adapt(predicterror_buffer_b, @@ -997,6 +1010,8 @@ int16_t* decode_frame(alac_file *alac, interlacing_leftweight = 0; } + yield(); + switch(alac->setinfo_sample_size) { case 16: diff --git a/apps/codecs/libalac/decomp.h b/apps/codecs/libalac/decomp.h index e6fa82d3d7..15b8910681 100644 --- a/apps/codecs/libalac/decomp.h +++ b/apps/codecs/libalac/decomp.h @@ -28,7 +28,8 @@ typedef struct void create_alac(int samplesize, int numchannels, alac_file* alac); int16_t* decode_frame(alac_file *alac, unsigned char *inbuffer, - int *outputsize); + int *outputsize, + void (*yield)(void)); void alac_set_info(alac_file *alac, char *inputbuffer); #endif /* __ALAC__DECOMP_H */ -- cgit v1.2.3