diff options
Diffstat (limited to 'lib/rbcodec/codecs/raac.c')
-rw-r--r-- | lib/rbcodec/codecs/raac.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/raac.c b/lib/rbcodec/codecs/raac.c index 523560b63e..d2d3531028 100644 --- a/lib/rbcodec/codecs/raac.c +++ b/lib/rbcodec/codecs/raac.c | |||
@@ -63,14 +63,16 @@ enum codec_status codec_run(void) | |||
63 | unsigned char c = 0; /* channels */ | 63 | unsigned char c = 0; /* channels */ |
64 | int playback_on = -1; | 64 | int playback_on = -1; |
65 | size_t resume_offset; | 65 | size_t resume_offset; |
66 | enum codec_command_action action; | ||
66 | intptr_t param; | 67 | intptr_t param; |
67 | enum codec_command_action action = CODEC_ACTION_NULL; | ||
68 | 68 | ||
69 | if (codec_init()) { | 69 | if (codec_init()) { |
70 | DEBUGF("FAAD: Codec init error\n"); | 70 | DEBUGF("FAAD: Codec init error\n"); |
71 | return CODEC_ERROR; | 71 | return CODEC_ERROR; |
72 | } | 72 | } |
73 | 73 | ||
74 | action = CODEC_ACTION_NULL; | ||
75 | param = ci->id3->elapsed; | ||
74 | resume_offset = ci->id3->offset; | 76 | resume_offset = ci->id3->offset; |
75 | 77 | ||
76 | ci->memset(&rmctx,0,sizeof(RMContext)); | 78 | ci->memset(&rmctx,0,sizeof(RMContext)); |
@@ -104,15 +106,21 @@ enum codec_status codec_run(void) | |||
104 | } | 106 | } |
105 | 107 | ||
106 | /* check for a mid-track resume and force a seek time accordingly */ | 108 | /* check for a mid-track resume and force a seek time accordingly */ |
107 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | 109 | if (resume_offset) { |
108 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | 110 | resume_offset -= MIN(resume_offset, rmctx.data_offset + DATA_HEADER_SIZE); |
109 | /* put number of subpackets to skip in resume_offset */ | 111 | /* put number of subpackets to skip in resume_offset */ |
110 | resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); | 112 | resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); |
111 | param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); | 113 | param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); |
114 | } | ||
115 | |||
116 | if (param > 0) { | ||
112 | action = CODEC_ACTION_SEEK_TIME; | 117 | action = CODEC_ACTION_SEEK_TIME; |
113 | } | 118 | } |
114 | ci->set_elapsed(0); | 119 | else { |
115 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); | 120 | /* Seek to the first packet */ |
121 | ci->set_elapsed(0); | ||
122 | ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); | ||
123 | } | ||
116 | 124 | ||
117 | /* The main decoding loop */ | 125 | /* The main decoding loop */ |
118 | while (1) { | 126 | while (1) { |
@@ -124,7 +132,7 @@ enum codec_status codec_run(void) | |||
124 | 132 | ||
125 | if (action == CODEC_ACTION_SEEK_TIME) { | 133 | if (action == CODEC_ACTION_SEEK_TIME) { |
126 | /* Do not allow seeking beyond the file's length */ | 134 | /* Do not allow seeking beyond the file's length */ |
127 | if ((unsigned) param > ci->id3->length) { | 135 | if ((unsigned long)param > ci->id3->length) { |
128 | ci->set_elapsed(ci->id3->length); | 136 | ci->set_elapsed(ci->id3->length); |
129 | ci->seek_complete(); | 137 | ci->seek_complete(); |
130 | break; | 138 | break; |
@@ -164,6 +172,7 @@ enum codec_status codec_run(void) | |||
164 | 172 | ||
165 | ci->advance_buffer(pkt.length); | 173 | ci->advance_buffer(pkt.length); |
166 | } | 174 | } |
175 | |||
167 | ci->seek_buffer(pkt_offset + rmctx.data_offset + DATA_HEADER_SIZE); | 176 | ci->seek_buffer(pkt_offset + rmctx.data_offset + DATA_HEADER_SIZE); |
168 | buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); | 177 | buffer = ci->request_buffer(&n,rmctx.audio_framesize + 1000); |
169 | NeAACDecPostSeekReset(decoder, decoder->frame); | 178 | NeAACDecPostSeekReset(decoder, decoder->frame); |