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
8c484eec
Commit
8c484eec
authored
May 13, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add type element to Song struct, and change utf8file to utf8url
git-svn-id:
https://svn.musicpd.org/mpd/trunk@999
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
e7ae1b0c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
60 deletions
+87
-60
directory.c
src/directory.c
+6
-5
playlist.c
src/playlist.c
+14
-12
song.c
src/song.c
+57
-40
song.h
src/song.h
+10
-3
No files found.
src/directory.c
View file @
8c484eec
...
...
@@ -277,7 +277,7 @@ void removeSongFromDirectory(Directory * directory, char * shortname) {
void
*
song
;
if
(
findInList
(
directory
->
songs
,
shortname
,
&
song
))
{
LOG
(
"removing: %s
\n
"
,((
Song
*
)
song
)
->
utf8
file
);
LOG
(
"removing: %s
\n
"
,((
Song
*
)
song
)
->
utf8
url
);
deleteFromList
(
directory
->
songs
,
shortname
);
}
}
...
...
@@ -508,7 +508,7 @@ int updatePath(char * utf8path) {
}
else
if
((
song
=
getSongDetails
(
path
,
&
shortname
,
&
parentDirectory
)))
{
/* if this song update is successfull, we are done */
if
(
song
&&
isMusic
(
song
->
utf8
file
,
&
mtime
))
{
if
(
song
&&
isMusic
(
song
->
utf8
url
,
&
mtime
))
{
free
(
path
);
if
(
song
->
mtime
==
mtime
)
return
0
;
else
if
(
updateSongInfo
(
song
)
==
0
)
return
1
;
...
...
@@ -655,7 +655,8 @@ int addToDirectory(Directory * directory, char * shortname, char * name) {
}
else
if
(
isMusic
(
name
,
NULL
))
{
Song
*
song
;
song
=
addSongToList
(
directory
->
songs
,
shortname
,
name
);
song
=
addSongToList
(
directory
->
songs
,
shortname
,
name
,
SONG_TYPE_FILE
);
if
(
!
song
)
return
-
1
;
LOG
(
"added %s
\n
"
,
name
);
return
1
;
...
...
@@ -1071,7 +1072,7 @@ int printDirectoryInDirectory(FILE * fp, Directory * directory, void * data) {
}
int
printSongInDirectory
(
FILE
*
fp
,
Song
*
song
,
void
*
data
)
{
myfprintf
(
fp
,
"file: %s
\n
"
,
song
->
utf8
file
);
myfprintf
(
fp
,
"file: %s
\n
"
,
song
->
utf8
url
);
return
0
;
}
...
...
@@ -1103,7 +1104,7 @@ int searchForTitleInDirectory(FILE * fp, Song * song, void * string) {
}
int
searchForFilenameInDirectory
(
FILE
*
fp
,
Song
*
song
,
void
*
string
)
{
char
*
dup
=
strDupToUpper
(
song
->
utf8
file
);
char
*
dup
=
strDupToUpper
(
song
->
utf8
url
);
if
(
strstr
(
dup
,(
char
*
)
string
))
printSongInfo
(
fp
,
song
);
free
(
dup
);
return
0
;
...
...
src/playlist.c
View file @
8c484eec
...
...
@@ -161,7 +161,7 @@ int showPlaylist(FILE * fp) {
int
i
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
myfprintf
(
fp
,
"%i:%s
\n
"
,
i
,(
playlist
.
songs
[
i
])
->
utf8
file
);
myfprintf
(
fp
,
"%i:%s
\n
"
,
i
,(
playlist
.
songs
[
i
])
->
utf8
url
);
}
return
0
;
...
...
@@ -357,7 +357,7 @@ int playlistInfo(FILE * fp,int song) {
}
for
(
i
=
begin
;
i
<
end
;
i
++
)
{
myfprintf
(
fp
,
"file: %s
\n
"
,(
playlist
.
songs
[
i
])
->
utf8
file
);
myfprintf
(
fp
,
"file: %s
\n
"
,(
playlist
.
songs
[
i
])
->
utf8
url
);
if
((
tag
=
(
playlist
.
songs
[
i
])
->
tag
))
{
printMpdTag
(
fp
,
tag
);
}
...
...
@@ -380,9 +380,9 @@ void queueNextSongInPlaylist() {
DEBUG
(
"playlist: queue song %i:
\"
%s
\"\n
"
,
playlist
.
queued
,
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
->
utf8
file
);
playlist
.
queued
]]
->
utf8
url
);
if
(
queueSong
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
->
utf8
file
)
<
0
)
{
playlist
.
queued
]]
->
utf8
url
)
<
0
)
{
playlist
.
queued
=
-
1
;
playlist_queueError
=
1
;
}
...
...
@@ -395,9 +395,9 @@ void queueNextSongInPlaylist() {
DEBUG
(
"playlist: queue song %i:
\"
%s
\"\n
"
,
playlist
.
queued
,
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
->
utf8
file
);
playlist
.
queued
]]
->
utf8
url
);
if
(
queueSong
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
->
utf8
file
)
<
0
)
{
playlist
.
queued
]]
->
utf8
url
)
<
0
)
{
playlist
.
queued
=
-
1
;
playlist_queueError
=
1
;
}
...
...
@@ -645,10 +645,10 @@ int playPlaylistOrderNumber(FILE * fp, int orderNum) {
playlist
.
current
=
orderNum
;
DEBUG
(
"playlist: play %i:
\"
%s
\"\n
"
,
orderNum
,
(
playlist
.
songs
[
playlist
.
order
[
orderNum
]])
->
utf8
file
);
(
playlist
.
songs
[
playlist
.
order
[
orderNum
]])
->
utf8
url
);
if
(
playerPlay
(
fp
,(
playlist
.
songs
[
playlist
.
order
[
orderNum
]])
->
utf8
file
)
<
0
)
utf8
url
)
<
0
)
{
stopPlaylist
(
fp
);
return
-
1
;
...
...
@@ -1052,12 +1052,14 @@ int savePlaylist(FILE * fp, char * utf8file) {
}
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
if
(
playlist_saveAbsolutePaths
)
{
if
(
playlist_saveAbsolutePaths
&&
playlist
.
songs
[
i
]
->
type
==
SONG_TYPE_FILE
)
{
myfprintf
(
fileP
,
"%s
\n
"
,
rmp2amp
(
utf8ToFsCharset
((
playlist
.
songs
[
i
])
->
utf8
file
)));
playlist
.
songs
[
i
])
->
utf8
url
)));
}
else
myfprintf
(
fileP
,
"%s
\n
"
,
utf8ToFsCharset
((
playlist
.
songs
[
i
])
->
utf8
file
));
utf8ToFsCharset
((
playlist
.
songs
[
i
])
->
utf8
url
));
}
while
(
fclose
(
fileP
)
&&
errno
==
EINTR
);
...
...
@@ -1203,6 +1205,6 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
if
(
playPlaylistOrderNumber
(
fp
,
i
)
<
0
)
return
-
1
;
}
return
playerSeek
(
fp
,
playlist
.
songs
[
playlist
.
order
[
i
]]
->
utf8
file
,
time
);
return
playerSeek
(
fp
,
playlist
.
songs
[
playlist
.
order
[
i
]]
->
utf8
url
,
time
);
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/song.c
View file @
8c484eec
...
...
@@ -47,43 +47,46 @@ Song * newNullSong() {
Song
*
song
=
malloc
(
sizeof
(
Song
));
song
->
tag
=
NULL
;
song
->
utf8file
=
NULL
;
song
->
utf8url
=
NULL
;
song
->
type
=
SONG_TYPE_FILE
;
return
song
;
}
Song
*
newSong
(
char
*
utf8
fil
e
)
{
Song
*
newSong
(
char
*
utf8
url
,
SONG_TYPE
typ
e
)
{
Song
*
song
=
newNullSong
();
song
->
utf8file
=
strdup
(
utf8file
);
song
->
utf8url
=
strdup
(
utf8url
);
song
->
type
=
type
;
if
(
!
isFile
(
utf8file
,
&
(
song
->
mtime
)));
if
(
song
->
type
==
SONG_TYPE_FILE
)
{
if
(
!
isFile
(
utf8url
,
&
(
song
->
mtime
)));
#ifdef HAVE_OGG
else
if
(
hasOggSuffix
(
utf8file
))
{
song
->
tag
=
oggTagDup
(
utf8file
);
else
if
(
hasOggSuffix
(
utf8url
))
{
song
->
tag
=
oggTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_FLAC
else
if
((
hasFlacSuffix
(
utf8file
)))
{
song
->
tag
=
flacTagDup
(
utf8file
);
else
if
((
hasFlacSuffix
(
utf8url
)))
{
song
->
tag
=
flacTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_MAD
else
if
(
hasMp3Suffix
(
utf8file
))
{
song
->
tag
=
mp3TagDup
(
utf8file
);
else
if
(
hasMp3Suffix
(
utf8url
))
{
song
->
tag
=
mp3TagDup
(
utf8url
);
}
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
hasWaveSuffix
(
utf8file
))
{
song
->
tag
=
audiofileTagDup
(
utf8file
);
else
if
(
hasWaveSuffix
(
utf8url
))
{
song
->
tag
=
audiofileTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_FAAD
else
if
(
hasAacSuffix
(
utf8file
))
{
song
->
tag
=
aacTagDup
(
utf8file
);
else
if
(
hasAacSuffix
(
utf8url
))
{
song
->
tag
=
aacTagDup
(
utf8url
);
}
else
if
(
hasMp4Suffix
(
utf8file
))
{
song
->
tag
=
mp4TagDup
(
utf8file
);
else
if
(
hasMp4Suffix
(
utf8url
))
{
song
->
tag
=
mp4TagDup
(
utf8url
);
}
#endif
...
...
@@ -92,20 +95,21 @@ Song * newSong(char * utf8file) {
song
=
NULL
;
}
else
addSongToTables
(
song
);
}
return
song
;
}
void
freeSong
(
Song
*
song
)
{
deleteASongFromPlaylist
(
song
);
removeASongFromTables
(
song
);
free
(
song
->
utf8
file
);
if
(
song
->
type
==
SONG_TYPE_FILE
)
removeASongFromTables
(
song
);
free
(
song
->
utf8
url
);
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
free
(
song
);
}
void
freeJustSong
(
Song
*
song
)
{
free
(
song
->
utf8
file
);
free
(
song
->
utf8
url
);
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
free
(
song
);
}
...
...
@@ -114,11 +118,20 @@ SongList * newSongList() {
return
makeList
((
ListFreeDataFunc
*
)
freeSong
);
}
Song
*
addSongToList
(
SongList
*
list
,
char
*
key
,
char
*
utf8file
)
{
Song
*
addSongToList
(
SongList
*
list
,
char
*
key
,
char
*
utf8url
,
SONG_TYPE
type
)
{
Song
*
song
=
NULL
;
if
(
isMusic
(
utf8file
,
NULL
))
{
song
=
newSong
(
utf8file
);
switch
(
type
)
{
case
SONG_TYPE_FILE
:
if
(
isMusic
(
utf8url
,
NULL
))
{
song
=
newSong
(
utf8url
,
type
);
}
break
;
case
SONG_TYPE_URL
:
song
=
newSong
(
utf8url
,
type
);
break
;
}
if
(
song
==
NULL
)
return
NULL
;
...
...
@@ -133,7 +146,7 @@ void freeSongList(SongList * list) {
}
int
printSongInfo
(
FILE
*
fp
,
Song
*
song
)
{
myfprintf
(
fp
,
"%s%s
\n
"
,
SONG_FILE
,
song
->
utf8
file
);
myfprintf
(
fp
,
"%s%s
\n
"
,
SONG_FILE
,
song
->
utf8
url
);
if
(
song
->
tag
)
printMpdTag
(
fp
,
song
->
tag
);
...
...
@@ -220,13 +233,14 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
key
=
strdup
(
&
(
buffer
[
strlen
(
SONG_KEY
)]));
song
=
newNullSong
();
song
->
type
=
SONG_TYPE_FILE
;
}
else
if
(
0
==
strncmp
(
SONG_FILE
,
buffer
,
strlen
(
SONG_FILE
)))
{
if
(
!
song
||
song
->
utf8
file
)
{
if
(
!
song
||
song
->
utf8
url
)
{
ERROR
(
"Problems reading song info
\n
"
);
exit
(
EXIT_FAILURE
);
}
song
->
utf8
file
=
strdup
(
&
(
buffer
[
strlen
(
SONG_FILE
)]));
song
->
utf8
url
=
strdup
(
&
(
buffer
[
strlen
(
SONG_FILE
)]));
}
else
if
(
0
==
strncmp
(
SONG_ARTIST
,
buffer
,
strlen
(
SONG_ARTIST
)))
{
if
(
!
song
->
tag
)
song
->
tag
=
newMpdTag
();
...
...
@@ -271,45 +285,47 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
}
int
updateSongInfo
(
Song
*
song
)
{
char
*
utf8
file
=
song
->
utf8file
;
char
*
utf8
url
=
song
->
utf8url
;
if
(
song
->
type
==
SONG_TYPE_FILE
)
{
removeASongFromTables
(
song
);
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
song
->
tag
=
NULL
;
if
(
!
isFile
(
utf8file
,
&
(
song
->
mtime
)));
if
(
!
isFile
(
utf8url
,
&
(
song
->
mtime
)));
#ifdef HAVE_OGG
else
if
(
hasOggSuffix
(
utf8file
))
{
song
->
tag
=
oggTagDup
(
utf8file
);
else
if
(
hasOggSuffix
(
utf8url
))
{
song
->
tag
=
oggTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_FLAC
else
if
((
hasFlacSuffix
(
utf8file
)))
{
song
->
tag
=
flacTagDup
(
utf8file
);
else
if
((
hasFlacSuffix
(
utf8url
)))
{
song
->
tag
=
flacTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_MAD
else
if
(
hasMp3Suffix
(
utf8file
))
{
song
->
tag
=
mp3TagDup
(
utf8file
);
else
if
(
hasMp3Suffix
(
utf8url
))
{
song
->
tag
=
mp3TagDup
(
utf8url
);
}
#endif
#ifdef HAVE_AUDIOFILE
else
if
(
hasWaveSuffix
(
utf8file
))
{
song
->
tag
=
audiofileTagDup
(
utf8file
);
else
if
(
hasWaveSuffix
(
utf8url
))
{
song
->
tag
=
audiofileTagDup
(
utf8url
);
}
#endif
#ifdef HAVE_FAAD
else
if
(
hasAacSuffix
(
utf8file
))
{
song
->
tag
=
aacTagDup
(
utf8file
);
else
if
(
hasAacSuffix
(
utf8url
))
{
song
->
tag
=
aacTagDup
(
utf8url
);
}
else
if
(
hasMp4Suffix
(
utf8file
))
{
song
->
tag
=
mp4TagDup
(
utf8file
);
else
if
(
hasMp4Suffix
(
utf8url
))
{
song
->
tag
=
mp4TagDup
(
utf8url
);
}
#endif
if
(
!
song
->
tag
||
song
->
tag
->
time
<
0
)
return
-
1
;
else
addSongToTables
(
song
);
}
return
0
;
}
...
...
@@ -317,9 +333,10 @@ int updateSongInfo(Song * song) {
Song
*
songDup
(
Song
*
song
)
{
Song
*
ret
=
malloc
(
sizeof
(
Song
));
ret
->
utf8
file
=
strdup
(
song
->
utf8file
);
ret
->
utf8
url
=
strdup
(
song
->
utf8url
);
ret
->
mtime
=
song
->
mtime
;
ret
->
tag
=
mpdTagDup
(
song
->
tag
);
ret
->
type
=
song
->
type
;
return
ret
;
}
...
...
src/song.h
View file @
8c484eec
...
...
@@ -30,15 +30,21 @@
#include "tag.h"
#include "list.h"
typedef
enum
{
SONG_TYPE_FILE
,
SONG_TYPE_URL
}
SONG_TYPE
;
typedef
struct
_Song
{
char
*
utf8file
;
char
*
utf8url
;
SONG_TYPE
type
;
MpdTag
*
tag
;
time_t
mtime
;
}
Song
;
typedef
List
SongList
;
Song
*
newSong
(
char
*
utf8
fil
e
);
Song
*
newSong
(
char
*
utf8
url
,
SONG_TYPE
typ
e
);
void
freeSong
(
Song
*
);
...
...
@@ -46,7 +52,8 @@ SongList * newSongList();
void
freeSongList
(
SongList
*
list
);
Song
*
addSongToList
(
SongList
*
list
,
char
*
key
,
char
*
utf8file
);
Song
*
addSongToList
(
SongList
*
list
,
char
*
key
,
char
*
utf8file
,
SONG_TYPE
type
);
int
printSongInfo
(
FILE
*
fp
,
Song
*
song
);
...
...
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