tmus

TUI Music Player
git clone https://git.sinitax.com/sinitax/tmus
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

commit b70423c2ece6b268a47c32950faeda344c7004a7
parent a001039548e2df4ba88b5ad0396eac4980959ab0
Author: Louis Burda <quent.burda@gmail.com>
Date:   Sun, 23 Jan 2022 21:46:46 +0100

Dont rely on d_type for loading tracks

Diffstat:
Msrc/main.c | 22+++++++++++++---------
Asrc/player_backend.c | 3+++
Asrc/player_backend.h | 6++++++
3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -119,7 +119,7 @@ static void data_load(void); static void data_save(void); static void data_free(void); -static void tracks_load(struct tag *tag); +static int tracks_load(struct tag *tag); static void tracks_save(struct tag *tag); static void pane_title(struct pane *pane, const char *title, int highlight); @@ -303,16 +303,16 @@ data_load(void) dir = opendir(datadir); ASSERT(dir != NULL); while ((ent = readdir(dir))) { - if (ent->d_type != DT_DIR) - continue; if (!strcmp(ent->d_name, ".")) continue; if (!strcmp(ent->d_name, "..")) continue; tag = tag_init(datadir, ent->d_name); - list_push_back(&tags, LINK(tag)); - tracks_load(tag); + if (tracks_load(tag)) + tag_free(tag); + else + list_push_back(&tags, LINK(tag)); } closedir(dir); @@ -350,7 +350,7 @@ data_free(void) } } -void +int tracks_load(struct tag *tag) { struct track *track, *track_iter; @@ -360,15 +360,17 @@ tracks_load(struct tag *tag) DIR *dir; dir = opendir(tag->fpath); - ASSERT(dir != NULL); + if (!dir) return 1; while ((ent = readdir(dir))) { - if (ent->d_type != DT_REG) - continue; if (!strcmp(ent->d_name, ".")) continue; if (!strcmp(ent->d_name, "..")) continue; + /* skip files without extension */ + if (!strchr(ent->d_name, '.')) + continue; + track = track_init(tag->fpath, ent->d_name); ref = ref_init(tag); @@ -392,6 +394,8 @@ tracks_load(struct tag *tag) } } closedir(dir); + + return 0; } void diff --git a/src/player_backend.c b/src/player_backend.c @@ -0,0 +1,3 @@ +#include "player_backend.h" + +void foo(void); diff --git a/src/player_backend.h b/src/player_backend.h @@ -0,0 +1,6 @@ +#pragma once + +struct player_data { + int time_pos, time_end; +}; +