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
5e7b18f8
Commit
5e7b18f8
authored
Oct 08, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
song: removed CamelCase
CamelCase is ugly... rename all functions.
parent
5e4be9e4
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
59 additions
and
58 deletions
+59
-58
decoder_api.c
src/decoder_api.c
+1
-1
decoder_thread.c
src/decoder_thread.c
+1
-1
directory.c
src/directory.c
+1
-1
locate.c
src/locate.c
+2
-2
player_control.c
src/player_control.c
+3
-3
player_thread.c
src/player_thread.c
+2
-2
playlist.c
src/playlist.c
+16
-16
song.c
src/song.c
+10
-10
song.h
src/song.h
+6
-6
song_print.c
src/song_print.c
+2
-2
song_save.c
src/song_save.c
+5
-5
storedPlaylist.c
src/storedPlaylist.c
+3
-2
update.c
src/update.c
+7
-7
No files found.
src/decoder_api.c
View file @
5e7b18f8
...
...
@@ -63,7 +63,7 @@ void decoder_initialized(struct decoder * decoder,
const
char
*
decoder_get_url
(
mpd_unused
struct
decoder
*
decoder
,
char
*
buffer
)
{
return
get_song_url
(
buffer
,
dc
.
current_song
);
return
song_get_url
(
dc
.
current_song
,
buffer
);
}
enum
decoder_command
decoder_get_command
(
mpd_unused
struct
decoder
*
decoder
)
...
...
src/decoder_thread.c
View file @
5e7b18f8
...
...
@@ -37,7 +37,7 @@ static void decodeStart(void)
char
path_max_fs
[
MPD_PATH_MAX
];
char
path_max_utf8
[
MPD_PATH_MAX
];
if
(
!
get_song_url
(
path_max_utf8
,
dc
.
next_song
))
{
if
(
!
song_get_url
(
dc
.
next_song
,
path_max_utf8
))
{
dc
.
error
=
DECODE_ERROR_FILE
;
goto
stop_no_close
;
}
...
...
src/directory.c
View file @
5e7b18f8
...
...
@@ -522,7 +522,7 @@ getSongFromDB(const char *file)
goto
out
;
if
(
!
(
song
=
songvec_find
(
&
directory
->
songs
,
shortname
)))
goto
out
;
assert
(
song
->
parent
Dir
==
directory
);
assert
(
song
->
parent
==
directory
);
out:
free
(
duplicated
);
...
...
src/locate.c
View file @
5e7b18f8
...
...
@@ -134,7 +134,7 @@ strstrSearchTag(struct song *song, enum tag_type type, char *str)
if
(
type
==
LOCATE_TAG_FILE_TYPE
||
type
==
LOCATE_TAG_ANY_TYPE
)
{
char
path_max_tmp
[
MPD_PATH_MAX
];
string_toupper
(
get_song_url
(
path_max_tmp
,
song
));
string_toupper
(
song_get_url
(
song
,
path_max_tmp
));
if
(
strstr
(
path_max_tmp
,
str
))
ret
=
1
;
if
(
ret
==
1
||
type
==
LOCATE_TAG_FILE_TYPE
)
...
...
@@ -192,7 +192,7 @@ tagItemFoundAndMatches(struct song *song, enum tag_type type, char *str)
if
(
type
==
LOCATE_TAG_FILE_TYPE
||
type
==
LOCATE_TAG_ANY_TYPE
)
{
char
path_max_tmp
[
MPD_PATH_MAX
];
if
(
0
==
strcmp
(
str
,
get_song_url
(
path_max_tmp
,
song
)))
if
(
0
==
strcmp
(
str
,
song_get_url
(
song
,
path_max_tmp
)))
return
1
;
if
(
type
==
LOCATE_TAG_FILE_TYPE
)
return
0
;
...
...
src/player_control.c
View file @
5e7b18f8
...
...
@@ -158,11 +158,11 @@ char *getPlayerErrorStr(void)
case
PLAYER_ERROR_FILENOTFOUND
:
snprintf
(
error
,
errorlen
,
"file
\"
%s
\"
does not exist or is inaccessible"
,
get_song_url
(
path_max_tmp
,
pc
.
errored_song
));
song_get_url
(
pc
.
errored_song
,
path_max_tmp
));
break
;
case
PLAYER_ERROR_FILE
:
snprintf
(
error
,
errorlen
,
"problems decoding
\"
%s
\"
"
,
get_song_url
(
path_max_tmp
,
pc
.
errored_song
));
song_get_url
(
pc
.
errored_song
,
path_max_tmp
));
break
;
case
PLAYER_ERROR_AUDIO
:
strcpy
(
error
,
"problems opening audio device"
);
...
...
@@ -172,7 +172,7 @@ char *getPlayerErrorStr(void)
break
;
case
PLAYER_ERROR_UNKTYPE
:
snprintf
(
error
,
errorlen
,
"file type of
\"
%s
\"
is unknown"
,
get_song_url
(
path_max_tmp
,
pc
.
errored_song
));
song_get_url
(
pc
.
errored_song
,
path_max_tmp
));
}
return
*
error
?
error
:
NULL
;
}
...
...
src/player_thread.c
View file @
5e7b18f8
...
...
@@ -135,7 +135,7 @@ static void processDecodeInput(int *pause_r, unsigned int *bbp_r,
pc
.
error
=
PLAYER_ERROR_AUDIO
;
ERROR
(
"problems opening audio device "
"while playing
\"
%s
\"\n
"
,
get_song_url
(
tmp
,
dc
.
next_song
));
song_get_url
(
dc
.
next_song
,
tmp
));
*
pause_r
=
-
1
;
}
}
...
...
@@ -244,7 +244,7 @@ static void do_play(void)
pc
.
error
=
PLAYER_ERROR_AUDIO
;
ERROR
(
"problems opening audio device "
"while playing
\"
%s
\"\n
"
,
get_song_url
(
tmp
,
dc
.
next_song
));
song_get_url
(
dc
.
next_song
,
tmp
));
break
;
}
...
...
src/playlist.c
View file @
5e7b18f8
...
...
@@ -176,7 +176,7 @@ void finishPlaylist(void)
int
i
;
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
if
(
!
song_is_file
(
playlist
.
songs
[
i
]))
{
freeJustSong
(
playlist
.
songs
[
i
]);
song_free
(
playlist
.
songs
[
i
]);
}
}
...
...
@@ -202,7 +202,7 @@ void clearPlaylist(void)
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
if
(
!
song_is_file
(
playlist
.
songs
[
i
]))
{
freeJustSong
(
playlist
.
songs
[
i
]);
song_free
(
playlist
.
songs
[
i
]);
}
playlist
.
idToPosition
[
playlist
.
positionToId
[
i
]]
=
-
1
;
playlist
.
songs
[
i
]
=
NULL
;
...
...
@@ -225,7 +225,7 @@ void showPlaylist(struct client *client)
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
client_printf
(
client
,
"%i:%s
\n
"
,
i
,
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
i
]
));
song_get_url
(
playlist
.
songs
[
i
],
path_max_tmp
));
}
}
...
...
@@ -236,7 +236,7 @@ static void playlist_save(FILE *fp)
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
fprintf
(
fp
,
"%i:%s
\n
"
,
i
,
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
i
]
));
song_get_url
(
playlist
.
songs
[
i
],
path_max_tmp
));
}
void
savePlaylistState
(
FILE
*
fp
)
...
...
@@ -479,9 +479,9 @@ static void queueNextSongInPlaylist(void)
playlist
.
queued
=
playlist
.
current
+
1
;
DEBUG
(
"playlist: queue song %i:
\"
%s
\"\n
"
,
playlist
.
queued
,
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
));
song_get_url
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]],
path_max_tmp
));
queueSong
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]);
}
else
if
(
playlist
.
length
&&
playlist
.
repeat
)
{
if
(
playlist
.
length
>
1
&&
playlist
.
random
)
{
...
...
@@ -490,9 +490,9 @@ static void queueNextSongInPlaylist(void)
playlist
.
queued
=
0
;
DEBUG
(
"playlist: queue song %i:
\"
%s
\"\n
"
,
playlist
.
queued
,
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]
));
song_get_url
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]],
path_max_tmp
));
queueSong
(
playlist
.
songs
[
playlist
.
order
[
playlist
.
queued
]]);
}
}
...
...
@@ -584,7 +584,7 @@ int addToStoredPlaylist(const char *url, const char *utf8file)
song
=
song_remote_new
(
url
);
if
(
song
)
{
int
ret
=
appendSongToStoredPlaylistByPath
(
utf8file
,
song
);
freeJustSong
(
song
);
song_free
(
song
);
return
ret
;
}
...
...
@@ -718,7 +718,7 @@ enum playlist_result deleteFromPlaylist(int song)
}
if
(
!
song_is_file
(
playlist
.
songs
[
song
]))
{
freeJustSong
(
playlist
.
songs
[
song
]);
song_free
(
playlist
.
songs
[
song
]);
}
playlist
.
idToPosition
[
playlist
.
positionToId
[
song
]]
=
-
1
;
...
...
@@ -812,8 +812,8 @@ static void playPlaylistOrderNumber(int orderNum)
playlist
.
queued
=
-
1
;
DEBUG
(
"playlist: play %i:
\"
%s
\"\n
"
,
orderNum
,
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
playlist
.
order
[
orderNum
]]
));
song_get_url
(
playlist
.
songs
[
playlist
.
order
[
orderNum
]]
,
path_max_tmp
));
playerPlay
(
playlist
.
songs
[
playlist
.
order
[
orderNum
]]);
playlist
.
current
=
orderNum
;
...
...
@@ -895,7 +895,7 @@ static void syncCurrentPlayerDecodeMetadata(void)
song
=
playlist
.
songs
[
songNum
];
if
(
!
song_is_file
(
song
)
&&
0
==
strcmp
(
get_song_url
(
path_max_tmp
,
song
),
songPlayer
->
url
)
&&
0
==
strcmp
(
song_get_url
(
song
,
path_max_tmp
),
songPlayer
->
url
)
&&
!
tag_equal
(
song
->
tag
,
songPlayer
->
tag
))
{
if
(
song
->
tag
)
tag_free
(
song
->
tag
);
...
...
@@ -1265,7 +1265,7 @@ enum playlist_result savePlaylist(const char *utf8file)
for
(
i
=
0
;
i
<
playlist
.
length
;
i
++
)
{
char
tmp
[
MPD_PATH_MAX
];
get_song_url
(
path_max_tmp
,
playlist
.
songs
[
i
]
);
song_get_url
(
playlist
.
songs
[
i
],
path_max_tmp
);
utf8_to_fs_charset
(
tmp
,
path_max_tmp
);
if
(
playlist_saveAbsolutePaths
&&
...
...
src/song.c
View file @
5e7b18f8
...
...
@@ -39,7 +39,7 @@ song_alloc(const char *url, struct directory *parent)
song
->
tag
=
NULL
;
memcpy
(
song
->
url
,
url
,
urllen
+
1
);
song
->
parent
Dir
=
parent
;
song
->
parent
=
parent
;
return
song
;
}
...
...
@@ -75,14 +75,14 @@ song_file_load(const char *path, struct directory *parent)
song
=
song_file_new
(
path
,
parent
);
abs_path
=
rmp2amp_r
(
path_max_tmp
,
get_song_url
(
path_max_tmp
,
song
));
abs_path
=
rmp2amp_r
(
path_max_tmp
,
song_get_url
(
song
,
path_max_tmp
));
while
(
song
->
tag
==
NULL
&&
(
plugin
=
isMusic
(
abs_path
,
&
(
song
->
mtime
),
next
++
)))
{
song
->
tag
=
plugin
->
tag_dup
(
abs_path
);
}
if
(
song
->
tag
==
NULL
||
song
->
tag
->
time
<
0
)
{
freeJustSong
(
song
);
song_free
(
song
);
return
NULL
;
}
...
...
@@ -90,7 +90,7 @@ song_file_load(const char *path, struct directory *parent)
}
void
freeJustSong
(
struct
song
*
song
)
song_free
(
struct
song
*
song
)
{
if
(
song
->
tag
)
tag_free
(
song
->
tag
);
...
...
@@ -98,7 +98,7 @@ freeJustSong(struct song *song)
}
int
updateSongInfo
(
struct
song
*
song
)
song_file_update
(
struct
song
*
song
)
{
if
(
song_is_file
(
song
))
{
struct
decoder_plugin
*
plugin
;
...
...
@@ -106,7 +106,7 @@ updateSongInfo(struct song *song)
char
path_max_tmp
[
MPD_PATH_MAX
];
char
abs_path
[
MPD_PATH_MAX
];
utf8_to_fs_charset
(
abs_path
,
get_song_url
(
path_max_tmp
,
song
));
utf8_to_fs_charset
(
abs_path
,
song_get_url
(
song
,
path_max_tmp
));
rmp2amp_r
(
abs_path
,
abs_path
);
if
(
song
->
tag
)
...
...
@@ -127,18 +127,18 @@ updateSongInfo(struct song *song)
}
char
*
get_song_url
(
char
*
path_max_tmp
,
struct
song
*
song
)
song_get_url
(
struct
song
*
song
,
char
*
path_max_tmp
)
{
if
(
!
song
)
return
NULL
;
assert
(
*
song
->
url
);
if
(
!
song
->
parent
Dir
||
!
song
->
parentDir
->
path
)
if
(
!
song
->
parent
||
!
song
->
parent
->
path
)
strcpy
(
path_max_tmp
,
song
->
url
);
else
pfx_dir
(
path_max_tmp
,
song
->
url
,
strlen
(
song
->
url
),
getDirectoryPath
(
song
->
parent
Dir
),
strlen
(
getDirectoryPath
(
song
->
parent
Dir
)));
getDirectoryPath
(
song
->
parent
),
strlen
(
getDirectoryPath
(
song
->
parent
)));
return
path_max_tmp
;
}
src/song.h
View file @
5e7b18f8
...
...
@@ -31,7 +31,7 @@
struct
song
{
struct
tag
*
tag
;
struct
directory
*
parent
Dir
;
struct
directory
*
parent
;
time_t
mtime
;
char
url
[
sizeof
(
int
)];
};
...
...
@@ -53,24 +53,24 @@ struct song *
song_file_load
(
const
char
*
path
,
struct
directory
*
parent
);
void
freeJustSong
(
struct
song
*
);
song_free
(
struct
song
*
song
);
int
updateSongInfo
(
struct
song
*
song
);
song_file_update
(
struct
song
*
song
);
/*
*
get_song
_url - Returns a path of a song in UTF8-encoded form
*
song_get
_url - Returns a path of a song in UTF8-encoded form
* path_max_tmp is the argument that the URL is written to, this
* buffer is assumed to be MPD_PATH_MAX or greater (including
* terminating '\0').
*/
char
*
get_song_url
(
char
*
path_max_tmp
,
struct
song
*
song
);
song_get_url
(
struct
song
*
song
,
char
*
path_max_tmp
);
static
inline
bool
song_is_file
(
const
struct
song
*
song
)
{
return
song
->
parent
Dir
!=
NULL
;
return
song
->
parent
!=
NULL
;
}
#endif
src/song_print.c
View file @
5e7b18f8
...
...
@@ -26,9 +26,9 @@
void
song_print_url
(
struct
client
*
client
,
struct
song
*
song
)
{
if
(
song
->
parent
Dir
&&
song
->
parentDir
->
path
)
{
if
(
song
->
parent
&&
song
->
parent
->
path
)
{
client_printf
(
client
,
"%s%s/%s
\n
"
,
SONG_FILE
,
getDirectoryPath
(
song
->
parent
Dir
),
song
->
url
);
getDirectoryPath
(
song
->
parent
),
song
->
url
);
}
else
{
client_printf
(
client
,
"%s%s
\n
"
,
SONG_FILE
,
song
->
url
);
}
...
...
src/song_save.c
View file @
5e7b18f8
...
...
@@ -31,9 +31,9 @@
static
void
song_save_url
(
FILE
*
fp
,
struct
song
*
song
)
{
if
(
song
->
parent
Dir
!=
NULL
&&
song
->
parentDir
->
path
!=
NULL
)
if
(
song
->
parent
!=
NULL
&&
song
->
parent
->
path
!=
NULL
)
fprintf
(
fp
,
SONG_FILE
"%s/%s
\n
"
,
getDirectoryPath
(
song
->
parent
Dir
),
song
->
url
);
getDirectoryPath
(
song
->
parent
),
song
->
url
);
else
fprintf
(
fp
,
SONG_FILE
"%s
\n
"
,
song
->
url
);
...
...
@@ -81,7 +81,7 @@ insertSongIntoList(struct songvec *sv, struct song *newsong)
existing
->
mtime
=
newsong
->
mtime
;
newsong
->
tag
=
NULL
;
}
freeJustSong
(
newsong
);
song_free
(
newsong
);
}
}
...
...
@@ -101,7 +101,7 @@ static int matchesAnMpdTagItemKey(char *buffer, int *itemType)
}
void
readSongInfoIntoList
(
FILE
*
fp
,
struct
songvec
*
sv
,
struct
directory
*
parent
Dir
)
struct
directory
*
parent
)
{
char
buffer
[
MPD_PATH_MAX
+
1024
];
int
bufferSize
=
MPD_PATH_MAX
+
1024
;
...
...
@@ -114,7 +114,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv,
insertSongIntoList
(
sv
,
song
);
song
=
song_file_new
(
buffer
+
strlen
(
SONG_KEY
),
parent
Dir
);
parent
);
}
else
if
(
*
buffer
==
0
)
{
/* ignore empty lines (starting with '\0') */
}
else
if
(
song
==
NULL
)
{
...
...
src/storedPlaylist.c
View file @
5e7b18f8
...
...
@@ -117,7 +117,7 @@ List *loadStoredPlaylist(const char *utf8path)
memmove
(
s
,
s
+
musicDir_len
+
1
,
strlen
(
s
+
musicDir_len
+
1
)
+
1
);
if
((
song
=
getSongFromDB
(
s
)))
{
get_song_url
(
path_max_tmp
,
song
);
song_get_url
(
song
,
path_max_tmp
);
insertInListWithoutKey
(
list
,
xstrdup
(
path_max_tmp
));
}
else
if
(
isValidRemoteUtf8Url
(
s
))
insertInListWithoutKey
(
list
,
xstrdup
(
s
));
...
...
@@ -293,7 +293,8 @@ appendSongToStoredPlaylistByPath(const char *utf8path, struct song *song)
return
PLAYLIST_RESULT_TOO_LARGE
;
}
s
=
utf8_to_fs_charset
(
path_max_tmp2
,
get_song_url
(
path_max_tmp
,
song
));
s
=
utf8_to_fs_charset
(
path_max_tmp2
,
song_get_url
(
song
,
path_max_tmp
));
if
(
playlist_saveAbsolutePaths
&&
song_is_file
(
song
))
s
=
rmp2amp_r
(
path_max_tmp
,
s
);
...
...
src/update.c
View file @
5e7b18f8
...
...
@@ -78,7 +78,7 @@ delete_song(struct directory *dir, struct song *del)
cond_leave
(
&
delete_cond
);
/* finally, all possible references gone, free it */
freeJustSong
(
del
);
song_free
(
del
);
}
struct
delete_data
{
...
...
@@ -93,7 +93,7 @@ delete_song_if_removed(struct song *song, void *_data)
{
struct
delete_data
*
data
=
_data
;
data
->
tmp
=
get_song_url
(
data
->
tmp
,
song
);
data
->
tmp
=
song_get_url
(
song
,
data
->
tmp
);
assert
(
data
->
tmp
);
if
(
!
isFile
(
data
->
tmp
,
NULL
))
{
...
...
@@ -232,7 +232,7 @@ updateInDirectory(struct directory *directory, const char *name)
return
UPDATE_RETURN_UPDATED
;
}
else
if
(
st
.
st_mtime
!=
song
->
mtime
)
{
LOG
(
"updating %s
\n
"
,
name
);
if
(
updateSongInfo
(
song
)
<
0
)
if
(
song_file_update
(
song
)
<
0
)
delete_song
(
directory
,
song
);
return
UPDATE_RETURN_UPDATED
;
}
...
...
@@ -407,7 +407,7 @@ static enum update_return updatePath(const char *utf8path)
/* don't return, path maybe a song now */
}
}
else
if
((
song
=
getSongFromDB
(
path
)))
{
parentDirectory
=
song
->
parent
Dir
;
parentDirectory
=
song
->
parent
;
if
(
!
parentDirectory
->
stat
&&
statDirectory
(
parentDirectory
)
<
0
)
{
free
(
path
);
...
...
@@ -417,11 +417,11 @@ static enum update_return updatePath(const char *utf8path)
else
if
(
!
inodeFoundInParent
(
parentDirectory
->
parent
,
parentDirectory
->
inode
,
parentDirectory
->
device
)
&&
isMusic
(
get_song_url
(
path_max_tmp
,
song
),
&
mtime
,
0
))
{
isMusic
(
song_get_url
(
song
,
path_max_tmp
),
&
mtime
,
0
))
{
free
(
path
);
if
(
song
->
mtime
==
mtime
)
return
UPDATE_RETURN_NOUPDATE
;
else
if
(
updateSongInfo
(
song
)
==
0
)
else
if
(
song_file_update
(
song
)
==
0
)
return
UPDATE_RETURN_UPDATED
;
else
{
delete_song
(
parentDirectory
,
song
);
...
...
@@ -521,7 +521,7 @@ void reap_update_task(void)
cond_enter
(
&
delete_cond
);
if
(
delete
)
{
char
tmp
[
MPD_PATH_MAX
];
LOG
(
"removing: %s
\n
"
,
get_song_url
(
tmp
,
delete
));
LOG
(
"removing: %s
\n
"
,
song_get_url
(
delete
,
tmp
));
deleteASongFromPlaylist
(
delete
);
delete
=
NULL
;
cond_signal_async
(
&
delete_cond
);
...
...
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