diff options
author | Yoshihisa Uchida <uchida@rockbox.org> | 2010-03-22 10:02:05 +0000 |
---|---|---|
committer | Yoshihisa Uchida <uchida@rockbox.org> | 2010-03-22 10:02:05 +0000 |
commit | 7a3822c8b03a5438a1bcfd6e38c0e6860dda3348 (patch) | |
tree | e50740c7f0ccd6aff1aac0e292a000ac7ef6be14 /apps/codecs/vox.c | |
parent | 20fccd84897352478c3306e41ca0fab0a5f4c65e (diff) | |
download | rockbox-7a3822c8b03a5438a1bcfd6e38c0e6860dda3348.tar.gz rockbox-7a3822c8b03a5438a1bcfd6e38c0e6860dda3348.zip |
fix bug: WAV file playback does not resume (FS#11077)
Not only WAV but also Sun audio, SMAF, vox and WAV64 can resume.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25289 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/vox.c')
-rw-r--r-- | apps/codecs/vox.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/apps/codecs/vox.c b/apps/codecs/vox.c index 21742e16d9..ff5d571e8d 100644 --- a/apps/codecs/vox.c +++ b/apps/codecs/vox.c | |||
@@ -52,9 +52,8 @@ enum codec_status codec_main(void) | |||
52 | int bufcount; | 52 | int bufcount; |
53 | int endofstream; | 53 | int endofstream; |
54 | uint8_t *voxbuf; | 54 | uint8_t *voxbuf; |
55 | off_t firstblockposn; /* position of the first block in file */ | 55 | off_t firstblockposn = 0; /* position of the first block in file */ |
56 | const struct pcm_codec *codec; | 56 | const struct pcm_codec *codec; |
57 | int offset = 0; | ||
58 | 57 | ||
59 | /* Generic codec initialisation */ | 58 | /* Generic codec initialisation */ |
60 | ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); | 59 | ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); |
@@ -70,7 +69,10 @@ next_track: | |||
70 | ci->sleep(1); | 69 | ci->sleep(1); |
71 | 70 | ||
72 | codec_set_replaygain(ci->id3); | 71 | codec_set_replaygain(ci->id3); |
73 | 72 | ||
73 | /* Need to save offset for later use (cleared indirectly by advance_buffer) */ | ||
74 | bytesdone = ci->id3->offset; | ||
75 | |||
74 | ci->memset(&format, 0, sizeof(struct pcm_format)); | 76 | ci->memset(&format, 0, sizeof(struct pcm_format)); |
75 | 77 | ||
76 | /* set format */ | 78 | /* set format */ |
@@ -80,12 +82,9 @@ next_track: | |||
80 | format.blockalign = 1; | 82 | format.blockalign = 1; |
81 | 83 | ||
82 | /* advance to first WAVE chunk */ | 84 | /* advance to first WAVE chunk */ |
83 | ci->advance_buffer(offset); | 85 | firstblockposn = 0; |
84 | |||
85 | firstblockposn = offset; | ||
86 | |||
87 | decodedsamples = 0; | 86 | decodedsamples = 0; |
88 | bytesdone = 0; | 87 | ci->advance_buffer(firstblockposn); |
89 | 88 | ||
90 | /* | 89 | /* |
91 | * get codec | 90 | * get codec |
@@ -124,6 +123,25 @@ next_track: | |||
124 | ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); | 123 | ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); |
125 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); | 124 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); |
126 | 125 | ||
126 | /* make sure we're at the correct offset */ | ||
127 | if (bytesdone > (uint32_t) firstblockposn) { | ||
128 | /* Round down to previous block */ | ||
129 | struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, | ||
130 | PCM_SEEK_POS, &read_buffer); | ||
131 | |||
132 | if (newpos->pos > format.numbytes) | ||
133 | goto done; | ||
134 | if (ci->seek_buffer(firstblockposn + newpos->pos)) | ||
135 | { | ||
136 | bytesdone = newpos->pos; | ||
137 | decodedsamples = newpos->samples; | ||
138 | } | ||
139 | ci->seek_complete(); | ||
140 | } else { | ||
141 | /* already where we need to be */ | ||
142 | bytesdone = 0; | ||
143 | } | ||
144 | |||
127 | /* The main decoder loop */ | 145 | /* The main decoder loop */ |
128 | endofstream = 0; | 146 | endofstream = 0; |
129 | 147 | ||
@@ -134,7 +152,8 @@ next_track: | |||
134 | } | 152 | } |
135 | 153 | ||
136 | if (ci->seek_time) { | 154 | if (ci->seek_time) { |
137 | struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, &read_buffer); | 155 | struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, PCM_SEEK_TIME, |
156 | &read_buffer); | ||
138 | 157 | ||
139 | if (newpos->pos > format.numbytes) | 158 | if (newpos->pos > format.numbytes) |
140 | break; | 159 | break; |