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
25b01940
Commit
25b01940
authored
Mar 10, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/wasapi: implement Drain()
parent
77fe727e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
WasapiOutputPlugin.cxx
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
+34
-2
No files found.
src/output/plugins/wasapi/WasapiOutputPlugin.cxx
View file @
25b01940
...
...
@@ -181,6 +181,8 @@ class WasapiOutputThread {
std
::
atomic_bool
cancel
=
false
;
std
::
atomic_bool
empty
=
true
;
enum
class
Status
:
uint32_t
{
FINISH
,
PLAY
,
PAUSE
};
alignas
(
BOOST_LOCKFREE_CACHELINE_BYTES
)
std
::
atomic
<
Status
>
status
=
...
...
@@ -224,6 +226,8 @@ public:
}
std
::
size_t
Push
(
ConstBuffer
<
void
>
input
)
noexcept
{
empty
.
store
(
false
);
std
::
size_t
consumed
=
spsc_buffer
.
push
(
static_cast
<
const
BYTE
*>
(
input
.
data
),
input
.
size
);
...
...
@@ -237,6 +241,24 @@ public:
}
/**
* Check if the buffer is empty, and if not, wait a bit.
*
* Throws on error.
*
* @return true if the buffer is now empty
*/
bool
Drain
()
{
if
(
empty
)
return
true
;
CheckException
();
Wait
();
CheckException
();
return
empty
;
}
/**
* Instruct the thread to discard the buffer (and wait for
* completion). This needs to be done inside this thread,
* because only the consumer thread is allowed to do that.
...
...
@@ -417,6 +439,7 @@ try {
if
(
cancel
.
load
())
{
spsc_buffer
.
consume_all
([](
auto
&&
)
{});
cancel
.
store
(
false
);
empty
.
store
(
true
);
InterruptWaiter
();
}
...
...
@@ -475,6 +498,9 @@ try {
const
UINT32
write_size
=
write_in_frames
*
frame_size
;
UINT32
new_data_size
=
0
;
new_data_size
=
spsc_buffer
.
pop
(
data
,
write_size
);
if
(
new_data_size
==
0
)
empty
.
store
(
true
);
std
::
fill_n
(
data
+
new_data_size
,
write_size
-
new_data_size
,
0
);
InterruptWaiter
();
...
...
@@ -741,9 +767,15 @@ WasapiOutput::Drain()
{
assert
(
thread
);
// TODO implement
not_interrupted
.
test_and_set
();
thread
->
CheckException
();
while
(
!
thread
->
Drain
())
{
if
(
!
not_interrupted
.
test_and_set
())
throw
AudioOutputInterrupted
{};
}
/* TODO: this needs to wait until the hardware has really
finished playing */
}
void
...
...
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