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
d146bef7
Commit
d146bef7
authored
Aug 04, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/jack: use jack_on_info_shutdown()
parent
1f4c4be1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
NEWS
NEWS
+1
-0
JackOutputPlugin.cxx
src/output/plugins/JackOutputPlugin.cxx
+29
-9
No files found.
NEWS
View file @
d146bef7
...
...
@@ -14,6 +14,7 @@ ver 0.22 (not yet released)
- volume: convert S16 to S24 to preserve quality and reduce dithering noise
* output
- jack: add option "auto_destination_ports"
- jack: report error details
- pulse: add option "media_role"
* switch to C++17
- GCC 7 or clang 4 (or newer) recommended
...
...
src/output/plugins/JackOutputPlugin.cxx
View file @
d146bef7
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "JackOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "thread/Mutex.hxx"
#include "util/ScopeExit.hxx"
#include "util/ConstBuffer.hxx"
#include "util/IterableSplitString.hxx"
...
...
@@ -80,6 +81,16 @@ struct JackOutput final : AudioOutput {
*/
std
::
atomic_bool
pause
;
/**
* Protects #error.
*/
Mutex
mutex
;
/**
* The error reported to the "on_info_shutdown" callback.
*/
std
::
exception_ptr
error
;
explicit
JackOutput
(
const
ConfigBlock
&
block
);
/**
...
...
@@ -95,8 +106,10 @@ struct JackOutput final : AudioOutput {
*/
void
Disconnect
()
noexcept
;
void
Shutdown
()
noexcept
{
void
Shutdown
(
std
::
exception_ptr
e
)
noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
shutdown
=
true
;
error
=
std
::
move
(
e
);
}
/**
...
...
@@ -344,11 +357,12 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
}
static
void
mpd_jack_shutdown
(
void
*
arg
)
mpd_jack_shutdown
(
jack_status_t
,
const
char
*
reason
,
void
*
arg
)
{
JackOutput
&
jo
=
*
(
JackOutput
*
)
arg
;
jo
.
Shutdown
();
jo
.
Shutdown
(
std
::
make_exception_ptr
(
FormatRuntimeError
(
"JACK connection shutdown: %s"
,
reason
)));
}
static
void
...
...
@@ -395,6 +409,7 @@ void
JackOutput
::
Connect
()
{
shutdown
=
false
;
error
=
{};
jack_status_t
status
;
client
=
jack_client_open
(
name
,
options
,
&
status
,
server_name
);
...
...
@@ -403,7 +418,7 @@ JackOutput::Connect()
status
);
jack_set_process_callback
(
client
,
mpd_jack_process
,
this
);
jack_on_shutdown
(
client
,
mpd_jack_shutdown
,
this
);
jack_on_
info_
shutdown
(
client
,
mpd_jack_shutdown
,
this
);
for
(
unsigned
i
=
0
;
i
<
num_source_ports
;
++
i
)
{
ports
[
i
]
=
jack_port_register
(
client
,
...
...
@@ -654,9 +669,11 @@ JackOutput::Play(const void *chunk, size_t size)
size
/=
frame_size
;
while
(
true
)
{
if
(
shutdown
)
throw
std
::
runtime_error
(
"Refusing to play, because "
"there is no client thread"
);
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
if
(
error
)
std
::
rethrow_exception
(
error
);
}
size_t
frames_written
=
WriteSamples
((
const
float
*
)
chunk
,
size
);
...
...
@@ -672,8 +689,11 @@ JackOutput::Play(const void *chunk, size_t size)
inline
bool
JackOutput
::
Pause
()
{
if
(
shutdown
)
return
false
;
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
if
(
error
)
std
::
rethrow_exception
(
error
);
}
pause
=
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