From a43ff6faf155b95ba17eb9bd192e99f52cb25820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Fri, 25 Apr 2008 15:05:45 +0200 Subject: - Switched from id3lib to TagLib --- Makefile | 4 ++-- src/mp3_vnops.c | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index f906f21..45b54d8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CFLAGS = -Wall -std=c99 -D_BSD_SOURCE -I/usr/local/include/ -Iinclude/ \ - `pkg-config fuse --cflags` -DDEBUGGING + `pkg-config fuse --cflags` `pkg-config taglib --cflags` -DDEBUGGING -LD_ADD = -L/usr/local/lib -lid3 \ +LD_ADD = -L/usr/local/lib -ltag_c \ `pkg-config fuse --libs` CC = gcc diff --git a/src/mp3_vnops.c b/src/mp3_vnops.c index 381e66d..3224314 100755 --- a/src/mp3_vnops.c +++ b/src/mp3_vnops.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ #define FUSE_USE_VERSION 26 #include +#include #include #include #include @@ -9,7 +10,7 @@ #include #include -#include +#include #include "debug.h" @@ -138,12 +139,11 @@ void mp3_artist(char *filepath, void *data) { struct filler_data *fd; - ID3Tag *tag; - ID3Frame *artist; - ID3Field *field; fuse_fill_dir_t filler; void *buf; char name[MAXPATHLEN]; + TagLib_File *tagfile; + TagLib_Tag *tag; /* Retrieve the filler function and pointers. */ fd = (struct filler_data *)data; @@ -151,18 +151,19 @@ mp3_artist(char *filepath, void *data) buf = fd->buf; /* Get the tag. */ - tag = ID3Tag_New(); - ID3Tag_Link(tag, filepath); - artist = ID3Tag_FindFrameWithID(tag, ID3FID_LEADARTIST); + tagfile = taglib_file_new(filepath); + tag = taglib_file_tag(tagfile); + + char *artist = taglib_tag_artist(tag); if (artist == NULL) return; - field = ID3Frame_GetField(artist, ID3FN_TEXT); - if (field == NULL) - return; - ID3Field_GetASCII(field, name, ID3Field_Size(field)); - /* XXX: doesn't show up... why? */ + + strcpy(name, artist); + filler(buf, name, NULL, 0); - ID3Tag_Delete(tag); + + taglib_tag_free_strings(); + taglib_file_free(tagfile); return; } @@ -207,12 +208,12 @@ static struct fuse_operations mp3_ops = { static int mp3fs_opt_proc (void *data, const char *arg, int key, struct fuse_args *outargs) { - static bool musicpath_set = false; + static int musicpath_set = 0; if (key == FUSE_OPT_KEY_NONOPT && !musicpath_set) { /* The source directory isn't already set, let's do it */ strcpy(musicpath, arg); - musicpath_set = true; + musicpath_set = 1; return (0); } return (1); -- cgit v1.2.3