Commit 706112bb authored by Jochen Keil's avatar Jochen Keil Committed by Max Kellermann

Initial support for embedded cue sheets found in flac files

So far only seekpoints are supported, so no proper tagging yet except for track number and track length. Tagging should be done by parsing the cue sheet which is often embedded as vorbis comment in flac files. Furthermore the pathname should be configurable like "%A - %t - %T", where %A means Artist, %t track number and %T Title or so.
parent ab3d89f4
......@@ -23,9 +23,6 @@
#include <glib.h>
#include <FLAC/format.h>
#include <FLAC/metadata.h>
#include <assert.h>
void
......@@ -349,3 +346,54 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
char*
flac_cue_track( const char* pathname,
const unsigned int tnum)
{
FLAC__StreamMetadata* cs = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET);
FLAC__metadata_get_cuesheet(pathname, &cs);
if (cs == NULL)
return NULL;
if (cs->data.cue_sheet.num_tracks <= 1)
{
FLAC__metadata_object_delete(cs);
return NULL;
}
if (tnum > 0 && tnum < cs->data.cue_sheet.num_tracks)
{
char* track = g_strdup_printf("track_%03u.flac", tnum);
FLAC__metadata_object_delete(cs);
return track;
}
else
{
FLAC__metadata_object_delete(cs);
return NULL;
}
}
unsigned int
flac_vtrack_tnum(const char* fname)
{
/* find last occurrence of '_' in fname
* which is hopefully something like track_xxx.flac
* another/better way would be to use tag struct
*/
char* ptr = strrchr(fname, '_');
// copy ascii tracknumber to int
char vtrack[4];
g_strlcpy(vtrack, ++ptr, 4);
return (unsigned int)strtol(vtrack, NULL, 10);
}
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
......@@ -175,4 +175,15 @@ FLAC__StreamDecoderWriteStatus
flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
const FLAC__int32 *const buf[]);
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
char*
flac_cue_track( const char* pathname,
const unsigned int tnum);
unsigned int
flac_vtrack_tnum( const char*);
#endif /* FLAC_API_VERSION_CURRENT >= 7 */
#endif /* _FLAC_COMMON_H */
......@@ -505,7 +505,7 @@ update_regular_file(struct directory *directory,
}
}
if (no_container == true)
if (no_container)
{
struct song *song = songvec_find(&directory->songs, name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment