diff options
author | Mohamed Tarek <mt@rockbox.org> | 2009-11-18 00:41:46 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2009-11-18 00:41:46 +0000 |
commit | 9669bbc135f3026858f8359555c1c3221d970f7f (patch) | |
tree | 0b52a67baa9e7538d8b96606740d1b5531d2e030 | |
parent | 9ccccce65505541548bfba6dcf5b280f3ebc785e (diff) | |
download | rockbox-9669bbc135f3026858f8359555c1c3221d970f7f.tar.gz rockbox-9669bbc135f3026858f8359555c1c3221d970f7f.zip |
Handle mid-track resumes in RM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23659 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/a52_rm.c | 11 | ||||
-rw-r--r-- | apps/codecs/atrac3_rm.c | 12 | ||||
-rw-r--r-- | apps/codecs/cook.c | 10 | ||||
-rw-r--r-- | apps/codecs/raac.c | 10 |
4 files changed, 41 insertions, 2 deletions
diff --git a/apps/codecs/a52_rm.c b/apps/codecs/a52_rm.c index 32b66d2826..1fe7312e03 100644 --- a/apps/codecs/a52_rm.c +++ b/apps/codecs/a52_rm.c | |||
@@ -131,7 +131,8 @@ enum codec_status codec_main(void) | |||
131 | size_t n; | 131 | size_t n; |
132 | uint8_t *filebuf; | 132 | uint8_t *filebuf; |
133 | int retval, consumed, packet_offset; | 133 | int retval, consumed, packet_offset; |
134 | int playback_on = -1; | 134 | int playback_on = -1; |
135 | size_t resume_offset = ci->id3->offset; | ||
135 | 136 | ||
136 | /* Generic codec initialisation */ | 137 | /* Generic codec initialisation */ |
137 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); | 138 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); |
@@ -155,6 +156,14 @@ next_track: | |||
155 | ci->memset(&pkt,0,sizeof(RMPacket)); | 156 | ci->memset(&pkt,0,sizeof(RMPacket)); |
156 | init_rm(&rmctx); | 157 | init_rm(&rmctx); |
157 | 158 | ||
159 | /* check for a mid-track resume and force a seek time accordingly */ | ||
160 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | ||
161 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | ||
162 | /* put number of subpackets to skip in resume_offset */ | ||
163 | resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); | ||
164 | ci->seek_time = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); | ||
165 | } | ||
166 | |||
158 | /* Seek to the first packet */ | 167 | /* Seek to the first packet */ |
159 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); | 168 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); |
160 | 169 | ||
diff --git a/apps/codecs/atrac3_rm.c b/apps/codecs/atrac3_rm.c index 75c0d1581b..d3e00c0e6f 100644 --- a/apps/codecs/atrac3_rm.c +++ b/apps/codecs/atrac3_rm.c | |||
@@ -45,6 +45,7 @@ enum codec_status codec_main(void) | |||
45 | uint32_t packet_count; | 45 | uint32_t packet_count; |
46 | int scrambling_unit_size, num_units, elapsed = 0; | 46 | int scrambling_unit_size, num_units, elapsed = 0; |
47 | int playback_on = -1; | 47 | int playback_on = -1; |
48 | size_t resume_offset = ci->id3->offset; | ||
48 | 49 | ||
49 | next_track: | 50 | next_track: |
50 | if (codec_init()) { | 51 | if (codec_init()) { |
@@ -80,6 +81,15 @@ next_track: | |||
80 | return CODEC_ERROR; | 81 | return CODEC_ERROR; |
81 | } | 82 | } |
82 | 83 | ||
84 | /* check for a mid-track resume and force a seek time accordingly */ | ||
85 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | ||
86 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | ||
87 | num_units = (int)resume_offset / scrambling_unit_size; | ||
88 | /* put number of subpackets to skip in resume_offset */ | ||
89 | resume_offset /= (sps + PACKET_HEADER_SIZE); | ||
90 | ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); | ||
91 | } | ||
92 | |||
83 | ci->set_elapsed(0); | 93 | ci->set_elapsed(0); |
84 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); | 94 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); |
85 | 95 | ||
@@ -98,7 +108,7 @@ seek_start : | |||
98 | else | 108 | else |
99 | goto done; | 109 | goto done; |
100 | } | 110 | } |
101 | 111 | ||
102 | for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) | 112 | for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++) |
103 | { | 113 | { |
104 | ci->yield(); | 114 | ci->yield(); |
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c index c9039a480c..5f91d244ff 100644 --- a/apps/codecs/cook.c +++ b/apps/codecs/cook.c | |||
@@ -45,6 +45,7 @@ enum codec_status codec_main(void) | |||
45 | uint16_t fs,sps,h; | 45 | uint16_t fs,sps,h; |
46 | uint32_t packet_count; | 46 | uint32_t packet_count; |
47 | int scrambling_unit_size, num_units; | 47 | int scrambling_unit_size, num_units; |
48 | size_t resume_offset = ci->id3->offset; | ||
48 | 49 | ||
49 | next_track: | 50 | next_track: |
50 | if (codec_init()) { | 51 | if (codec_init()) { |
@@ -79,6 +80,15 @@ next_track: | |||
79 | DEBUGF("failed to initialize cook decoder\n"); | 80 | DEBUGF("failed to initialize cook decoder\n"); |
80 | return CODEC_ERROR; | 81 | return CODEC_ERROR; |
81 | } | 82 | } |
83 | |||
84 | /* check for a mid-track resume and force a seek time accordingly */ | ||
85 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | ||
86 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | ||
87 | num_units = (int)resume_offset / scrambling_unit_size; | ||
88 | /* put number of subpackets to skip in resume_offset */ | ||
89 | resume_offset /= (sps + PACKET_HEADER_SIZE); | ||
90 | ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); | ||
91 | } | ||
82 | 92 | ||
83 | ci->set_elapsed(0); | 93 | ci->set_elapsed(0); |
84 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); | 94 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); |
diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c index b886136bd9..516828093d 100644 --- a/apps/codecs/raac.c +++ b/apps/codecs/raac.c | |||
@@ -48,6 +48,7 @@ enum codec_status codec_main(void) | |||
48 | uint32_t s = 0; /* sample rate */ | 48 | uint32_t s = 0; /* sample rate */ |
49 | unsigned char c = 0; /* channels */ | 49 | unsigned char c = 0; /* channels */ |
50 | int playback_on = -1; | 50 | int playback_on = -1; |
51 | size_t resume_offset = ci->id3->offset; | ||
51 | 52 | ||
52 | /* Generic codec initialisation */ | 53 | /* Generic codec initialisation */ |
53 | ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); | 54 | ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); |
@@ -91,6 +92,15 @@ next_track: | |||
91 | err = CODEC_ERROR; | 92 | err = CODEC_ERROR; |
92 | goto done; | 93 | goto done; |
93 | } | 94 | } |
95 | |||
96 | /* check for a mid-track resume and force a seek time accordingly */ | ||
97 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | ||
98 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | ||
99 | /* put number of subpackets to skip in resume_offset */ | ||
100 | resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); | ||
101 | ci->seek_time = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); | ||
102 | } | ||
103 | |||
94 | ci->id3->frequency = s; | 104 | ci->id3->frequency = s; |
95 | ci->set_elapsed(0); | 105 | ci->set_elapsed(0); |
96 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); | 106 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); |