Tag subtracks according to "cuesheet" vorbis comment value

Cuesheets are often saved as vorbis comment
flac files (CUESHEET=.. case doesn't matter).
We can parse this now and use the information to
tag the subtracks (from the embedded cuesheets).
This commit is contained in:
Jochen Keil 2009-03-31 22:07:20 +02:00
parent d7b0c768b0
commit 4bfbdfe5c5

View File

@ -27,6 +27,10 @@
#include <sys/stat.h>
#include <sys/types.h>
#ifdef HAVE_CUE /* libcue */
#include "../cue/cue_tag.h"
#endif
/* this code was based on flac123, from flac-tools */
static flac_read_status
@ -290,20 +294,44 @@ flac_cue_tag_load(const char *file)
{
struct tag* tag = NULL;
char* char_tnum = NULL;
char* slash = NULL;
char* ptr = NULL;
unsigned int i = 0;
unsigned int tnum = 0;
unsigned int sample_rate = 0;
FLAC__uint64 track_time = 0;
#ifdef HAVE_CUE /* libcue */
FLAC__StreamMetadata* vc = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
#endif /* libcue */
FLAC__StreamMetadata* si = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO);
FLAC__StreamMetadata* cs = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET);
tnum = flac_vtrack_tnum(file);
char_tnum = g_strdup_printf("%u", tnum);
slash = strrchr(file, '/');
*slash = '\0';
ptr = strrchr(file, '/');
*ptr = '\0';
tag = flac_tag_load(file, char_tnum);
#ifdef HAVE_CUE /* libcue */
if (FLAC__metadata_get_tags(file, &vc))
{
for (i = 0; i < vc->data.vorbis_comment.num_comments; i++)
{
if ((ptr = (char*)vc->data.vorbis_comment.comments[i].entry) != NULL)
{
if (g_ascii_strncasecmp(ptr, "cuesheet", 8) == 0)
{
while (*(++ptr) != '=');
tag = cue_tag_string( ++ptr,
tnum);
}
}
}
FLAC__metadata_object_delete(vc);
}
#endif /* libcue */
if (tag == NULL)
tag = flac_tag_load(file, char_tnum);
if (char_tnum != NULL)
{