Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
d6d5caae
Commit
d6d5caae
authored
Jan 06, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/flac: moved flac_tag_load() to flac_metadata.c
Make this code is reusable.
parent
38269117
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
53 deletions
+56
-53
flac_decoder_plugin.c
src/decoder/flac_decoder_plugin.c
+0
-53
flac_metadata.c
src/decoder/flac_metadata.c
+53
-0
flac_metadata.h
src/decoder/flac_metadata.h
+3
-0
No files found.
src/decoder/flac_decoder_plugin.c
View file @
d6d5caae
...
...
@@ -214,59 +214,6 @@ flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame,
return
flac_common_write
(
data
,
frame
,
buf
,
nbytes
);
}
static
struct
tag
*
flac_tag_load
(
const
char
*
file
,
const
char
*
char_tnum
)
{
struct
tag
*
tag
;
FLAC__Metadata_SimpleIterator
*
it
;
FLAC__StreamMetadata
*
block
=
NULL
;
it
=
FLAC__metadata_simple_iterator_new
();
if
(
!
FLAC__metadata_simple_iterator_init
(
it
,
file
,
1
,
0
))
{
const
char
*
err
;
FLAC_API
FLAC__Metadata_SimpleIteratorStatus
s
;
s
=
FLAC__metadata_simple_iterator_status
(
it
);
switch
(
s
)
{
/* slightly more human-friendly messages: */
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT
:
err
=
"illegal input"
;
break
;
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE
:
err
=
"error opening file"
;
break
;
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE
:
err
=
"not a FLAC file"
;
break
;
default:
err
=
FLAC__Metadata_SimpleIteratorStatusString
[
s
];
}
g_debug
(
"Reading '%s' metadata gave the following error: %s
\n
"
,
file
,
err
);
FLAC__metadata_simple_iterator_delete
(
it
);
return
NULL
;
}
tag
=
tag_new
();
do
{
block
=
FLAC__metadata_simple_iterator_get_block
(
it
);
if
(
!
block
)
break
;
flac_tag_apply_metadata
(
tag
,
char_tnum
,
block
);
FLAC__metadata_object_delete
(
block
);
}
while
(
FLAC__metadata_simple_iterator_next
(
it
));
FLAC__metadata_simple_iterator_delete
(
it
);
if
(
!
tag_is_defined
(
tag
))
{
tag_free
(
tag
);
tag
=
NULL
;
}
return
tag
;
}
#if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7
static
struct
tag
*
...
...
src/decoder/flac_metadata.c
View file @
d6d5caae
...
...
@@ -191,3 +191,56 @@ flac_tag_apply_metadata(struct tag *tag, const char *track,
break
;
}
}
struct
tag
*
flac_tag_load
(
const
char
*
file
,
const
char
*
char_tnum
)
{
struct
tag
*
tag
;
FLAC__Metadata_SimpleIterator
*
it
;
FLAC__StreamMetadata
*
block
=
NULL
;
it
=
FLAC__metadata_simple_iterator_new
();
if
(
!
FLAC__metadata_simple_iterator_init
(
it
,
file
,
1
,
0
))
{
const
char
*
err
;
FLAC_API
FLAC__Metadata_SimpleIteratorStatus
s
;
s
=
FLAC__metadata_simple_iterator_status
(
it
);
switch
(
s
)
{
/* slightly more human-friendly messages: */
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT
:
err
=
"illegal input"
;
break
;
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE
:
err
=
"error opening file"
;
break
;
case
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE
:
err
=
"not a FLAC file"
;
break
;
default:
err
=
FLAC__Metadata_SimpleIteratorStatusString
[
s
];
}
g_debug
(
"Reading '%s' metadata gave the following error: %s
\n
"
,
file
,
err
);
FLAC__metadata_simple_iterator_delete
(
it
);
return
NULL
;
}
tag
=
tag_new
();
do
{
block
=
FLAC__metadata_simple_iterator_get_block
(
it
);
if
(
!
block
)
break
;
flac_tag_apply_metadata
(
tag
,
char_tnum
,
block
);
FLAC__metadata_object_delete
(
block
);
}
while
(
FLAC__metadata_simple_iterator_next
(
it
));
FLAC__metadata_simple_iterator_delete
(
it
);
if
(
!
tag_is_defined
(
tag
))
{
tag_free
(
tag
);
tag
=
NULL
;
}
return
tag
;
}
src/decoder/flac_metadata.h
View file @
d6d5caae
...
...
@@ -42,4 +42,7 @@ void
flac_tag_apply_metadata
(
struct
tag
*
tag
,
const
char
*
track
,
const
FLAC__StreamMetadata
*
block
);
struct
tag
*
flac_tag_load
(
const
char
*
file
,
const
char
*
char_tnum
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment