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
7f29bb1a
Commit
7f29bb1a
authored
Apr 15, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log cycling and a few cleanups
git-svn-id:
https://svn.musicpd.org/mpd/trunk@772
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
df3af7d4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
80 additions
and
34 deletions
+80
-34
TODO
TODO
+6
-11
decode.c
src/decode.c
+8
-0
decode.h
src/decode.h
+7
-6
main.c
src/main.c
+3
-15
myfprintf.c
src/myfprintf.c
+34
-1
myfprintf.h
src/myfprintf.h
+4
-1
ogg_decode.c
src/ogg_decode.c
+1
-0
player.c
src/player.c
+13
-0
player.h
src/player.h
+1
-0
sig_handlers.c
src/sig_handlers.c
+3
-0
No files found.
TODO
View file @
7f29bb1a
...
...
@@ -6,9 +6,6 @@
e) abitility to disable resampling and audio format conversion
2) non-blocking (for other clients) update
j) when reading new directory db, we should block some signals when
manipulating the directorydb, so we don't receive a signal to
quit in the middle of an update
k) when bg-update, have parent print out new old stuff to log on
reading db, not the child
n) mpd command for rereading db
...
...
@@ -17,14 +14,12 @@
and should be reread by parent process
p) set error: in status when an error occurs during update
3) have children close all logging stuff, and redirect stdout and stderr to
/dev/null, and set error bits in the shared log for the parent process
to check when it receives a SIGUSR1, and print logs and then reset values of
error bits. (don't redirect children's stdout and stderr to /dev/null if mpd is
run with --no-daemon)
3) cleanup main()
4) cleanup main()
5) crosslink "list" stuff, for example, artists are crosslinked to alubms and
4) crosslink "list" stuff, for example, artists are crosslinked to alubms and
vice versa, this way you can do list album artists or list artist albums, this
will make life easier when we add genre and other metadata
5) when writing combined interface for all decodes to use, be sure to add a
common function and abstrct dealing with DecoderControl * and put
cycleLogFiles in there, so we cycleLogFiles while decoding, not just when decoding has stopped.
src/decode.c
View file @
7f29bb1a
...
...
@@ -174,6 +174,10 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
}
#define processDecodeInput() \
if(pc->cycleLogFiles) { \
myfprintfCloseAndOpenLogFile(); \
pc->cycleLogFiles = 0; \
} \
if(pc->lockQueue) { \
pc->queueLockState = PLAYER_QUEUE_LOCKED; \
pc->lockQueue = 0; \
...
...
@@ -277,6 +281,10 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
dc
->
stop
=
0
;
}
else
if
(
dc
->
seek
)
dc
->
start
=
1
;
if
(
dc
->
cycleLogFiles
)
{
myfprintfCloseAndOpenLogFile
();
dc
->
cycleLogFiles
=
0
;
}
else
my_usleep
(
10000
);
}
...
...
src/decode.h
View file @
7f29bb1a
...
...
@@ -41,12 +41,13 @@
#define DECODE_ERROR_FILE 2
typedef
struct
_DecoderControl
{
mpd_sint8
state
;
mpd_sint8
stop
;
mpd_sint8
start
;
mpd_uint16
error
;
mpd_sint8
seek
;
mpd_sint8
seekError
;
volatile
mpd_sint8
state
;
volatile
mpd_sint8
stop
;
volatile
mpd_sint8
start
;
volatile
mpd_uint16
error
;
volatile
mpd_sint8
seek
;
volatile
mpd_sint8
seekError
;
volatile
mpd_sint8
cycleLogFiles
;
double
seekWhere
;
char
file
[
MAXPATHLEN
+
1
];
}
DecoderControl
;
...
...
src/main.c
View file @
7f29bb1a
...
...
@@ -356,31 +356,19 @@ int main(int argc, char * argv[]) {
exit
(
EXIT_FAILURE
);
}
if
(
close
(
STDOUT_FILENO
))
{
fprintf
(
err
,
"problems closing stdout : %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
if
(
close
(
STDERR_FILENO
))
{
fprintf
(
err
,
"problems closing stderr : %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
if
(
dup2
(
fileno
(
out
),
STDOUT_FILENO
)
<
0
)
{
fprintf
(
err
,
"problems dup2 stdout : %s
\n
"
,
my
fprintf
(
err
,
"problems dup2 stdout : %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
if
(
dup2
(
fileno
(
err
),
STDERR_FILENO
)
<
0
)
{
fprintf
(
err
,
"problems dup2 stderr : %s
\n
"
,
my
fprintf
(
err
,
"problems dup2 stderr : %s
\n
"
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
}
myfprintfStdLogMode
(
out
,
err
);
myfprintfStdLogMode
(
out
,
err
,
options
.
logFile
,
options
.
errorFile
);
fflush
(
NULL
);
pid
=
fork
();
...
...
src/myfprintf.c
View file @
7f29bb1a
...
...
@@ -18,6 +18,8 @@
#include "myfprintf.h"
#include "interface.h"
#include "path.h"
#include "log.h"
#include <stdarg.h>
#include <sys/param.h>
...
...
@@ -32,6 +34,8 @@
int
myfprintf_stdLogMode
=
0
;
FILE
*
myfprintf_out
;
FILE
*
myfprintf_err
;
char
*
myfprintf_outFilename
;
char
*
myfprintf_errFilename
;
void
blockingWrite
(
int
fd
,
char
*
string
)
{
int
len
=
strlen
(
string
);
...
...
@@ -48,10 +52,14 @@ void blockingWrite(int fd, char * string) {
}
}
void
myfprintfStdLogMode
(
FILE
*
out
,
FILE
*
err
)
{
void
myfprintfStdLogMode
(
FILE
*
out
,
FILE
*
err
,
char
*
outFilename
,
char
*
errFilename
)
{
myfprintf_stdLogMode
=
1
;
myfprintf_out
=
out
;
myfprintf_err
=
err
;
myfprintf_outFilename
=
prependCwdToPathDup
(
outFilename
);
myfprintf_errFilename
=
prependCwdToPathDup
(
errFilename
);
}
void
myfprintf
(
FILE
*
fp
,
char
*
format
,
...
)
{
...
...
@@ -85,4 +93,29 @@ void myfprintf(FILE * fp, char * format, ... ) {
va_end
(
arglist
);
}
int
myfprintfCloseAndOpenLogFile
()
{
if
(
myfprintf_stdLogMode
)
{
while
(
fclose
(
myfprintf_out
)
<
0
&&
errno
==
EINTR
);
while
(
fclose
(
myfprintf_err
)
<
0
&&
errno
==
EINTR
);
while
((
myfprintf_out
=
fopen
(
myfprintf_outFilename
,
"a+"
))
==
NULL
&&
errno
==
EINTR
);
if
(
!
myfprintf_out
)
{
ERROR
(
"error re-opening log file: %s
\n
"
,
myfprintf_out
);
return
-
1
;
}
while
((
myfprintf_err
=
fopen
(
myfprintf_errFilename
,
"a+"
))
==
NULL
&&
errno
==
EINTR
);
if
(
!
myfprintf_out
)
{
ERROR
(
"error re-opening log file: %s
\n
"
,
myfprintf_out
);
return
-
1
;
}
while
(
dup2
(
fileno
(
myfprintf_out
),
1
)
<
0
&&
errno
==
EINTR
);
while
(
dup2
(
fileno
(
myfprintf_err
),
2
)
<
0
&&
errno
==
EINTR
);
}
return
0
;
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/myfprintf.h
View file @
7f29bb1a
...
...
@@ -23,9 +23,12 @@
#include <stdio.h>
void
myfprintfStdLogMode
(
FILE
*
out
,
FILE
*
err
);
void
myfprintfStdLogMode
(
FILE
*
out
,
FILE
*
err
,
char
*
outFilename
,
char
*
errFilename
);
void
myfprintf
(
FILE
*
fp
,
char
*
format
,
...
);
int
myfprintfCloseAndOpenLogFile
();
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/ogg_decode.c
View file @
7f29bb1a
...
...
@@ -116,6 +116,7 @@ int ogg_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
}
if
(
dc
->
stop
)
break
;
else
if
(
dc
->
seek
)
continue
;
memcpy
(
cb
->
chunks
+
cb
->
end
*
CHUNK_SIZE
,
chunk
,
chunkpos
);
cb
->
chunkSize
[
cb
->
end
]
=
chunkpos
;
...
...
src/player.c
View file @
7f29bb1a
...
...
@@ -139,6 +139,10 @@ int playerInit() {
pc
->
queueLockState
=
PLAYER_QUEUE_UNLOCKED
;
pc
->
unlockQueue
=
0
;
}
else
if
(
pc
->
cycleLogFiles
)
{
myfprintfCloseAndOpenLogFile
();
pc
->
cycleLogFiles
=
0
;
}
else
my_usleep
(
10000
);
}
...
...
@@ -474,4 +478,13 @@ int getPlayerChannels() {
return
pc
->
channels
;
}
void
playerCycleLogFiles
()
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
DecoderControl
*
dc
=
&
(
getPlayerData
()
->
decoderControl
);
pc
->
cycleLogFiles
=
1
;
dc
->
cycleLogFiles
=
1
;
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
src/player.h
View file @
7f29bb1a
...
...
@@ -77,6 +77,7 @@ typedef struct _PlayerControl {
volatile
mpd_uint16
softwareVolume
;
volatile
double
totalPlayTime
;
volatile
int
decode_pid
;
volatile
mpd_sint8
cycleLogFiles
;
}
PlayerControl
;
void
clearPlayerPid
();
...
...
src/sig_handlers.c
View file @
7f29bb1a
...
...
@@ -23,6 +23,7 @@
#include "command.h"
#include "signal_check.h"
#include "log.h"
#include "player.h"
#include <signal.h>
#include <sys/types.h>
...
...
@@ -44,6 +45,8 @@ int handlePendingSignals() {
readDirectoryDB
();
incrPlaylistVersion
();
}
if
(
myfprintfCloseAndOpenLogFile
()
<
0
)
return
COMMAND_RETURN_KILL
;
playerCycleLogFiles
();
}
return
0
;
...
...
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