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
b0e47fce
Commit
b0e47fce
authored
Apr 12, 2008
by
Max Kellermann
Committed by
Eric Wong
Apr 12, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass pc to player notify functions
Same as the previous patch: less global variables. git-svn-id:
https://svn.musicpd.org/mpd/trunk@7317
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
7642d10f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
30 deletions
+29
-30
decode.c
src/decode.c
+15
-13
player.c
src/player.c
+12
-15
player.h
src/player.h
+2
-2
No files found.
src/decode.c
View file @
b0e47fce
...
@@ -33,13 +33,15 @@
...
@@ -33,13 +33,15 @@
/* called inside decoder_task (inputPlugins) */
/* called inside decoder_task (inputPlugins) */
void
decoder_wakeup_player
(
void
)
void
decoder_wakeup_player
(
void
)
{
{
wakeup_player_nb
();
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
wakeup_player_nb
(
pc
);
}
}
void
decoder_sleep
(
DecoderControl
*
dc
)
void
decoder_sleep
(
DecoderControl
*
dc
)
{
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
notifyWait
(
&
dc
->
notify
);
notifyWait
(
&
dc
->
notify
);
wakeup_player_nb
();
wakeup_player_nb
(
pc
);
}
}
static
void
player_wakeup_decoder_nb
(
DecoderControl
*
dc
)
static
void
player_wakeup_decoder_nb
(
DecoderControl
*
dc
)
...
@@ -48,10 +50,10 @@ static void player_wakeup_decoder_nb(DecoderControl * dc)
...
@@ -48,10 +50,10 @@ static void player_wakeup_decoder_nb(DecoderControl * dc)
}
}
/* called from player_task */
/* called from player_task */
static
void
player_wakeup_decoder
(
DecoderControl
*
dc
)
static
void
player_wakeup_decoder
(
PlayerControl
*
pc
,
DecoderControl
*
dc
)
{
{
notifySignal
(
&
dc
->
notify
);
notifySignal
(
&
dc
->
notify
);
player_sleep
();
player_sleep
(
pc
);
}
}
static
void
stopDecode
(
DecoderControl
*
dc
)
static
void
stopDecode
(
DecoderControl
*
dc
)
...
@@ -102,7 +104,7 @@ static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
...
@@ -102,7 +104,7 @@ static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
OutputBuffer
*
cb
,
int
*
decodeWaitedOn
)
OutputBuffer
*
cb
,
int
*
decodeWaitedOn
)
{
{
while
(
dc
->
start
)
while
(
dc
->
start
)
player_wakeup_decoder
(
dc
);
player_wakeup_decoder
(
pc
,
dc
);
if
(
dc
->
error
!=
DECODE_ERROR_NOERROR
)
{
if
(
dc
->
error
!=
DECODE_ERROR_NOERROR
)
{
pc
->
errored_song
=
pc
->
current_song
;
pc
->
errored_song
=
pc
->
current_song
;
...
@@ -143,7 +145,7 @@ static int decodeSeek(PlayerControl * pc, DecoderControl * dc,
...
@@ -143,7 +145,7 @@ static int decodeSeek(PlayerControl * pc, DecoderControl * dc,
dc
->
seekWhere
=
0
>
dc
->
seekWhere
?
0
:
dc
->
seekWhere
;
dc
->
seekWhere
=
0
>
dc
->
seekWhere
?
0
:
dc
->
seekWhere
;
dc
->
seekError
=
0
;
dc
->
seekError
=
0
;
dc
->
seek
=
1
;
dc
->
seek
=
1
;
do
{
player_wakeup_decoder
(
dc
);
}
while
(
dc
->
seek
);
do
{
player_wakeup_decoder
(
pc
,
dc
);
}
while
(
dc
->
seek
);
if
(
!
dc
->
seekError
)
{
if
(
!
dc
->
seekError
)
{
pc
->
elapsedTime
=
dc
->
seekWhere
;
pc
->
elapsedTime
=
dc
->
seekWhere
;
ret
=
0
;
ret
=
0
;
...
@@ -431,7 +433,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -431,7 +433,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
if
(
buffering
)
{
if
(
buffering
)
{
if
(
availableOutputBuffer
(
cb
)
<
bbp
)
{
if
(
availableOutputBuffer
(
cb
)
<
bbp
)
{
/* not enough decoded buffer space yet */
/* not enough decoded buffer space yet */
player_sleep
();
player_sleep
(
pc
);
continue
;
continue
;
}
else
}
else
/* buffering is complete */
/* buffering is complete */
...
@@ -452,7 +454,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -452,7 +454,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
get_song_url
(
tmp
,
pc
->
current_song
));
get_song_url
(
tmp
,
pc
->
current_song
));
break
;
break
;
}
else
{
}
else
{
player_wakeup_decoder
(
dc
);
player_wakeup_decoder
(
pc
,
dc
);
}
}
if
(
do_pause
)
{
if
(
do_pause
)
{
dropBufferedAudio
();
dropBufferedAudio
();
...
@@ -473,7 +475,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -473,7 +475,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
else
{
else
{
/* the decoder is not yet ready; wait
/* the decoder is not yet ready; wait
some more */
some more */
player_sleep
();
player_sleep
(
pc
);
continue
;
continue
;
}
}
}
}
...
@@ -509,7 +511,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -509,7 +511,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
}
if
(
do_pause
)
if
(
do_pause
)
player_sleep
();
player_sleep
(
pc
);
else
if
(
!
outputBufferEmpty
(
cb
)
&&
(
int
)
cb
->
begin
!=
next
)
{
else
if
(
!
outputBufferEmpty
(
cb
)
&&
(
int
)
cb
->
begin
!=
next
)
{
OutputBufferChunk
*
beginChunk
=
OutputBufferChunk
*
beginChunk
=
outputBufferGetChunk
(
cb
,
cb
->
begin
);
outputBufferGetChunk
(
cb
,
cb
->
begin
);
...
@@ -544,7 +546,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -544,7 +546,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
else
{
}
else
{
/* wait for the
/* wait for the
decoder */
decoder */
player_sleep
();
player_sleep
(
pc
);
continue
;
continue
;
}
}
}
}
...
@@ -571,7 +573,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
...
@@ -571,7 +573,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
/* wait for the decoder to work on the new song */
/* wait for the decoder to work on the new song */
if
(
pc
->
queueState
==
PLAYER_QUEUE_DECODE
||
if
(
pc
->
queueState
==
PLAYER_QUEUE_DECODE
||
pc
->
queueLockState
==
PLAYER_QUEUE_LOCKED
)
{
pc
->
queueLockState
==
PLAYER_QUEUE_LOCKED
)
{
player_sleep
();
player_sleep
(
pc
);
continue
;
continue
;
}
}
if
(
pc
->
queueState
!=
PLAYER_QUEUE_PLAY
)
if
(
pc
->
queueState
!=
PLAYER_QUEUE_PLAY
)
...
@@ -615,7 +617,7 @@ void decode(void)
...
@@ -615,7 +617,7 @@ void decode(void)
dc
->
seek
=
0
;
dc
->
seek
=
0
;
dc
->
stop
=
0
;
dc
->
stop
=
0
;
dc
->
start
=
1
;
dc
->
start
=
1
;
do
{
player_wakeup_decoder
(
dc
);
}
while
(
dc
->
start
);
do
{
player_wakeup_decoder
(
pc
,
dc
);
}
while
(
dc
->
start
);
decodeParent
(
pc
,
dc
,
cb
);
decodeParent
(
pc
,
dc
,
cb
);
}
}
src/player.c
View file @
b0e47fce
...
@@ -35,22 +35,19 @@
...
@@ -35,22 +35,19 @@
static
void
playerCloseAudio
(
void
);
static
void
playerCloseAudio
(
void
);
void
wakeup_player_nb
(
void
)
void
wakeup_player_nb
(
PlayerControl
*
pc
)
{
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
notifySignal
(
&
pc
->
notify
);
notifySignal
(
&
pc
->
notify
);
}
}
static
void
wakeup_player
(
void
)
static
void
wakeup_player
(
PlayerControl
*
pc
)
{
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
notifySignal
(
&
pc
->
notify
);
notifySignal
(
&
pc
->
notify
);
wait_main_task
();
wait_main_task
();
}
}
void
player_sleep
(
void
)
void
player_sleep
(
PlayerControl
*
pc
)
{
{
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
notifyWait
(
&
pc
->
notify
);
notifyWait
(
&
pc
->
notify
);
}
}
...
@@ -80,7 +77,7 @@ static void * player_task(mpd_unused void *unused)
...
@@ -80,7 +77,7 @@ static void * player_task(mpd_unused void *unused)
pc
->
queueLockState
=
PLAYER_QUEUE_UNLOCKED
;
pc
->
queueLockState
=
PLAYER_QUEUE_UNLOCKED
;
pc
->
unlockQueue
=
0
;
pc
->
unlockQueue
=
0
;
}
else
{
}
else
{
player_sleep
();
player_sleep
(
pc
);
continue
;
continue
;
}
}
/* we did something, tell the main task about it */
/* we did something, tell the main task about it */
...
@@ -129,7 +126,7 @@ int playerPlay(int fd, Song * song)
...
@@ -129,7 +126,7 @@ int playerPlay(int fd, Song * song)
pc
->
play
=
1
;
pc
->
play
=
1
;
/* FIXME: _nb() variant is probably wrong here, and everywhere... */
/* FIXME: _nb() variant is probably wrong here, and everywhere... */
do
{
wakeup_player_nb
();
}
while
(
pc
->
play
);
do
{
wakeup_player_nb
(
pc
);
}
while
(
pc
->
play
);
return
0
;
return
0
;
}
}
...
@@ -140,7 +137,7 @@ int playerStop(int fd)
...
@@ -140,7 +137,7 @@ int playerStop(int fd)
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
pc
->
stop
=
1
;
pc
->
stop
=
1
;
do
{
wakeup_player
();
}
while
(
pc
->
stop
);
do
{
wakeup_player
(
pc
);
}
while
(
pc
->
stop
);
}
}
pc
->
queueState
=
PLAYER_QUEUE_BLANK
;
pc
->
queueState
=
PLAYER_QUEUE_BLANK
;
...
@@ -160,7 +157,7 @@ int playerPause(int fd)
...
@@ -160,7 +157,7 @@ int playerPause(int fd)
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
pc
->
pause
=
1
;
pc
->
pause
=
1
;
do
{
wakeup_player
();
}
while
(
pc
->
pause
);
do
{
wakeup_player
(
pc
);
}
while
(
pc
->
pause
);
}
}
return
0
;
return
0
;
...
@@ -253,7 +250,7 @@ static void playerCloseAudio(void)
...
@@ -253,7 +250,7 @@ static void playerCloseAudio(void)
if
(
playerStop
(
STDERR_FILENO
)
<
0
)
if
(
playerStop
(
STDERR_FILENO
)
<
0
)
return
;
return
;
pc
->
closeAudio
=
1
;
pc
->
closeAudio
=
1
;
do
{
wakeup_player
();
}
while
(
pc
->
closeAudio
);
do
{
wakeup_player
(
pc
);
}
while
(
pc
->
closeAudio
);
}
}
int
queueSong
(
Song
*
song
)
int
queueSong
(
Song
*
song
)
...
@@ -281,7 +278,7 @@ void setQueueState(int queueState)
...
@@ -281,7 +278,7 @@ void setQueueState(int queueState)
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
PlayerControl
*
pc
=
&
(
getPlayerData
()
->
playerControl
);
pc
->
queueState
=
queueState
;
pc
->
queueState
=
queueState
;
wakeup_player_nb
();
wakeup_player_nb
(
pc
);
}
}
void
playerQueueLock
(
void
)
void
playerQueueLock
(
void
)
...
@@ -290,7 +287,7 @@ void playerQueueLock(void)
...
@@ -290,7 +287,7 @@ void playerQueueLock(void)
if
(
pc
->
queueLockState
==
PLAYER_QUEUE_UNLOCKED
)
{
if
(
pc
->
queueLockState
==
PLAYER_QUEUE_UNLOCKED
)
{
pc
->
lockQueue
=
1
;
pc
->
lockQueue
=
1
;
do
{
wakeup_player
();
}
while
(
pc
->
lockQueue
);
do
{
wakeup_player
(
pc
);
}
while
(
pc
->
lockQueue
);
}
}
}
}
...
@@ -300,7 +297,7 @@ void playerQueueUnlock(void)
...
@@ -300,7 +297,7 @@ void playerQueueUnlock(void)
if
(
pc
->
queueLockState
==
PLAYER_QUEUE_LOCKED
)
{
if
(
pc
->
queueLockState
==
PLAYER_QUEUE_LOCKED
)
{
pc
->
unlockQueue
=
1
;
pc
->
unlockQueue
=
1
;
do
{
wakeup_player
();
}
while
(
pc
->
unlockQueue
);
do
{
wakeup_player
(
pc
);
}
while
(
pc
->
unlockQueue
);
}
}
}
}
...
@@ -323,7 +320,7 @@ int playerSeek(int fd, Song * song, float seek_time)
...
@@ -323,7 +320,7 @@ int playerSeek(int fd, Song * song, float seek_time)
pc
->
seekWhere
=
seek_time
;
pc
->
seekWhere
=
seek_time
;
pc
->
seek
=
1
;
pc
->
seek
=
1
;
/* FIXME: _nb() is probably wrong here, too */
/* FIXME: _nb() is probably wrong here, too */
do
{
wakeup_player_nb
();
}
while
(
pc
->
seek
);
do
{
wakeup_player_nb
(
pc
);
}
while
(
pc
->
seek
);
}
}
return
0
;
return
0
;
...
...
src/player.h
View file @
b0e47fce
...
@@ -82,9 +82,9 @@ void wakeup_main_task(void);
...
@@ -82,9 +82,9 @@ void wakeup_main_task(void);
void
wait_main_task
(
void
);
void
wait_main_task
(
void
);
void
wakeup_player_nb
(
void
);
void
wakeup_player_nb
(
PlayerControl
*
pc
);
void
player_sleep
(
void
);
void
player_sleep
(
PlayerControl
*
pc
);
int
playerPlay
(
int
fd
,
Song
*
song
);
int
playerPlay
(
int
fd
,
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