diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-31 22:52:50 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-05-31 22:52:50 +0200 |
commit | f527057e3be407d79efe82284332da28e6c51f8f (patch) | |
tree | dd2d0b27db5e3ff4174ca835f968187e09ace5b8 /plugins/tta | |
parent | d220ad6dec412fe141872158ea795ed7c610cf27 (diff) |
fixed tta seeking
Diffstat (limited to 'plugins/tta')
-rw-r--r-- | plugins/tta/ttaplug.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/tta/ttaplug.c b/plugins/tta/ttaplug.c index 2b54c475..c55c223f 100644 --- a/plugins/tta/ttaplug.c +++ b/plugins/tta/ttaplug.c @@ -153,12 +153,16 @@ tta_read_int16 (DB_fileinfo_t *_info, char *bytes, int size) { static int tta_seek_sample (DB_fileinfo_t *_info, int sample) { tta_info_t *info = (tta_info_t *)_info; - if (set_position (sample * 1000 / info->tta.SAMPLERATE / SEEK_STEP) != 0) { + int seek_time = (sample + info->startsample) / SEEK_STEP * 1000 / info->tta.SAMPLERATE; + + if (set_position (seek_time) != 0) { fprintf (stderr, "tta: seek failed\n"); return -1; } - info->currentsample = sample; - _info->readpos = (sample - info->startsample) / _info->samplerate; + sample = (seek_time * SEEK_STEP) / 1000 * info->tta.SAMPLERATE; + + info->currentsample = sample - info->startsample; + _info->readpos = sample / _info->samplerate; return 0; } |