diff options
Diffstat (limited to 'apps/codecs/libpcm/dialogic_oki_adpcm.c')
-rw-r--r-- | apps/codecs/libpcm/dialogic_oki_adpcm.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/codecs/libpcm/dialogic_oki_adpcm.c b/apps/codecs/libpcm/dialogic_oki_adpcm.c index 62d092e677..4a6465f196 100644 --- a/apps/codecs/libpcm/dialogic_oki_adpcm.c +++ b/apps/codecs/libpcm/dialogic_oki_adpcm.c | |||
@@ -44,6 +44,7 @@ static const int index_table[] ICONST_ATTR = { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | static struct adpcm_data cur_data; | 46 | static struct adpcm_data cur_data; |
47 | static int blocksperchunk; | ||
47 | 48 | ||
48 | static struct pcm_format *fmt; | 49 | static struct pcm_format *fmt; |
49 | 50 | ||
@@ -71,7 +72,8 @@ static bool set_format(struct pcm_format *format) | |||
71 | fmt->samplesperblock = 2; | 72 | fmt->samplesperblock = 2; |
72 | 73 | ||
73 | /* chunksize = about 1/32[sec] data */ | 74 | /* chunksize = about 1/32[sec] data */ |
74 | fmt->chunksize = ci->id3->frequency >> 6; | 75 | blocksperchunk = ci->id3->frequency >> 6; |
76 | fmt->chunksize = blocksperchunk * fmt->blockalign; | ||
75 | 77 | ||
76 | max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency | 78 | max_chunk_count = (uint64_t)ci->id3->length * ci->id3->frequency |
77 | / (2000LL * fmt->chunksize); | 79 | / (2000LL * fmt->chunksize); |
@@ -146,20 +148,18 @@ static int decode_for_seek(const uint8_t *inbuf, size_t inbufsize) | |||
146 | return CODEC_OK; | 148 | return CODEC_OK; |
147 | } | 149 | } |
148 | 150 | ||
149 | static struct pcm_pos *get_seek_pos(long seek_time, | 151 | static struct pcm_pos *get_seek_pos(uint32_t seek_val, int seek_mode, |
150 | uint8_t *(*read_buffer)(size_t *realsize)) | 152 | uint8_t *(*read_buffer)(size_t *realsize)) |
151 | { | 153 | { |
152 | static struct pcm_pos newpos; | 154 | static struct pcm_pos newpos; |
153 | uint32_t seek_count = 0; | 155 | uint32_t seek_count = (seek_mode == PCM_SEEK_TIME)? |
154 | uint32_t new_count; | 156 | ((uint64_t)seek_val * ci->id3->frequency / 1000LL) |
157 | / (blocksperchunk * fmt->samplesperblock) : | ||
158 | seek_val / fmt->chunksize; | ||
159 | uint32_t new_count = seek(seek_count, &cur_data, read_buffer, &decode_for_seek); | ||
155 | 160 | ||
156 | if (seek_time > 0) | ||
157 | seek_count = (uint64_t)seek_time * ci->id3->frequency | ||
158 | / (2000LL * fmt->chunksize); | ||
159 | |||
160 | new_count = seek(seek_count, &cur_data, read_buffer, &decode_for_seek); | ||
161 | newpos.pos = new_count * fmt->chunksize; | 161 | newpos.pos = new_count * fmt->chunksize; |
162 | newpos.samples = (newpos.pos / fmt->blockalign) * fmt->samplesperblock; | 162 | newpos.samples = new_count * blocksperchunk * fmt->samplesperblock; |
163 | return &newpos; | 163 | return &newpos; |
164 | } | 164 | } |
165 | 165 | ||