mp4: use tag_is_empty() instead of passing the tag_is_found flag
The API of mp4_load_tag() was strange: it always returned a tag object, no matter if a tag was found in the file; the existence of a tag was indicated with the tag_found integer reference. This flag is superfluous, since we can simply check whether the tag is empty or not.
This commit is contained in:
parent
02a172f2c2
commit
01706dd46c
@ -302,7 +302,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct tag *
|
static struct tag *
|
||||||
mp4_load_tag(const char *file, int *tag_found)
|
mp4_load_tag(const char *file)
|
||||||
{
|
{
|
||||||
struct tag *ret = NULL;
|
struct tag *ret = NULL;
|
||||||
struct input_stream input_stream;
|
struct input_stream input_stream;
|
||||||
@ -317,8 +317,6 @@ mp4_load_tag(const char *file, int *tag_found)
|
|||||||
int32_t scale;
|
int32_t scale;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*tag_found = 0;
|
|
||||||
|
|
||||||
if (!input_stream_open(&input_stream, file)) {
|
if (!input_stream_open(&input_stream, file)) {
|
||||||
DEBUG("mp4_load_tag: Failed to open file: %s\n", file);
|
DEBUG("mp4_load_tag: Failed to open file: %s\n", file);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -356,25 +354,18 @@ mp4_load_tag(const char *file, int *tag_found)
|
|||||||
|
|
||||||
if (0 == strcasecmp("artist", item)) {
|
if (0 == strcasecmp("artist", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_ARTIST, value);
|
tag_add_item(ret, TAG_ITEM_ARTIST, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("title", item)) {
|
} else if (0 == strcasecmp("title", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_TITLE, value);
|
tag_add_item(ret, TAG_ITEM_TITLE, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("album", item)) {
|
} else if (0 == strcasecmp("album", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_ALBUM, value);
|
tag_add_item(ret, TAG_ITEM_ALBUM, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("track", item)) {
|
} else if (0 == strcasecmp("track", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_TRACK, value);
|
tag_add_item(ret, TAG_ITEM_TRACK, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("disc", item)) { /* Is that the correct id? */
|
} else if (0 == strcasecmp("disc", item)) { /* Is that the correct id? */
|
||||||
tag_add_item(ret, TAG_ITEM_DISC, value);
|
tag_add_item(ret, TAG_ITEM_DISC, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("genre", item)) {
|
} else if (0 == strcasecmp("genre", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_GENRE, value);
|
tag_add_item(ret, TAG_ITEM_GENRE, value);
|
||||||
*tag_found = 1;
|
|
||||||
} else if (0 == strcasecmp("date", item)) {
|
} else if (0 == strcasecmp("date", item)) {
|
||||||
tag_add_item(ret, TAG_ITEM_DATE, value);
|
tag_add_item(ret, TAG_ITEM_DATE, value);
|
||||||
*tag_found = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(item);
|
free(item);
|
||||||
@ -391,12 +382,11 @@ static struct tag *
|
|||||||
mp4_tag_dup(const char *file)
|
mp4_tag_dup(const char *file)
|
||||||
{
|
{
|
||||||
struct tag *ret = NULL;
|
struct tag *ret = NULL;
|
||||||
int tag_found = 0;
|
|
||||||
|
|
||||||
ret = mp4_load_tag(file, &tag_found);
|
ret = mp4_load_tag(file);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!tag_found) {
|
if (tag_is_empty(ret)) {
|
||||||
struct tag *temp = tag_id3_load(file);
|
struct tag *temp = tag_id3_load(file);
|
||||||
if (temp) {
|
if (temp) {
|
||||||
temp->time = ret->time;
|
temp->time = ret->time;
|
||||||
|
Loading…
Reference in New Issue
Block a user