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
97fe75a0
Commit
97fe75a0
authored
May 31, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
little cleanup of plugin stuff
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1247
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
30424cb3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
73 deletions
+43
-73
inputPlugin.h
src/inputPlugin.h
+2
-1
flac_plugin.c
src/inputPlugins/flac_plugin.c
+5
-8
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+3
-6
ogg_plugin.c
src/inputPlugins/ogg_plugin.c
+18
-25
song.c
src/song.c
+6
-2
tag.c
src/tag.c
+8
-8
tag.h
src/tag.h
+1
-23
No files found.
src/inputPlugin.h
View file @
97fe75a0
...
...
@@ -15,7 +15,8 @@ typedef int (* InputPlugin_streamDecodeFunc) (OutputBuffer *, DecoderControl *,
typedef
int
(
*
InputPlugin_fileDecodeFunc
)
(
OutputBuffer
*
,
DecoderControl
*
);
typedef
MpdTag
*
(
*
InputPlugin_tagDupFunc
)
(
char
*
utf8file
);
/* file should be the full path! */
typedef
MpdTag
*
(
*
InputPlugin_tagDupFunc
)
(
char
*
file
);
typedef
struct
_InputPlugin
{
char
*
name
;
...
...
src/inputPlugins/flac_plugin.c
View file @
97fe75a0
...
...
@@ -27,7 +27,6 @@
#include "../outputBuffer.h"
#include "../replayGain.h"
#include "../audio.h"
#include "../path.h"
#include <stdio.h>
#include <string.h>
...
...
@@ -438,7 +437,7 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
return
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
;
}
MpdTag
*
flacMetadataDup
(
char
*
utf8
file
,
int
*
vorbisCommentFound
)
{
MpdTag
*
flacMetadataDup
(
char
*
file
,
int
*
vorbisCommentFound
)
{
MpdTag
*
ret
=
NULL
;
FLAC__Metadata_SimpleIterator
*
it
;
FLAC__StreamMetadata
*
block
=
NULL
;
...
...
@@ -448,7 +447,7 @@ MpdTag * flacMetadataDup(char * utf8file, int * vorbisCommentFound) {
*
vorbisCommentFound
=
0
;
it
=
FLAC__metadata_simple_iterator_new
();
if
(
!
FLAC__metadata_simple_iterator_init
(
it
,
rmp2amp
(
utf8ToFsCharset
(
utf8file
))
,
1
,
0
))
{
if
(
!
FLAC__metadata_simple_iterator_init
(
it
,
file
,
1
,
0
))
{
FLAC__metadata_simple_iterator_delete
(
it
);
return
ret
;
}
...
...
@@ -530,14 +529,14 @@ MpdTag * flacMetadataDup(char * utf8file, int * vorbisCommentFound) {
return
ret
;
}
MpdTag
*
flacTagDup
(
char
*
utf8
file
)
{
MpdTag
*
flacTagDup
(
char
*
file
)
{
MpdTag
*
ret
=
NULL
;
int
foundVorbisComment
=
0
;
ret
=
flacMetadataDup
(
utf8file
,
&
foundVorbisComment
);
ret
=
flacMetadataDup
(
file
,
&
foundVorbisComment
);
if
(
!
ret
)
return
NULL
;
if
(
!
foundVorbisComment
)
{
MpdTag
*
temp
=
id3Dup
(
utf8
file
);
MpdTag
*
temp
=
id3Dup
(
file
);
if
(
temp
)
{
temp
->
time
=
ret
->
time
;
freeMpdTag
(
ret
);
...
...
@@ -545,8 +544,6 @@ MpdTag * flacTagDup(char * utf8file) {
}
}
if
(
ret
)
validateUtf8Tag
(
ret
);
return
ret
;
}
...
...
src/inputPlugins/mp3_plugin.c
View file @
97fe75a0
...
...
@@ -36,7 +36,6 @@
#include "../log.h"
#include "../utils.h"
#include "../tag.h"
#include "../path.h"
#include <stdio.h>
#include <string.h>
...
...
@@ -613,21 +612,19 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) {
return
0
;
}
MpdTag
*
mp3_tagDup
(
char
*
utf8
file
)
{
MpdTag
*
mp3_tagDup
(
char
*
file
)
{
MpdTag
*
ret
=
NULL
;
int
time
;
ret
=
id3Dup
(
utf8
file
);
ret
=
id3Dup
(
file
);
time
=
getMp3TotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
))
);
time
=
getMp3TotalTime
(
file
);
if
(
time
>=
0
)
{
if
(
!
ret
)
ret
=
newMpdTag
();
ret
->
time
=
time
;
}
if
(
ret
)
validateUtf8Tag
(
ret
);
return
ret
;
}
...
...
src/inputPlugins/ogg_plugin.c
View file @
97fe75a0
...
...
@@ -108,7 +108,9 @@ long ogg_tell_cb(void * vdata) {
char
*
ogg_parseComment
(
char
*
comment
,
char
*
needle
)
{
int
len
=
strlen
(
needle
);
if
(
strncasecmp
(
comment
,
needle
,
len
))
return
comment
+
len
;
if
(
strncasecmp
(
comment
,
needle
,
len
)
==
0
&&
*
(
comment
+
len
)
==
'='
)
{
return
comment
+
len
+
1
;
}
return
NULL
;
}
...
...
@@ -274,16 +276,14 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
return
0
;
}
MpdTag
*
oggTagDup
(
char
*
utf8
file
)
{
MpdTag
*
oggTagDup
(
char
*
file
)
{
MpdTag
*
ret
=
NULL
;
FILE
*
fp
;
OggVorbis_File
vf
;
char
**
comments
;
char
*
temp
;
char
*
s1
;
char
*
s2
;
fp
=
fopen
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
))
,
"r"
);
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
NULL
;
if
(
ov_open
(
fp
,
&
vf
,
NULL
,
0
)
<
0
)
{
fclose
(
fp
);
...
...
@@ -296,33 +296,28 @@ MpdTag * oggTagDup(char * utf8file) {
comments
=
ov_comment
(
&
vf
,
-
1
)
->
user_comments
;
while
(
*
comments
)
{
temp
=
strdup
(
*
comments
);
++
comments
;
if
(
!
(
s1
=
strtok
(
temp
,
"="
)))
continue
;
s2
=
strtok
(
NULL
,
""
);
if
(
!
s1
||
!
s2
);
else
if
(
0
==
strcasecmp
(
s1
,
"artist"
))
{
if
((
temp
=
ogg_parseComment
(
*
comments
,
"artist"
)))
{
if
(
!
ret
->
artist
)
{
stripReturnChar
(
s2
);
ret
->
artist
=
strdup
(
s2
);
ret
->
artist
=
strdup
(
temp
);
stripReturnChar
(
ret
->
artist
);
}
}
else
if
(
0
==
strcasecmp
(
s1
,
"title"
))
{
}
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"title"
)
))
{
if
(
!
ret
->
title
)
{
stripReturnChar
(
s2
);
ret
->
title
=
strdup
(
s2
);
ret
->
title
=
strdup
(
temp
);
stripReturnChar
(
ret
->
title
);
}
}
else
if
(
0
==
strcasecmp
(
s1
,
"album"
))
{
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"album"
)
))
{
if
(
!
ret
->
album
)
{
stripReturnChar
(
s2
);
ret
->
album
=
strdup
(
s2
);
ret
->
album
=
strdup
(
temp
);
stripReturnChar
(
ret
->
album
);
}
}
else
if
(
0
==
strcasecmp
(
s1
,
"tracknumber"
))
{
else
if
((
temp
=
ogg_parseComment
(
*
comments
,
"tracknumber"
)
))
{
if
(
!
ret
->
track
)
{
stripReturnChar
(
s2
);
ret
->
track
=
strdup
(
s2
);
ret
->
track
=
strdup
(
temp
);
stripReturnChar
(
ret
->
track
);
}
}
free
(
temp
);
...
...
@@ -330,8 +325,6 @@ MpdTag * oggTagDup(char * utf8file) {
ov_clear
(
&
vf
);
if
(
ret
)
validateUtf8Tag
(
ret
);
return
ret
;
}
...
...
src/song.c
View file @
97fe75a0
...
...
@@ -59,7 +59,9 @@ Song * newSong(char * utf8url, SONG_TYPE type) {
if
(
song
->
type
==
SONG_TYPE_FILE
)
{
InputPlugin
*
plugin
;
if
((
plugin
=
isMusic
(
utf8url
,
&
(
song
->
mtime
))))
{
song
->
tag
=
plugin
->
tagDupFunc
(
utf8url
);
song
->
tag
=
plugin
->
tagDupFunc
(
rmp2amp
(
utf8ToFsCharset
(
utf8url
)));
if
(
song
->
tag
)
validateUtf8Tag
(
song
->
tag
);
}
if
(
!
song
->
tag
||
song
->
tag
->
time
<
0
)
{
freeSong
(
song
);
...
...
@@ -267,7 +269,9 @@ int updateSongInfo(Song * song) {
song
->
tag
=
NULL
;
if
((
plugin
=
isMusic
(
utf8url
,
&
(
song
->
mtime
))))
{
song
->
tag
=
plugin
->
tagDupFunc
(
utf8url
);
song
->
tag
=
plugin
->
tagDupFunc
(
rmp2amp
(
utf8ToFsCharset
(
utf8url
)));
if
(
song
->
tag
)
validateUtf8Tag
(
song
->
tag
);
}
if
(
!
song
->
tag
||
song
->
tag
->
time
<
0
)
return
-
1
;
else
addSongToTables
(
song
);
...
...
src/tag.c
View file @
97fe75a0
...
...
@@ -101,22 +101,22 @@ char * getID3Info(struct id3_tag * tag, char * id) {
}
#endif
MpdTag
*
id3Dup
(
char
*
utf8filenam
e
)
{
MpdTag
*
id3Dup
(
char
*
fil
e
)
{
MpdTag
*
ret
=
NULL
;
#ifdef HAVE_ID3TAG
struct
id3_file
*
file
;
struct
id3_file
*
id3_
file
;
struct
id3_tag
*
tag
;
char
*
str
;
file
=
id3_file_open
(
rmp2amp
(
utf8ToFsCharset
(
utf8filename
)),
ID3_FILE_MODE_READONLY
);
if
(
!
file
)
{
id3_file
=
id3_file_open
(
file
,
ID3_FILE_MODE_READONLY
);
if
(
!
id3_
file
)
{
return
NULL
;
}
tag
=
id3_file_tag
(
file
);
tag
=
id3_file_tag
(
id3_
file
);
if
(
!
tag
)
{
id3_file_close
(
file
);
id3_file_close
(
id3_
file
);
return
NULL
;
}
...
...
@@ -148,7 +148,7 @@ MpdTag * id3Dup(char * utf8filename) {
ret
->
track
=
str
;
}
id3_file_close
(
file
);
id3_file_close
(
id3_
file
);
#endif
return
ret
;
...
...
src/tag.h
View file @
97fe75a0
...
...
@@ -31,34 +31,12 @@ typedef struct _MpdTag {
int
time
;
}
MpdTag
;
MpdTag
*
id3Dup
(
char
*
utf8filenam
e
);
MpdTag
*
id3Dup
(
char
*
fil
e
);
MpdTag
*
newMpdTag
();
void
freeMpdTag
(
MpdTag
*
tag
);
#ifdef HAVE_MAD
MpdTag
*
mp3TagDup
(
char
*
utf8file
);
#endif
#ifdef HAVE_FAAD
MpdTag
*
aacTagDup
(
char
*
utf8file
);
MpdTag
*
mp4TagDup
(
char
*
utf8file
);
#endif
#ifdef HAVE_OGG
MpdTag
*
oggTagDup
(
char
*
utf8file
);
#endif
#ifdef HAVE_FLAC
MpdTag
*
flacTagDup
(
char
*
utf8file
);
#endif
#ifdef HAVE_AUDIOFILE
MpdTag
*
audiofileTagDup
(
char
*
utf8file
);
#endif
void
printMpdTag
(
FILE
*
fp
,
MpdTag
*
tag
);
MpdTag
*
mpdTagDup
(
MpdTag
*
tag
);
...
...
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