summaryrefslogtreecommitdiff
path: root/apps/codecs/vox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/vox.c')
-rw-r--r--apps/codecs/vox.c37
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;