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
4484d7a5
Commit
4484d7a5
authored
Oct 02, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/jack: implement Interrupt()
parent
b80a135c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
NEWS
NEWS
+1
-1
JackOutputPlugin.cxx
src/output/plugins/JackOutputPlugin.cxx
+36
-0
No files found.
NEWS
View file @
4484d7a5
ver 0.22.1 (not yet released)
* output
- alsa: don't deadlock when the ALSA driver is buggy
- pulse: reduce the delay when stopping or pausing playback
-
jack,
pulse: reduce the delay when stopping or pausing playback
ver 0.22 (2020/09/23)
* protocol
...
...
src/output/plugins/JackOutputPlugin.cxx
View file @
4484d7a5
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "JackOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "../Error.hxx"
#include "output/Features.h"
#include "thread/Mutex.hxx"
#include "util/ScopeExit.hxx"
...
...
@@ -80,6 +81,15 @@ class JackOutput final : public AudioOutput {
std
::
atomic_bool
pause
;
/**
* Was Interrupt() called? This will unblock Play(). It will
* be reset by Cancel() and Pause(), as documented by the
* #AudioOutput interface.
*
* Only initialized while the output is open.
*/
bool
interrupted
;
/**
* Protects #error.
*/
mutable
Mutex
mutex
;
...
...
@@ -156,6 +166,8 @@ public:
Stop
();
}
void
Interrupt
()
noexcept
override
;
std
::
chrono
::
steady_clock
::
duration
Delay
()
const
noexcept
override
{
return
pause
&&
!
LockWasShutdown
()
?
std
::
chrono
::
seconds
(
1
)
...
...
@@ -164,6 +176,7 @@ public:
size_t
Play
(
const
void
*
chunk
,
size_t
size
)
override
;
void
Cancel
()
noexcept
override
;
bool
Pause
()
override
;
private
:
...
...
@@ -613,9 +626,21 @@ JackOutput::Open(AudioFormat &new_audio_format)
new_audio_format
.
format
=
SampleFormat
::
FLOAT
;
audio_format
=
new_audio_format
;
interrupted
=
false
;
Start
();
}
void
JackOutput
::
Interrupt
()
noexcept
{
const
std
::
unique_lock
<
Mutex
>
lock
(
mutex
);
/* the "interrupted" flag will prevent Play() from waiting,
and will instead throw AudioOutputInterrupted */
interrupted
=
true
;
}
inline
size_t
JackOutput
::
WriteSamples
(
const
float
*
src
,
size_t
n_frames
)
{
...
...
@@ -671,6 +696,9 @@ JackOutput::Play(const void *chunk, size_t size)
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
if
(
error
)
std
::
rethrow_exception
(
error
);
if
(
interrupted
)
throw
AudioOutputInterrupted
{};
}
size_t
frames_written
=
...
...
@@ -684,11 +712,19 @@ JackOutput::Play(const void *chunk, size_t size)
}
}
void
JackOutput
::
Cancel
()
noexcept
{
const
std
::
unique_lock
<
Mutex
>
lock
(
mutex
);
interrupted
=
false
;
}
inline
bool
JackOutput
::
Pause
()
{
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
interrupted
=
false
;
if
(
error
)
std
::
rethrow_exception
(
error
);
}
...
...
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