summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/mpc.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-07-14 07:59:39 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-03-10 04:12:30 +0100
commit31b712286721dd606940c7b557d03e3f714b9604 (patch)
tree8c4a4cc32e9000ea721ebb23aa3c0129ca97bf53 /lib/rbcodec/codecs/mpc.c
parentdda54b85daa83b7803b4fb189ab45859f96ff3f9 (diff)
downloadrockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.gz
rockbox-31b712286721dd606940c7b557d03e3f714b9604.zip
Implement time-based resume and playback start.
This complements offset-based resume and playback start funcionality. The implementation is global on both HWCODEC and SWCODEC. Basically, if either the specified elapsed or offset are non-zero, it indicates a mid-track resume. To resume by time only, set elapsed to nonzero and offset to zero. To resume by offset only, set offset to nonzero and elapsed to zero. Which one the codec uses and which has priority is up to the codec; however, using an elapsed time covers more cases: * Codecs not able to use an offset such as VGM or other atomic formats * Starting playback at a nonzero elapsed time from a source that contains no offset, such as a cuesheet The change re-versions pretty much everything from tagcache to nvram. Change-Id: Ic7aebb24e99a03ae99585c5e236eba960d163f38 Reviewed-on: http://gerrit.rockbox.org/516 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
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);