map

minimalist audio player
git clone https://git.porkepik.fr/map
Log | Files | Refs | README | LICENSE

commit 1fbe26f368e6e9380f1519a549dddd8e1f94b7a2
parent 33b94312b46a103666f40bbf9eb04f1807026658
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Mon, 16 Mar 2020 17:23:39 +0100

fix seeking for mp3 and flac files

Diffstat:
Malsa.c | 1-
Mflac.c | 3+--
Mmp3.c | 2+-
3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/alsa.c b/alsa.c @@ -83,7 +83,6 @@ alsa_play(void *buf, size_t nbytes) void alsa_close(void) { - snd_pcm_drain(hdl); if (hdl) snd_pcm_close(hdl); hdl = NULL; diff --git a/flac.c b/flac.c @@ -25,8 +25,7 @@ flac_decode(void *buf, int nbytes) void flac_seek(int sec) { - long frame_index = (flac->currentPCMFrame / flac->channels) + - (sec * flac->sampleRate); + long frame_index = flac->currentPCMFrame + sec * (int) flac->sampleRate; if (frame_index < 0) frame_index = 0; drflac_seek_to_pcm_frame(flac, frame_index); diff --git a/mp3.c b/mp3.c @@ -25,7 +25,7 @@ mp3_decode(void *buf, int nbytes) void mp3_seek(int sec) { - long frame_index = mp3.currentPCMFrame + (sec * mp3.sampleRate); + long frame_index = mp3.currentPCMFrame + sec * (int) mp3.sampleRate; if (frame_index < 0) frame_index = 0; drmp3_seek_to_pcm_frame(&mp3, frame_index);