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
6b96f5d5
Commit
6b96f5d5
authored
Dec 31, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_plugin: added method stream_tag()
This is like tag_dup(), but works with an input_stream object instead of a file path.
parent
7a2e07e1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
1 deletion
+63
-1
sidplay_plugin.cxx
src/decoder/sidplay_plugin.cxx
+1
-0
decoder_plugin.h
src/decoder_plugin.h
+22
-1
song_update.c
src/song_update.c
+26
-0
read_tags.c
test/read_tags.c
+14
-0
No files found.
src/decoder/sidplay_plugin.cxx
View file @
6b96f5d5
...
...
@@ -411,6 +411,7 @@ const struct decoder_plugin sidplay_decoder_plugin = {
NULL
,
/* stream_decode() */
sidplay_file_decode
,
sidplay_tag_dup
,
NULL
,
/* stream_tag() */
sidplay_container_scan
,
sidplay_suffixes
,
NULL
,
/* mime_types */
...
...
src/decoder_plugin.h
View file @
6b96f5d5
...
...
@@ -77,6 +77,13 @@ struct decoder_plugin {
struct
tag
*
(
*
tag_dup
)(
const
char
*
path_fs
);
/**
* Read the tags of a stream.
*
* @return NULL if the operation has failed
*/
struct
tag
*
(
*
stream_tag
)(
struct
input_stream
*
is
);
/**
* @brief Return a "virtual" filename for subtracks in
* container formats like flac
* @param const char* pathname full pathname for the file on fs
...
...
@@ -147,7 +154,21 @@ static inline struct tag *
decoder_plugin_tag_dup
(
const
struct
decoder_plugin
*
plugin
,
const
char
*
path_fs
)
{
return
plugin
->
tag_dup
(
path_fs
);
return
plugin
->
tag_dup
!=
NULL
?
plugin
->
tag_dup
(
path_fs
)
:
NULL
;
}
/**
* Read the tag of a stream.
*/
static
inline
struct
tag
*
decoder_plugin_stream_tag
(
const
struct
decoder_plugin
*
plugin
,
struct
input_stream
*
is
)
{
return
plugin
->
stream_tag
!=
NULL
?
plugin
->
stream_tag
(
is
)
:
NULL
;
}
/**
...
...
src/song_update.c
View file @
6b96f5d5
...
...
@@ -27,12 +27,14 @@
#include "tag_ape.h"
#include "tag_id3.h"
#include "tag.h"
#include "input_stream.h"
#include <glib.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
struct
song
*
song_file_load
(
const
char
*
path
,
struct
directory
*
parent
)
...
...
@@ -99,6 +101,7 @@ song_file_update(struct song *song)
char
*
path_fs
;
const
struct
decoder_plugin
*
plugin
;
struct
stat
st
;
struct
input_stream
is
=
{
.
plugin
=
NULL
};
assert
(
song_is_file
(
song
));
...
...
@@ -129,13 +132,36 @@ song_file_update(struct song *song)
song
->
mtime
=
st
.
st_mtime
;
do
{
/* load file tag */
song
->
tag
=
decoder_plugin_tag_dup
(
plugin
,
path_fs
);
if
(
song
->
tag
!=
NULL
)
break
;
/* fall back to stream tag */
if
(
plugin
->
stream_tag
!=
NULL
)
{
/* open the input_stream (if not already
open) */
if
(
is
.
plugin
==
NULL
&&
!
input_stream_open
(
&
is
,
path_fs
,
NULL
))
is
.
plugin
=
NULL
;
/* now try the stream_tag() method */
if
(
is
.
plugin
!=
NULL
)
{
song
->
tag
=
decoder_plugin_stream_tag
(
plugin
,
&
is
);
if
(
song
->
tag
!=
NULL
)
break
;
input_stream_seek
(
&
is
,
0
,
SEEK_SET
,
NULL
);
}
}
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
);
}
while
(
plugin
!=
NULL
);
if
(
is
.
plugin
!=
NULL
)
input_stream_close
(
&
is
);
if
(
song
->
tag
!=
NULL
&&
tag_is_empty
(
song
->
tag
))
song
->
tag
=
tag_fallback
(
path_fs
,
song
->
tag
);
...
...
test/read_tags.c
View file @
6b96f5d5
...
...
@@ -169,6 +169,20 @@ int main(int argc, char **argv)
}
tag
=
decoder_plugin_tag_dup
(
plugin
,
path
);
if
(
tag
==
NULL
&&
plugin
->
stream_tag
!=
NULL
)
{
struct
input_stream
is
;
if
(
!
input_stream_open
(
&
is
,
path
,
&
error
))
{
g_printerr
(
"Failed to open %s: %s
\n
"
,
path
,
error
->
message
);
g_error_free
(
error
);
return
1
;
}
tag
=
decoder_plugin_stream_tag
(
plugin
,
&
is
);
input_stream_close
(
&
is
);
}
decoder_plugin_deinit_all
();
input_stream_global_finish
();
if
(
tag
==
NULL
)
{
...
...
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