summaryrefslogtreecommitdiffstats
path: root/track.c
blob: 3312daf8cdd4f3444d6fc25b793a09543da13a4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "track.h"

#include <string.h>


struct track *
track_init(const char *dir, const char *file)
{
	struct track *track;

	track = malloc(sizeof(struct track));

	ASSERT(track != NULL);
	track->fname = strdup(file);
	ASSERT(track->fname != NULL);
	track->fpath = aprintf("%s/%s", dir, file);
	ASSERT(track->fpath != NULL);
	track->name = sanitized(track->fname);
	ASSERT(track->name != NULL);

	// TODO track_load_info(track)
	track->artist = NULL;
	track->duration = 0;
	track->link = LINK_EMPTY;

	track->tags = LIST_HEAD;

	return track;
}

void
track_free(struct track *t)
{
	free(t->fname);
	free(t->fpath);
	free(t->name);
}