mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 16:25:03 -05:00
[pulseaudio] Kill sessions if context becomes invalid
This commit is contained in:
parent
84a5772439
commit
fa6c6a1832
@ -42,6 +42,11 @@
|
|||||||
|
|
||||||
#define PULSE_MAX_DEVICES 64
|
#define PULSE_MAX_DEVICES 64
|
||||||
|
|
||||||
|
/* TODO for Pulseaudio
|
||||||
|
- Get volume from Pulseaudio on startup and on callbacks
|
||||||
|
- Add sync with AirPlay with pa_buffer_attr
|
||||||
|
*/
|
||||||
|
|
||||||
struct pulse
|
struct pulse
|
||||||
{
|
{
|
||||||
pa_threaded_mainloop *mainloop;
|
pa_threaded_mainloop *mainloop;
|
||||||
@ -488,9 +493,9 @@ stream_open(struct pulse *p, struct pulse_session *ps)
|
|||||||
pa_stream_set_write_callback(ps->stream, stream_request_cb, ps);
|
pa_stream_set_write_callback(ps->stream, stream_request_cb, ps);
|
||||||
pa_stream_set_latency_update_callback(ps->stream, stream_latency_update_cb, ps);
|
pa_stream_set_latency_update_callback(ps->stream, stream_latency_update_cb, ps);
|
||||||
|
|
||||||
|
// TODO should we use PA_STREAM_ADJUST_LATENCY?
|
||||||
flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE;
|
flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE;
|
||||||
|
|
||||||
// TODO sync stream
|
|
||||||
ret = pa_stream_connect_playback(ps->stream, ps->devname, NULL, flags, NULL, NULL);
|
ret = pa_stream_connect_playback(ps->stream, ps->devname, NULL, flags, NULL, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto unlock_and_fail;
|
goto unlock_and_fail;
|
||||||
@ -683,6 +688,7 @@ pulse_write(uint8_t *buf, uint64_t rtptime)
|
|||||||
struct pulse_session *ps;
|
struct pulse_session *ps;
|
||||||
struct pulse_session *next;
|
struct pulse_session *next;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
int invalid_context;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!sessions)
|
if (!sessions)
|
||||||
@ -692,18 +698,13 @@ pulse_write(uint8_t *buf, uint64_t rtptime)
|
|||||||
|
|
||||||
pa_threaded_mainloop_lock(p->mainloop);
|
pa_threaded_mainloop_lock(p->mainloop);
|
||||||
|
|
||||||
if (context_check(p->context) < 0)
|
invalid_context = (context_check(p->context) < 0);
|
||||||
{
|
|
||||||
// TODO Not a good situation... we should kill all sessions
|
|
||||||
pa_threaded_mainloop_unlock(p->mainloop);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ps = sessions; ps; ps = next)
|
for (ps = sessions; ps; ps = next)
|
||||||
{
|
{
|
||||||
next = ps->next;
|
next = ps->next;
|
||||||
|
|
||||||
if (stream_check(p, ps) < 0)
|
if (invalid_context || (stream_check(p, ps) < 0))
|
||||||
{
|
{
|
||||||
pulse_status(ps); // Note: This will nuke the session (deferred)
|
pulse_status(ps); // Note: This will nuke the session (deferred)
|
||||||
continue;
|
continue;
|
||||||
@ -793,7 +794,6 @@ pulse_init(void)
|
|||||||
if (!(p->cmdbase = commands_base_new(evbase_player, NULL)))
|
if (!(p->cmdbase = commands_base_new(evbase_player, NULL)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
// TODO
|
|
||||||
#ifdef HAVE_PULSE_MAINLOOP_SET_NAME
|
#ifdef HAVE_PULSE_MAINLOOP_SET_NAME
|
||||||
pa_threaded_mainloop_set_name(p->mainloop, "pulseaudio");
|
pa_threaded_mainloop_set_name(p->mainloop, "pulseaudio");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user