map

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

commit 3b381c28316371f9efbc407c66d1ea48c6e5afe7
parent a28ef50ab83c0c3475e61ab43c860e3e998f20ed
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Sat, 31 Aug 2019 19:53:46 +0200

fix vorbis seeking

Diffstat:
Mmap.c | 6+++---
Mvorbis.c | 8++++----
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/map.c b/map.c @@ -14,7 +14,7 @@ #include <unistd.h> -#define BUFF_SIZE 4096 +#define BUFF_SIZE 2048 #define SEEK_SEC 30 @@ -211,7 +211,7 @@ get_tracks(const char *curdir) while ((dir = readdir(d))) { if (!strend(dir->d_name, ".flac") && !strend(dir->d_name, ".mp3") && - !strend(dir->d_name, ".vorbis") && + !strend(dir->d_name, ".ogg") && !strend(dir->d_name, ".wav")) continue; tracks = realloc(tracks, sizeof(struct track *) * (ntracks+1)); @@ -249,7 +249,7 @@ playtrack(struct track curtrack, struct player player, int trackid) int timersec = 0, toptrack = 0; long done; time_t start, pausetime = 0; - int buffer[BUFF_SIZE]; + long buffer[BUFF_SIZE]; start = time(NULL); opentrack(&curtrack); diff --git a/vorbis.c b/vorbis.c @@ -26,10 +26,10 @@ vorbis_decode(void *buf, int nbytes) void vorbis_seek(int sec) { - long frame_index = vorbis->current_loc + (sec * vorbis->sample_rate); - if (frame_index < 0) - frame_index = 0; - stb_vorbis_seek_frame(vorbis, frame_index); + long index = vorbis->current_loc + (sec * (long)vorbis->sample_rate); + if (index < 0) + index = 0; + stb_vorbis_seek_frame(vorbis, index); } void