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
77fe727e
Commit
77fe727e
authored
Mar 10, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/wasapi: move the "is_started" flag to class WasapiOutputThread
parent
73f9824d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
19 deletions
+33
-19
WasapiOutputPlugin.cxx
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+33
-19
No files found.
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
View file @
77fe727e
...
...
@@ -167,6 +167,16 @@ class WasapiOutputThread {
const
UINT32
buffer_size_in_frames
;
const
bool
is_exclusive
;
/**
* This flag is only used by the calling thread
* (i.e. #OutputThread), and specifies whether the
* WasapiOutputThread has been told to play via Play(). This
* variable is somewhat redundant because we already have
* "state", but using this variable saves some overhead for
* atomic operations.
*/
bool
playing
=
false
;
bool
started
=
false
;
std
::
atomic_bool
cancel
=
false
;
...
...
@@ -200,12 +210,30 @@ public:
thread
.
Join
();
}
void
Play
()
noexcept
{
return
SetStatus
(
Status
::
PLAY
);
}
void
Pause
()
noexcept
{
return
SetStatus
(
Status
::
PAUSE
);
}
void
Play
()
noexcept
{
playing
=
true
;
SetStatus
(
Status
::
PLAY
);
}
void
Pause
()
noexcept
{
if
(
!
playing
)
return
;
playing
=
false
;
SetStatus
(
Status
::
PAUSE
);
}
std
::
size_t
Push
(
ConstBuffer
<
void
>
input
)
noexcept
{
return
spsc_buffer
.
push
(
static_cast
<
const
BYTE
*>
(
input
.
data
),
input
.
size
);
std
::
size_t
consumed
=
spsc_buffer
.
push
(
static_cast
<
const
BYTE
*>
(
input
.
data
),
input
.
size
);
if
(
!
playing
)
{
playing
=
true
;
Play
();
}
return
consumed
;
}
/**
...
...
@@ -262,11 +290,6 @@ class WasapiOutput final : public AudioOutput {
/**
* Only valid if the output is open.
*/
bool
is_started
;
/**
* Only valid if the output is open.
*/
bool
paused
;
std
::
atomic_flag
not_interrupted
=
true
;
...
...
@@ -625,7 +648,6 @@ WasapiOutput::DoOpen(AudioFormat &audio_format)
thread
.
emplace
(
*
client
,
std
::
move
(
render_client
),
FrameSize
(),
buffer_size_in_frames
,
is_exclusive
);
is_started
=
false
;
paused
=
false
;
}
...
...
@@ -678,11 +700,6 @@ WasapiOutput::Play(const void *chunk, size_t size)
do
{
const
size_t
consumed_size
=
thread
->
Push
({
chunk
,
size
});
if
(
!
is_started
)
{
is_started
=
true
;
thread
->
Play
();
}
if
(
consumed_size
==
0
)
{
thread
->
Wait
();
thread
->
CheckException
();
...
...
@@ -705,10 +722,7 @@ bool
WasapiOutput
::
Pause
()
{
paused
=
true
;
if
(
is_started
)
{
thread
->
Pause
();
is_started
=
false
;
}
thread
->
Pause
();
thread
->
CheckException
();
return
true
;
}
...
...
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