decoder/sidplay: correctly calculate floating point time
Internally, use only the integer time. When needed, convert it to a floating point seconds value.
This commit is contained in:
parent
409a3ed808
commit
873025a495
@ -283,8 +283,10 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
|||||||
|
|
||||||
/* .. and play */
|
/* .. and play */
|
||||||
|
|
||||||
float data_time=0;
|
unsigned data_time = 0;
|
||||||
int timebase=player.timebase();
|
const unsigned timebase = player.timebase();
|
||||||
|
song_len *= timebase;
|
||||||
|
|
||||||
enum decoder_command cmd;
|
enum decoder_command cmd;
|
||||||
do {
|
do {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
@ -295,12 +297,13 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
cmd = decoder_data(decoder, NULL, buffer, nbytes,
|
cmd = decoder_data(decoder, NULL, buffer, nbytes,
|
||||||
data_time, 0, NULL);
|
(float)data_time / (float)timebase,
|
||||||
|
0, NULL);
|
||||||
data_time=player.time()/timebase;
|
data_time = player.time();
|
||||||
|
|
||||||
if(cmd==DECODE_COMMAND_SEEK) {
|
if(cmd==DECODE_COMMAND_SEEK) {
|
||||||
int target_time=decoder_seek_where(decoder);
|
unsigned target_time = (unsigned)
|
||||||
|
(decoder_seek_where(decoder) * timebase);
|
||||||
|
|
||||||
/* can't rewind so return to zero and seek forward */
|
/* can't rewind so return to zero and seek forward */
|
||||||
if(target_time<data_time) {
|
if(target_time<data_time) {
|
||||||
@ -313,13 +316,13 @@ sidplay_file_decode(struct decoder *decoder, const char *path_fs)
|
|||||||
nbytes=player.play(buffer, sizeof(buffer));
|
nbytes=player.play(buffer, sizeof(buffer));
|
||||||
if(nbytes==0)
|
if(nbytes==0)
|
||||||
break;
|
break;
|
||||||
data_time=player.time()/timebase;
|
data_time = player.time();
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(song_len && data_time>=(float)song_len)
|
if (song_len > 0 && data_time >= song_len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} while (cmd != DECODE_COMMAND_STOP);
|
} while (cmd != DECODE_COMMAND_STOP);
|
||||||
|
Loading…
Reference in New Issue
Block a user