summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/wavpack.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/wavpack.c')
-rw-r--r--lib/rbcodec/codecs/wavpack.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/wavpack.c b/lib/rbcodec/codecs/wavpack.c
index c0cdafabac..d9c294397c 100644
--- a/lib/rbcodec/codecs/wavpack.c
+++ b/lib/rbcodec/codecs/wavpack.c
@@ -55,12 +55,16 @@ enum codec_status codec_run(void)
55 int bps; 55 int bps;
56 */ 56 */
57 int nchans, sr_100; 57 int nchans, sr_100;
58 unsigned long offset;
58 intptr_t param; 59 intptr_t param;
59 60
60 if (codec_init()) 61 if (codec_init())
61 return CODEC_ERROR; 62 return CODEC_ERROR;
62 63
63 ci->seek_buffer (ci->id3->offset); 64 param = ci->id3->elapsed;
65 offset = ci->id3->offset;
66
67 ci->seek_buffer (offset);
64 68
65 /* Create a decoder instance */ 69 /* Create a decoder instance */
66 wpc = WavpackOpenFileInput (read_callback, error); 70 wpc = WavpackOpenFileInput (read_callback, error);
@@ -75,7 +79,12 @@ enum codec_status codec_run(void)
75 ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO); 79 ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO);
76 sr_100 = ci->id3->frequency / 100; 80 sr_100 = ci->id3->frequency / 100;
77 81
78 ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); 82 if (!offset && param) {
83 goto resume_start; /* resume by elapsed */
84 }
85 else {
86 ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10);
87 }
79 88
80 /* The main decoder loop */ 89 /* The main decoder loop */
81 90
@@ -87,6 +96,7 @@ enum codec_status codec_run(void)
87 break; 96 break;
88 97
89 if (action == CODEC_ACTION_SEEK_TIME) { 98 if (action == CODEC_ACTION_SEEK_TIME) {
99 resume_start:;
90 int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10; 100 int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10;
91 int n, d, skip; 101 int n, d, skip;
92 102