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
e55de6e9
Commit
e55de6e9
authored
3 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pipewire: implement Drain()
parent
cfaf2ed0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
PipeWireOutputPlugin.cxx
src/output/plugins/PipeWireOutputPlugin.cxx
+29
-3
No files found.
src/output/plugins/PipeWireOutputPlugin.cxx
View file @
e55de6e9
...
...
@@ -58,6 +58,7 @@ class PipeWireOutput final : AudioOutput {
bool
disconnected
;
bool
interrupted
;
bool
drained
;
explicit
PipeWireOutput
(
const
ConfigBlock
&
block
);
...
...
@@ -74,6 +75,7 @@ public:
events
.
version
=
PW_VERSION_STREAM_EVENTS
;
events
.
state_changed
=
StateChanged
;
events
.
process
=
Process
;
events
.
drained
=
Drained
;
return
events
;
}
...
...
@@ -107,6 +109,16 @@ private:
o
.
Process
();
}
void
Drained
()
noexcept
{
drained
=
true
;
pw_thread_loop_signal
(
thread_loop
,
false
);
}
static
void
Drained
(
void
*
data
)
noexcept
{
auto
&
o
=
*
(
PipeWireOutput
*
)
data
;
o
.
Drained
();
}
/* virtual methods from class AudioOutput */
void
Enable
()
override
;
void
Disable
()
noexcept
override
;
...
...
@@ -125,8 +137,8 @@ private:
size_t
Play
(
const
void
*
chunk
,
size_t
size
)
override
;
// TODO:
void Drain() override;
void
Cancel
()
noexcept
override
;
void
Drain
()
override
;
void
Cancel
()
noexcept
override
;
// TODO: bool Pause() noexcept override;
};
...
...
@@ -211,6 +223,7 @@ void
PipeWireOutput
::
Open
(
AudioFormat
&
audio_format
)
{
disconnected
=
false
;
drained
=
true
;
auto
props
=
pw_properties_new
(
PW_KEY_MEDIA_TYPE
,
"Audio"
,
PW_KEY_MEDIA_CATEGORY
,
"Playback"
,
...
...
@@ -307,8 +320,10 @@ PipeWireOutput::Play(const void *chunk, size_t size)
std
::
size_t
bytes_written
=
ring_buffer
->
push
((
const
std
::
byte
*
)
chunk
,
size
);
if
(
bytes_written
>
0
)
if
(
bytes_written
>
0
)
{
drained
=
false
;
return
bytes_written
;
}
if
(
interrupted
)
throw
AudioOutputInterrupted
{};
...
...
@@ -318,6 +333,17 @@ PipeWireOutput::Play(const void *chunk, size_t size)
}
void
PipeWireOutput
::
Drain
()
{
const
PipeWire
::
ThreadLoopLock
lock
(
thread_loop
);
while
(
!
drained
&&
!
interrupted
)
{
CheckThrowError
();
pw_thread_loop_wait
(
thread_loop
);
}
}
void
PipeWireOutput
::
Cancel
()
noexcept
{
const
PipeWire
::
ThreadLoopLock
lock
(
thread_loop
);
...
...
This diff is collapsed.
Click to expand it.
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