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
710ec569
Commit
710ec569
authored
Jun 03, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better method for computing total time played
git-svn-id:
https://svn.musicpd.org/mpd/trunk@1317
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
c453f7dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
14 deletions
+6
-14
decode.c
src/decode.c
+5
-8
player.c
src/player.c
+1
-5
player.h
src/player.h
+0
-1
No files found.
src/decode.c
View file @
710ec569
...
...
@@ -127,6 +127,9 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
pc->sampleRate = dc->audioFormat.sampleRate; \
pc->bits = dc->audioFormat.bits; \
pc->channels = dc->audioFormat.channels; \
sizeToTime = 8.0/cb->audioFormat.bits/ \
cb->audioFormat.channels/ \
cb->audioFormat.sampleRate; \
} \
else if(dc->state!=DECODE_STATE_START || *decode_pid <= 0) { \
strncpy(pc->erroredUrl, pc->utf8url, MAXPATHLEN); \
...
...
@@ -198,7 +201,6 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
while
(
*
decode_pid
>
0
&&
dc
->
seek
)
my_usleep
(
10000
);
if
(
!
dc
->
seekError
)
{
pc
->
elapsedTime
=
dc
->
seekWhere
;
pc
->
beginTime
=
pc
->
elapsedTime
;
ret
=
0
;
}
}
...
...
@@ -240,7 +242,6 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
if(pause) closeAudioDevice(); \
} \
if(pc->seek) { \
pc->totalPlayTime+= pc->elapsedTime-pc->beginTime; \
if(decodeSeek(pc,dc,cb,&decodeWaitedOn) == 0) { \
doCrossFade = 0; \
nextChunk = -1; \
...
...
@@ -248,7 +249,6 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
} \
} \
if(pc->stop) { \
pc->totalPlayTime+= pc->elapsedTime-pc->beginTime; \
quitDecode(pc,dc); \
return; \
}
...
...
@@ -410,6 +410,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
int
test
;
int
decodeWaitedOn
=
0
;
char
silence
[
CHUNK_SIZE
];
double
sizeToTime
=
0
.
0
;
memset
(
silence
,
0
,
CHUNK_SIZE
);
...
...
@@ -417,7 +418,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
pc
->
state
=
PLAYER_STATE_PLAY
;
pc
->
play
=
0
;
pc
->
beginTime
=
pc
->
elapsedTime
;
kill
(
getppid
(),
SIGUSR1
);
while
(
*
decode_pid
>
0
&&
!
cb
->
wrap
&&
cb
->
end
-
cb
->
begin
<
bbp
&&
...
...
@@ -517,6 +517,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
{
quit
=
1
;
}
pc
->
totalPlayTime
+=
sizeToTime
*
cb
->
chunkSize
[
cb
->
begin
];
cb
->
begin
++
;
if
(
cb
->
begin
>=
buffered_chunks
)
{
cb
->
begin
=
0
;
...
...
@@ -524,8 +525,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
}
}
else
if
(
cb
->
next
==
cb
->
begin
)
{
pc
->
totalPlayTime
+=
pc
->
elapsedTime
-
pc
->
beginTime
;
if
(
doCrossFade
==
1
&&
nextChunk
>=
0
)
{
nextChunk
=
cb
->
begin
+
crossFadeChunks
;
test
=
cb
->
end
;
...
...
@@ -563,7 +562,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
pc
->
queueState
=
PLAYER_QUEUE_EMPTY
;
kill
(
getppid
(),
SIGUSR1
);
}
pc
->
beginTime
=
cb
->
times
[
cb
->
begin
];
}
else
if
(
*
decode_pid
<=
0
||
(
dc
->
state
==
DECODE_STATE_STOP
&&
!
dc
->
start
))
...
...
@@ -576,7 +574,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
}
}
pc
->
totalPlayTime
+=
pc
->
elapsedTime
-
pc
->
beginTime
;
\
quitDecode
(
pc
,
dc
);
}
...
...
src/player.c
View file @
710ec569
...
...
@@ -442,11 +442,7 @@ int getPlayerSoftwareVolume() {
double
getPlayerTotalPlayTime
()
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
if
(
pc
->
state
==
PLAYER_STATE_STOP
)
{
return
pc
->
totalPlayTime
;
}
return
pc
->
totalPlayTime
+
pc
->
elapsedTime
-
pc
->
beginTime
;
return
pc
->
totalPlayTime
;
}
unsigned
int
getPlayerSampleRate
()
{
...
...
src/player.h
View file @
710ec569
...
...
@@ -66,7 +66,6 @@ typedef struct _PlayerControl {
volatile
mpd_sint8
bits
;
volatile
mpd_sint8
channels
;
volatile
mpd_uint32
sampleRate
;
volatile
float
beginTime
;
volatile
float
totalTime
;
volatile
float
elapsedTime
;
volatile
float
fileTime
;
...
...
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