mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-08 21:24:57 -05:00
[outputs] Add a 10 sec stop timer + drop playback_stop()
In the output implementations playback_stop() was somewhat redundant, since device_stop() does the same. The timer should make sure that we always close outputs (previously they were in some cases kept open). The commit also includes some renaming.
This commit is contained in:
@@ -967,22 +967,6 @@ alsa_device_cb_set(struct output_device *device, int callback_id)
|
||||
as->callback_id = callback_id;
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_playback_stop(void)
|
||||
{
|
||||
struct alsa_session *as;
|
||||
struct alsa_session *next;
|
||||
|
||||
for (as = sessions; as; as = next)
|
||||
{
|
||||
next = as->next;
|
||||
snd_pcm_drop(as->hdl);
|
||||
|
||||
as->state = OUTPUT_STATE_STOPPED;
|
||||
alsa_status(as); // Will stop the session
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
alsa_write(struct output_buffer *obuf)
|
||||
{
|
||||
@@ -1061,6 +1045,5 @@ struct output_definition output_alsa =
|
||||
.device_probe = alsa_device_probe,
|
||||
.device_volume_set = alsa_device_volume_set,
|
||||
.device_cb_set = alsa_device_cb_set,
|
||||
.playback_stop = alsa_playback_stop,
|
||||
.write = alsa_write,
|
||||
};
|
||||
|
||||
@@ -2062,20 +2062,6 @@ cast_device_volume_set(struct output_device *device, int callback_id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
cast_playback_stop(void)
|
||||
{
|
||||
struct cast_session *cs;
|
||||
struct cast_session *next;
|
||||
|
||||
for (cs = cast_sessions; cs; cs = next)
|
||||
{
|
||||
next = cs->next;
|
||||
if (cs->state & CAST_STATE_F_MEDIA_CONNECTED)
|
||||
cast_session_shutdown(cs, CAST_STATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cast_write(struct output_buffer *obuf)
|
||||
{
|
||||
@@ -2220,7 +2206,6 @@ struct output_definition output_cast =
|
||||
.device_flush = cast_device_flush,
|
||||
.device_cb_set = cast_device_cb_set,
|
||||
.device_volume_set = cast_device_volume_set,
|
||||
.playback_stop = cast_playback_stop,
|
||||
.write = cast_write,
|
||||
.init = cast_init,
|
||||
.deinit = cast_deinit,
|
||||
|
||||
@@ -183,18 +183,6 @@ dummy_device_cb_set(struct output_device *device, int callback_id)
|
||||
ds->callback_id = callback_id;
|
||||
}
|
||||
|
||||
static void
|
||||
dummy_playback_stop(void)
|
||||
{
|
||||
struct dummy_session *ds = sessions;
|
||||
|
||||
if (!sessions)
|
||||
return;
|
||||
|
||||
ds->state = OUTPUT_STATE_CONNECTED;
|
||||
dummy_status(ds);
|
||||
}
|
||||
|
||||
static int
|
||||
dummy_init(void)
|
||||
{
|
||||
@@ -245,5 +233,4 @@ struct output_definition output_dummy =
|
||||
.device_probe = dummy_device_probe,
|
||||
.device_volume_set = dummy_device_volume_set,
|
||||
.device_cb_set = dummy_device_cb_set,
|
||||
.playback_stop = dummy_playback_stop,
|
||||
};
|
||||
|
||||
@@ -387,20 +387,6 @@ fifo_device_cb_set(struct output_device *device, int callback_id)
|
||||
fifo_session->callback_id = callback_id;
|
||||
}
|
||||
|
||||
static void
|
||||
fifo_playback_stop(void)
|
||||
{
|
||||
struct fifo_session *fifo_session = sessions;
|
||||
|
||||
if (!fifo_session)
|
||||
return;
|
||||
|
||||
free_buffer();
|
||||
|
||||
fifo_session->state = OUTPUT_STATE_CONNECTED;
|
||||
fifo_status(fifo_session);
|
||||
}
|
||||
|
||||
static void
|
||||
fifo_write(struct output_buffer *obuf)
|
||||
{
|
||||
@@ -532,6 +518,5 @@ struct output_definition output_fifo =
|
||||
.device_probe = fifo_device_probe,
|
||||
.device_volume_set = fifo_device_volume_set,
|
||||
.device_cb_set = fifo_device_cb_set,
|
||||
.playback_stop = fifo_playback_stop,
|
||||
.write = fifo_write,
|
||||
};
|
||||
|
||||
@@ -771,7 +771,6 @@ pulse_device_stop(struct output_device *device, int callback_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pulse_device_flush(struct output_device *device, int callback_id)
|
||||
{
|
||||
@@ -907,36 +906,6 @@ pulse_write(struct output_buffer *obuf)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_playback_stop(void)
|
||||
{
|
||||
struct pulse_session *ps;
|
||||
pa_operation* o;
|
||||
|
||||
pa_threaded_mainloop_lock(pulse.mainloop);
|
||||
|
||||
for (ps = sessions; ps; ps = ps->next)
|
||||
{
|
||||
o = pa_stream_cork(ps->stream, 1, NULL, NULL);
|
||||
if (!o)
|
||||
{
|
||||
DPRINTF(E_LOG, L_LAUDIO, "Pulseaudio could not pause '%s': %s\n", ps->devname, pa_strerror(pa_context_errno(pulse.context)));
|
||||
continue;
|
||||
}
|
||||
pa_operation_unref(o);
|
||||
|
||||
o = pa_stream_flush(ps->stream, NULL, NULL);
|
||||
if (!o)
|
||||
{
|
||||
DPRINTF(E_LOG, L_LAUDIO, "Pulseaudio could not flush '%s': %s\n", ps->devname, pa_strerror(pa_context_errno(pulse.context)));
|
||||
continue;
|
||||
}
|
||||
pa_operation_unref(o);
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_unlock(pulse.mainloop);
|
||||
}
|
||||
|
||||
static int
|
||||
pulse_init(void)
|
||||
{
|
||||
@@ -1032,7 +1001,6 @@ struct output_definition output_pulse =
|
||||
.device_free_extra = pulse_device_free_extra,
|
||||
.device_cb_set = pulse_device_cb_set,
|
||||
.device_volume_set = pulse_device_volume_set,
|
||||
.playback_stop = pulse_playback_stop,
|
||||
.write = pulse_write,
|
||||
};
|
||||
|
||||
|
||||
@@ -2816,6 +2816,12 @@ raop_keep_alive_timer_cb(int fd, short what, void *arg)
|
||||
{
|
||||
struct raop_session *rs;
|
||||
|
||||
if (!raop_sessions)
|
||||
{
|
||||
event_del(keep_alive_timer);
|
||||
return;
|
||||
}
|
||||
|
||||
for (rs = raop_sessions; rs; rs = rs->next)
|
||||
{
|
||||
if (!(rs->state & RAOP_STATE_F_CONNECTED))
|
||||
@@ -4850,17 +4856,6 @@ raop_device_free_extra(struct output_device *device)
|
||||
free(re);
|
||||
}
|
||||
|
||||
static void
|
||||
raop_playback_stop(void)
|
||||
{
|
||||
struct raop_session *rs;
|
||||
|
||||
evtimer_del(keep_alive_timer);
|
||||
|
||||
for (rs = raop_sessions; rs; rs = rs->next)
|
||||
session_teardown(rs, "playback_stop");
|
||||
}
|
||||
|
||||
static void
|
||||
raop_write(struct output_buffer *obuf)
|
||||
{
|
||||
@@ -5069,7 +5064,6 @@ struct output_definition output_raop =
|
||||
.device_free_extra = raop_device_free_extra,
|
||||
.device_volume_set = raop_set_volume_one,
|
||||
.device_volume_to_pct = raop_volume_to_pct,
|
||||
.playback_stop = raop_playback_stop,
|
||||
.write = raop_write,
|
||||
.metadata_prepare = raop_metadata_prepare,
|
||||
.metadata_send = raop_metadata_send,
|
||||
|
||||
Reference in New Issue
Block a user