summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/mpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/mpc.c')
-rw-r--r--lib/rbcodec/codecs/mpc.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/mpc.c b/lib/rbcodec/codecs/mpc.c
index 9db40242dc..79f2aa22db 100644
--- a/lib/rbcodec/codecs/mpc.c
+++ b/lib/rbcodec/codecs/mpc.c
@@ -108,6 +108,7 @@ enum codec_status codec_run(void)
108 * sample seek position from the file offset, the sampling frequency and 108 * sample seek position from the file offset, the sampling frequency and
109 * the bitrate. As the saved position is exactly calculated the reverse way 109 * the bitrate. As the saved position is exactly calculated the reverse way
110 * there is no loss of information except rounding. */ 110 * there is no loss of information except rounding. */
111 elapsed_time = ci->id3->elapsed;
111 samplesdone = 100 * (((mpc_uint64_t)ci->id3->offset * frequency) / byterate); 112 samplesdone = 100 * (((mpc_uint64_t)ci->id3->offset * frequency) / byterate);
112 113
113 /* Set up digital signal processing for correct number of channels */ 114 /* Set up digital signal processing for correct number of channels */
@@ -122,19 +123,24 @@ enum codec_status codec_run(void)
122 123
123 codec_set_replaygain(ci->id3); 124 codec_set_replaygain(ci->id3);
124 125
125 /* Resume to saved sample offset. */ 126 if (samplesdone > 0 || elapsed_time)
126 elapsed_time = 0;
127
128 if (samplesdone > 0)
129 { 127 {
130 if (mpc_demux_seek_sample(demux, samplesdone) == MPC_STATUS_OK) 128 mpc_int64_t new_offset = samplesdone;
129
130 if (new_offset <= 0)
131 new_offset = (elapsed_time/10)*frequency; /* by time */
132
133 /* Resume to sample offset. */
134 if (mpc_demux_seek_sample(demux, new_offset) == MPC_STATUS_OK)
131 { 135 {
132 elapsed_time = (samplesdone*10)/frequency; 136 samplesdone = new_offset;
133 } 137 }
134 else 138 else
135 { 139 {
136 samplesdone = 0; 140 samplesdone = 0;
137 } 141 }
142
143 elapsed_time = (samplesdone*10)/frequency;
138 } 144 }
139 145
140 ci->set_elapsed(elapsed_time); 146 ci->set_elapsed(elapsed_time);