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
68dc3517
Commit
68dc3517
authored
Mar 10, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move adding and removeing from tables from directory.c to song.c
git-svn-id:
https://svn.musicpd.org/mpd/trunk@239
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
e5e45242
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
29 deletions
+53
-29
directory.c
src/directory.c
+4
-8
main.c
src/main.c
+1
-1
song.c
src/song.c
+48
-20
No files found.
src/directory.c
View file @
68dc3517
...
...
@@ -20,13 +20,12 @@
#include "ls.h"
#include "command.h"
#include "tables.h"
#include "utils.h"
#include "path.h"
#include "log.h"
#include "playlist.h"
#include "conf.h"
#include "stats.h"
#include "playlist.h"
#include <string.h>
#include <sys/types.h>
...
...
@@ -98,8 +97,6 @@ Directory * newDirectory(Directory * parentDirectory, char * dirname, time_t mti
void
freeDirectory
(
Directory
*
directory
)
{
freeDirectoryList
(
directory
->
subDirectories
);
removeSongsFromTables
(
directory
->
songs
);
deleteSongsFromPlaylist
(
directory
->
songs
);
freeSongList
(
directory
->
songs
);
if
(
directory
->
utf8name
)
free
(
directory
->
utf8name
);
free
(
directory
);
...
...
@@ -118,8 +115,6 @@ void removeSongFromDirectory(Directory * directory, char * shortname) {
if
(
findInList
(
directory
->
songs
,
shortname
,
&
song
))
{
LOG
(
"removing: %s
\n
"
,((
Song
*
)
song
)
->
utf8file
);
removeASongFromTables
((
Song
*
)
song
);
deleteASongFromPlaylist
((
Song
*
)
song
);
deleteFromList
(
directory
->
songs
,
shortname
);
}
}
...
...
@@ -153,7 +148,9 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
}
else
if
(
mtime
!=
((
Song
*
)
song
)
->
mtime
)
{
LOG
(
"updating %s
\n
"
,
name
);
updateSongInfo
((
Song
*
)
song
);
if
(
updateSongInfo
((
Song
*
)
song
)
<
0
)
{
removeSongFromDirectory
(
directory
,
shortname
);
}
}
}
else
if
(
isDir
(
name
,
&
mtime
))
{
...
...
@@ -331,7 +328,6 @@ int addToDirectory(Directory * directory, char * shortname, char * name) {
song
=
addSongToList
(
directory
->
songs
,
shortname
,
name
);
if
(
!
song
)
return
-
1
;
LOG
(
"added %s
\n
"
,
name
);
addSongToTables
(
song
);
return
0
;
}
...
...
src/main.c
View file @
68dc3517
...
...
@@ -329,6 +329,7 @@ int main(int argc, char * argv[]) {
}
initTables
();
initPlaylist
();
if
(
!
options
.
dbFile
)
{
strncpy
(
directorydb
,
playlistDir
,
MAXPATHLEN
);
...
...
@@ -353,7 +354,6 @@ int main(int argc, char * argv[]) {
initPlayerData
();
initVolume
();
initInterfaces
();
initPlaylist
();
close
(
STDIN_FILENO
);
if
(
options
.
daemon
)
{
...
...
src/song.c
View file @
68dc3517
...
...
@@ -28,6 +28,8 @@
#include "ogg_decode.h"
#include "flac_decode.h"
#include "path.h"
#include "playlist.h"
#include "tables.h"
#define SONG_KEY "key: "
#define SONG_FILE "file: "
...
...
@@ -41,10 +43,19 @@
#include <stdlib.h>
#include <string.h>
Song
*
new
Song
(
char
*
utf8file
)
{
Song
*
new
NullSong
(
)
{
Song
*
song
=
malloc
(
sizeof
(
Song
));
song
->
tag
=
NULL
;
song
->
utf8file
=
NULL
;
song
->
time
=
-
1
;
return
song
;
}
Song
*
newSong
(
char
*
utf8file
)
{
Song
*
song
=
newNullSong
();
song
->
utf8file
=
strdup
(
utf8file
);
if
(
0
);
...
...
@@ -81,11 +92,14 @@ Song * newSong(char * utf8file) {
freeSong
(
song
);
song
=
NULL
;
}
else
addSongToTables
(
song
);
return
song
;
}
void
freeSong
(
Song
*
song
)
{
deleteASongFromPlaylist
(
song
);
removeASongFromTables
(
song
);
free
(
song
->
utf8file
);
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
free
(
song
);
...
...
@@ -163,9 +177,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
free
(
key
);
}
key
=
strdup
(
&
(
buffer
[
strlen
(
SONG_KEY
)]));
song
=
malloc
(
sizeof
(
Song
));
song
->
tag
=
NULL
;
song
->
utf8file
=
NULL
;
song
=
newNullSong
();
}
else
if
(
0
==
strncmp
(
SONG_FILE
,
buffer
,
strlen
(
SONG_FILE
)))
{
if
(
!
song
||
song
->
utf8file
)
{
...
...
@@ -210,32 +222,48 @@ void readSongInfoIntoList(FILE * fp, SongList * list) {
}
int
updateSongInfo
(
Song
*
song
)
{
char
*
utf8file
=
song
->
utf8file
;
removeASongFromTables
(
song
);
if
(
song
->
tag
)
freeMpdTag
(
song
->
tag
);
#ifdef HAVE_MAD
if
(
isMp3
(
song
->
utf8file
,
&
(
song
->
mtime
)))
{
song
->
tag
=
mp3TagDup
(
song
->
utf8file
);
return
0
;
}
#endif
song
->
time
=
-
1
;
song
->
tag
=
NULL
;
if
(
0
);
#ifdef HAVE_OGG
if
(
isOgg
(
song
->
utf8file
,
&
(
song
->
mtime
)))
{
song
->
tag
=
oggTagDup
(
song
->
utf8file
);
return
0
;
else
if
(
isOgg
(
utf8file
,
&
(
song
->
mtime
)))
{
song
->
time
=
getOggTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
oggTagDup
(
utf8file
);
}
#endif
#ifdef HAVE_FLAC
if
(
isFlac
(
song
->
utf8file
,
&
(
song
->
mtime
)))
{
song
->
tag
=
flacTagDup
(
song
->
utf8file
);
return
0
;
else
if
((
isFlac
(
utf8file
,
&
(
song
->
mtime
))))
{
song
->
time
=
getFlacTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
flacTagDup
(
utf8file
);
}
#endif
#ifdef HAVE_MAD
else
if
(
isMp3
(
utf8file
,
&
(
song
->
mtime
)))
{
song
->
time
=
getMp3TotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
mp3TagDup
(
utf8file
);
}
#endif
#ifdef HAVE_AUDIOFILE
if
(
isWave
(
song
->
utf8file
,
&
(
song
->
mtime
)))
{
song
->
tag
=
audiofileTagDup
(
song
->
utf8file
);
return
0
;
else
if
(
isWave
(
utf8file
,
&
(
song
->
mtime
)))
{
song
->
time
=
getAudiofileTotalTime
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)));
if
(
song
->
time
>=
0
)
song
->
tag
=
audiofileTagDup
(
utf8file
);
}
#endif
return
-
1
;
if
(
song
->
time
<
0
)
return
-
1
;
else
addSongToTables
(
song
);
return
0
;
}
Song
*
songDup
(
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