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
79effd62
Commit
79effd62
authored
Feb 27, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display db_playtime in stats
git-svn-id:
https://svn.musicpd.org/mpd/trunk@98
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
a78c5e4a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
0 deletions
+23
-0
directory.c
src/directory.c
+19
-0
directory.h
src/directory.h
+2
-0
stats.c
src/stats.c
+1
-0
stats.h
src/stats.h
+1
-0
No files found.
src/directory.c
View file @
79effd62
...
@@ -477,6 +477,7 @@ int writeDirectoryDB() {
...
@@ -477,6 +477,7 @@ int writeDirectoryDB() {
sortDirectory
(
mp3rootDirectory
);
sortDirectory
(
mp3rootDirectory
);
stats
.
numberOfSongs
=
countSongsIn
(
stderr
,
NULL
);
stats
.
numberOfSongs
=
countSongsIn
(
stderr
,
NULL
);
stats
.
dbPlayTime
=
sumSongTimesIn
(
stderr
,
NULL
);
while
(
!
(
fp
=
fopen
(
directorydb
,
"w"
))
&&
errno
==
EINTR
);
while
(
!
(
fp
=
fopen
(
directorydb
,
"w"
))
&&
errno
==
EINTR
);
if
(
!
fp
)
return
-
1
;
if
(
!
fp
)
return
-
1
;
...
@@ -570,6 +571,7 @@ int readDirectoryDB() {
...
@@ -570,6 +571,7 @@ int readDirectoryDB() {
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
stats
.
numberOfSongs
=
countSongsIn
(
stderr
,
NULL
);
stats
.
numberOfSongs
=
countSongsIn
(
stderr
,
NULL
);
stats
.
dbPlayTime
=
sumSongTimesIn
(
stderr
,
NULL
);
return
0
;
return
0
;
}
}
...
@@ -777,6 +779,14 @@ int directoryPrintSongInfo(FILE * fp, Song * song, void * data) {
...
@@ -777,6 +779,14 @@ int directoryPrintSongInfo(FILE * fp, Song * song, void * data) {
return
printSongInfo
(
fp
,
song
);
return
printSongInfo
(
fp
,
song
);
}
}
int
sumSongTime
(
FILE
*
fp
,
Song
*
song
,
void
*
data
)
{
unsigned
long
*
time
=
(
unsigned
long
*
)
data
;
if
(
song
->
tag
&&
song
->
tag
->
time
>=
0
)
*
time
+=
song
->
tag
->
time
;
return
0
;
}
int
printInfoForAllIn
(
FILE
*
fp
,
char
*
name
)
{
int
printInfoForAllIn
(
FILE
*
fp
,
char
*
name
)
{
return
traverseAllIn
(
fp
,
name
,
directoryPrintSongInfo
,
NULL
,
NULL
);
return
traverseAllIn
(
fp
,
name
,
directoryPrintSongInfo
,
NULL
,
NULL
);
}
}
...
@@ -790,6 +800,15 @@ int countSongsIn(FILE * fp, char * name) {
...
@@ -790,6 +800,15 @@ int countSongsIn(FILE * fp, char * name) {
return
count
;
return
count
;
}
}
unsigned
long
sumSongTimesIn
(
FILE
*
fp
,
char
*
name
)
{
unsigned
long
dbPlayTime
=
0
;
void
*
ptr
=
(
void
*
)
&
dbPlayTime
;
traverseAllIn
(
fp
,
name
,
sumSongTime
,
NULL
,
ptr
);
return
dbPlayTime
;
}
void
initMp3Directory
()
{
void
initMp3Directory
()
{
mp3rootDirectory
=
newDirectory
(
NULL
,
NULL
,
0
);
mp3rootDirectory
=
newDirectory
(
NULL
,
NULL
,
0
);
exploreDirectory
(
mp3rootDirectory
);
exploreDirectory
(
mp3rootDirectory
);
...
...
src/directory.h
View file @
79effd62
...
@@ -50,6 +50,8 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string);
...
@@ -50,6 +50,8 @@ int findSongsIn(FILE * fp, char * name, char * item, char * string);
int
countSongsIn
(
FILE
*
fp
,
char
*
name
);
int
countSongsIn
(
FILE
*
fp
,
char
*
name
);
unsigned
long
sumSongTimesIn
(
FILE
*
fp
,
char
*
name
);
Song
*
getSong
(
char
*
file
);
Song
*
getSong
(
char
*
file
);
time_t
getDbModTime
();
time_t
getDbModTime
();
...
...
src/stats.c
View file @
79effd62
...
@@ -41,6 +41,7 @@ int printStats(FILE * fp) {
...
@@ -41,6 +41,7 @@ int printStats(FILE * fp) {
myfprintf
(
fp
,
"songs: %i
\n
"
,
stats
.
numberOfSongs
);
myfprintf
(
fp
,
"songs: %i
\n
"
,
stats
.
numberOfSongs
);
myfprintf
(
fp
,
"uptime: %li
\n
"
,
time
(
NULL
)
-
stats
.
daemonStart
);
myfprintf
(
fp
,
"uptime: %li
\n
"
,
time
(
NULL
)
-
stats
.
daemonStart
);
myfprintf
(
fp
,
"playtime: %li
\n
"
,(
long
)(
getPlayerTotalPlayTime
()
+
0
.
5
));
myfprintf
(
fp
,
"playtime: %li
\n
"
,(
long
)(
getPlayerTotalPlayTime
()
+
0
.
5
));
myfprintf
(
fp
,
"db_playtime: %li
\n
"
,
stats
.
dbPlayTime
);
/*myfprintf(fp,"songs_played: %li\n",stats.songsPlayed);*/
/*myfprintf(fp,"songs_played: %li\n",stats.songsPlayed);*/
myfprintf
(
fp
,
"db_update: %li
\n
"
,
getDbModTime
());
myfprintf
(
fp
,
"db_update: %li
\n
"
,
getDbModTime
());
return
0
;
return
0
;
...
...
src/stats.h
View file @
79effd62
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
typedef
struct
_Stats
{
typedef
struct
_Stats
{
unsigned
long
daemonStart
;
unsigned
long
daemonStart
;
int
numberOfSongs
;
int
numberOfSongs
;
unsigned
long
dbPlayTime
;
/*unsigned long playTime;
/*unsigned long playTime;
unsigned long songsPlayed;*/
unsigned long songsPlayed;*/
}
Stats
;
}
Stats
;
...
...
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