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
ef663810
Commit
ef663810
authored
Sep 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderControl: convert functions to methods
parent
ada67a6a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
40 deletions
+52
-40
DecoderControl.cxx
src/DecoderControl.cxx
+5
-40
DecoderControl.hxx
src/DecoderControl.hxx
+47
-0
No files found.
src/DecoderControl.cxx
View file @
ef663810
...
@@ -48,41 +48,6 @@ decoder_control::~decoder_control()
...
@@ -48,41 +48,6 @@ decoder_control::~decoder_control()
g_free
(
mixramp_prev_end
);
g_free
(
mixramp_prev_end
);
}
}
static
void
dc_command_wait_locked
(
struct
decoder_control
*
dc
)
{
while
(
dc
->
command
!=
DECODE_COMMAND_NONE
)
dc
->
WaitForDecoder
();
}
static
void
dc_command_locked
(
struct
decoder_control
*
dc
,
enum
decoder_command
cmd
)
{
dc
->
command
=
cmd
;
dc
->
Signal
();
dc_command_wait_locked
(
dc
);
}
static
void
dc_command
(
struct
decoder_control
*
dc
,
enum
decoder_command
cmd
)
{
dc
->
Lock
();
dc
->
ClearError
();
dc_command_locked
(
dc
,
cmd
);
dc
->
Unlock
();
}
static
void
dc_command_async
(
struct
decoder_control
*
dc
,
enum
decoder_command
cmd
)
{
dc
->
Lock
();
dc
->
command
=
cmd
;
dc
->
Signal
();
dc
->
Unlock
();
}
bool
bool
decoder_control
::
IsCurrentSong
(
const
Song
*
_song
)
const
decoder_control
::
IsCurrentSong
(
const
Song
*
_song
)
const
{
{
...
@@ -119,7 +84,7 @@ decoder_control::Start(Song *_song,
...
@@ -119,7 +84,7 @@ decoder_control::Start(Song *_song,
buffer
=
&
_buffer
;
buffer
=
&
_buffer
;
pipe
=
&
_pipe
;
pipe
=
&
_pipe
;
dc_command
(
this
,
DECODE_COMMAND_START
);
LockSynchronousCommand
(
DECODE_COMMAND_START
);
}
}
void
void
...
@@ -132,10 +97,10 @@ decoder_control::Stop()
...
@@ -132,10 +97,10 @@ decoder_control::Stop()
late and the decoder thread is already executing
late and the decoder thread is already executing
the old command, we'll call STOP again in this
the old command, we'll call STOP again in this
function (see below). */
function (see below). */
dc_command_locked
(
this
,
DECODE_COMMAND_STOP
);
SynchronousCommandLocked
(
DECODE_COMMAND_STOP
);
if
(
state
!=
DECODE_STATE_STOP
&&
state
!=
DECODE_STATE_ERROR
)
if
(
state
!=
DECODE_STATE_STOP
&&
state
!=
DECODE_STATE_ERROR
)
dc_command_locked
(
this
,
DECODE_COMMAND_STOP
);
SynchronousCommandLocked
(
DECODE_COMMAND_STOP
);
Unlock
();
Unlock
();
}
}
...
@@ -152,7 +117,7 @@ decoder_control::Seek(double where)
...
@@ -152,7 +117,7 @@ decoder_control::Seek(double where)
seek_where
=
where
;
seek_where
=
where
;
seek_error
=
false
;
seek_error
=
false
;
dc_command
(
this
,
DECODE_COMMAND_SEEK
);
SynchronousCommandLocked
(
DECODE_COMMAND_SEEK
);
return
!
seek_error
;
return
!
seek_error
;
}
}
...
@@ -163,7 +128,7 @@ decoder_control::Quit()
...
@@ -163,7 +128,7 @@ decoder_control::Quit()
assert
(
thread
!=
nullptr
);
assert
(
thread
!=
nullptr
);
quit
=
true
;
quit
=
true
;
dc_command_async
(
this
,
DECODE_COMMAND_STOP
);
LockAsynchronousCommand
(
DECODE_COMMAND_STOP
);
g_thread_join
(
thread
);
g_thread_join
(
thread
);
thread
=
nullptr
;
thread
=
nullptr
;
...
...
src/DecoderControl.hxx
View file @
ef663810
...
@@ -278,6 +278,53 @@ struct decoder_control {
...
@@ -278,6 +278,53 @@ struct decoder_control {
return
result
;
return
result
;
}
}
private
:
/**
* Wait for the command to be finished by the decoder thread.
*
* To be called from the client thread. Caller must lock the
* object.
*/
void
WaitCommandLocked
()
{
while
(
command
!=
DECODE_COMMAND_NONE
)
WaitForDecoder
();
}
/**
* Send a command to the decoder thread and synchronously wait
* for it to finish.
*
* To be called from the client thread. Caller must lock the
* object.
*/
void
SynchronousCommandLocked
(
decoder_command
cmd
)
{
command
=
cmd
;
Signal
();
WaitCommandLocked
();
}
/**
* Send a command to the decoder thread and synchronously wait
* for it to finish.
*
* To be called from the client thread. This method locks the
* object.
*/
void
LockSynchronousCommand
(
decoder_command
cmd
)
{
Lock
();
ClearError
();
SynchronousCommandLocked
(
cmd
);
Unlock
();
}
void
LockAsynchronousCommand
(
decoder_command
cmd
)
{
Lock
();
command
=
cmd
;
Signal
();
Unlock
();
}
public
:
/**
/**
* Start the decoder.
* Start the decoder.
*
*
...
...
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