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
c6d1d360
Commit
c6d1d360
authored
Nov 11, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Control: use class ScopeLock
parent
afc1236b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
35 deletions
+18
-35
Control.cxx
src/player/Control.cxx
+11
-21
Control.hxx
src/player/Control.hxx
+7
-14
No files found.
src/player/Control.cxx
View file @
c6d1d360
...
@@ -54,7 +54,7 @@ PlayerControl::Play(DetachedSong *song)
...
@@ -54,7 +54,7 @@ PlayerControl::Play(DetachedSong *song)
{
{
assert
(
song
!=
nullptr
);
assert
(
song
!=
nullptr
);
Lock
(
);
const
ScopeLock
protect
(
mutex
);
if
(
state
!=
PlayerState
::
STOP
)
if
(
state
!=
PlayerState
::
STOP
)
SynchronousCommand
(
PlayerCommand
::
STOP
);
SynchronousCommand
(
PlayerCommand
::
STOP
);
...
@@ -64,8 +64,6 @@ PlayerControl::Play(DetachedSong *song)
...
@@ -64,8 +64,6 @@ PlayerControl::Play(DetachedSong *song)
EnqueueSongLocked
(
song
);
EnqueueSongLocked
(
song
);
assert
(
next_song
==
nullptr
);
assert
(
next_song
==
nullptr
);
Unlock
();
}
}
void
void
...
@@ -113,15 +111,14 @@ PlayerControl::PauseLocked()
...
@@ -113,15 +111,14 @@ PlayerControl::PauseLocked()
void
void
PlayerControl
::
LockPause
()
PlayerControl
::
LockPause
()
{
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
PauseLocked
();
PauseLocked
();
Unlock
();
}
}
void
void
PlayerControl
::
LockSetPause
(
bool
pause_flag
)
PlayerControl
::
LockSetPause
(
bool
pause_flag
)
{
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
switch
(
state
)
{
switch
(
state
)
{
case
PlayerState
:
:
STOP
:
case
PlayerState
:
:
STOP
:
...
@@ -137,16 +134,13 @@ PlayerControl::LockSetPause(bool pause_flag)
...
@@ -137,16 +134,13 @@ PlayerControl::LockSetPause(bool pause_flag)
PauseLocked
();
PauseLocked
();
break
;
break
;
}
}
Unlock
();
}
}
void
void
PlayerControl
::
LockSetBorderPause
(
bool
_border_pause
)
PlayerControl
::
LockSetBorderPause
(
bool
_border_pause
)
{
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
border_pause
=
_border_pause
;
border_pause
=
_border_pause
;
Unlock
();
}
}
player_status
player_status
...
@@ -154,7 +148,7 @@ PlayerControl::LockGetStatus()
...
@@ -154,7 +148,7 @@ PlayerControl::LockGetStatus()
{
{
player_status
status
;
player_status
status
;
Lock
(
);
const
ScopeLock
protect
(
mutex
);
SynchronousCommand
(
PlayerCommand
::
REFRESH
);
SynchronousCommand
(
PlayerCommand
::
REFRESH
);
status
.
state
=
state
;
status
.
state
=
state
;
...
@@ -166,8 +160,6 @@ PlayerControl::LockGetStatus()
...
@@ -166,8 +160,6 @@ PlayerControl::LockGetStatus()
status
.
elapsed_time
=
elapsed_time
;
status
.
elapsed_time
=
elapsed_time
;
}
}
Unlock
();
return
status
;
return
status
;
}
}
...
@@ -184,18 +176,16 @@ PlayerControl::SetError(PlayerError type, Error &&_error)
...
@@ -184,18 +176,16 @@ PlayerControl::SetError(PlayerError type, Error &&_error)
void
void
PlayerControl
::
LockClearError
()
PlayerControl
::
LockClearError
()
{
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
ClearError
();
ClearError
();
Unlock
();
}
}
void
void
PlayerControl
::
LockSetTaggedSong
(
const
DetachedSong
&
song
)
PlayerControl
::
LockSetTaggedSong
(
const
DetachedSong
&
song
)
{
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
delete
tagged_song
;
delete
tagged_song
;
tagged_song
=
new
DetachedSong
(
song
);
tagged_song
=
new
DetachedSong
(
song
);
Unlock
();
}
}
void
void
...
@@ -210,9 +200,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
...
@@ -210,9 +200,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
{
{
assert
(
song
!=
nullptr
);
assert
(
song
!=
nullptr
);
Lock
(
);
const
ScopeLock
protect
(
mutex
);
EnqueueSongLocked
(
song
);
EnqueueSongLocked
(
song
);
Unlock
();
}
}
void
void
...
@@ -237,9 +226,10 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t)
...
@@ -237,9 +226,10 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t)
{
{
assert
(
song
!=
nullptr
);
assert
(
song
!=
nullptr
);
Lock
();
{
const
ScopeLock
protect
(
mutex
);
SeekLocked
(
song
,
t
);
SeekLocked
(
song
,
t
);
Unlock
();
}
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
...
...
src/player/Control.hxx
View file @
c6d1d360
...
@@ -210,9 +210,8 @@ struct PlayerControl {
...
@@ -210,9 +210,8 @@ struct PlayerControl {
* this function.
* this function.
*/
*/
void
LockSignal
()
{
void
LockSignal
()
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
Signal
();
Signal
();
Unlock
();
}
}
/**
/**
...
@@ -264,9 +263,8 @@ struct PlayerControl {
...
@@ -264,9 +263,8 @@ struct PlayerControl {
}
}
void
LockCommandFinished
()
{
void
LockCommandFinished
()
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
CommandFinished
();
CommandFinished
();
Unlock
();
}
}
private
:
private
:
...
@@ -304,9 +302,8 @@ private:
...
@@ -304,9 +302,8 @@ private:
* object.
* object.
*/
*/
void
LockSynchronousCommand
(
PlayerCommand
cmd
)
{
void
LockSynchronousCommand
(
PlayerCommand
cmd
)
{
Lock
(
);
const
ScopeLock
protect
(
mutex
);
SynchronousCommand
(
cmd
);
SynchronousCommand
(
cmd
);
Unlock
();
}
}
public
:
public
:
...
@@ -377,10 +374,8 @@ public:
...
@@ -377,10 +374,8 @@ public:
*/
*/
gcc_pure
gcc_pure
Error
LockGetError
()
const
{
Error
LockGetError
()
const
{
Lock
();
const
ScopeLock
protect
(
mutex
);
Error
result
=
GetError
();
return
GetError
();
Unlock
();
return
result
;
}
}
void
LockClearError
();
void
LockClearError
();
...
@@ -412,10 +407,8 @@ public:
...
@@ -412,10 +407,8 @@ public:
* Like ReadTaggedSong(), but locks and unlocks the object.
* Like ReadTaggedSong(), but locks and unlocks the object.
*/
*/
DetachedSong
*
LockReadTaggedSong
()
{
DetachedSong
*
LockReadTaggedSong
()
{
Lock
();
const
ScopeLock
protect
(
mutex
);
DetachedSong
*
result
=
ReadTaggedSong
();
return
ReadTaggedSong
();
Unlock
();
return
result
;
}
}
void
LockStop
();
void
LockStop
();
...
...
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