[player] Migrate a lot of speaker handling to outputs.c

Moves speaker selection, volume handling and startup to outputs.c, plus adds
the ability to "resurrect" a speaker that disconnects.

The purpose of moving the code is to concentrate device handling in one place.

Also changes how we deal with speaker selection. The player will now generally
not alter a user selection, even if the device fails. The purpose of this is to
maintain selection both if the device briefly fails, and if the user switches
off the device (we stop playback) and later turns it on + starts new playback.
This commit is contained in:
ejurgensen
2020-05-01 20:11:45 +02:00
parent d0738aabae
commit 661289990c
10 changed files with 476 additions and 573 deletions

View File

@@ -1143,7 +1143,7 @@ alsa_device_start(struct output_device *device, int callback_id)
as->state = OUTPUT_STATE_CONNECTED;
alsa_status(as);
return 0;
return 1;
}
static int
@@ -1155,7 +1155,7 @@ alsa_device_stop(struct output_device *device, int callback_id)
as->state = OUTPUT_STATE_STOPPED;
alsa_status(as); // Will terminate the session since the state is STOPPED
return 0;
return 1;
}
static int
@@ -1169,7 +1169,7 @@ alsa_device_flush(struct output_device *device, int callback_id)
as->state = OUTPUT_STATE_CONNECTED;
alsa_status(as);
return 0;
return 1;
}
static int
@@ -1184,7 +1184,7 @@ alsa_device_probe(struct output_device *device, int callback_id)
as->state = OUTPUT_STATE_STOPPED;
alsa_status(as); // Will terminate the session since the state is STOPPED
return 0;
return 1;
}
static int

View File

@@ -1932,7 +1932,7 @@ cast_device_start_generic(struct output_device *device, int callback_id, cast_re
cast_session_cleanup(cs);
}
else
return 0;
return 1;
}
cs = cast_session_make(device, AF_INET, callback_id);
@@ -1950,7 +1950,7 @@ cast_device_start_generic(struct output_device *device, int callback_id, cast_re
return -1;
}
return 0;
return 1;
}
static int
@@ -1974,7 +1974,7 @@ cast_device_stop(struct output_device *device, int callback_id)
cast_session_shutdown(cs, CAST_STATE_NONE);
return 0;
return 1;
}
static int
@@ -1986,7 +1986,7 @@ cast_device_flush(struct output_device *device, int callback_id)
cs->state = CAST_STATE_MEDIA_CONNECTED;
cast_status(cs);
return 0;
return 1;
}
static void

View File

@@ -115,7 +115,7 @@ dummy_device_start(struct output_device *device, int callback_id)
dummy_status(ds);
return 0;
return 1;
}
static int
@@ -128,7 +128,7 @@ dummy_device_stop(struct output_device *device, int callback_id)
dummy_status(ds);
return 0;
return 1;
}
static int
@@ -141,7 +141,7 @@ dummy_device_flush(struct output_device *device, int callback_id)
dummy_status(ds);
return 0;
return 1;
}
static int
@@ -158,7 +158,7 @@ dummy_device_probe(struct output_device *device, int callback_id)
dummy_status(ds);
return 0;
return 1;
}
static int

View File

@@ -302,7 +302,7 @@ fifo_device_start(struct output_device *device, int callback_id)
fifo_status(fifo_session);
return 0;
return 1;
}
static int
@@ -320,7 +320,7 @@ fifo_device_stop(struct output_device *device, int callback_id)
fifo_session->state = OUTPUT_STATE_STOPPED;
fifo_status(fifo_session);
return 0;
return 1;
}
static int
@@ -335,7 +335,7 @@ fifo_device_flush(struct output_device *device, int callback_id)
fifo_session->state = OUTPUT_STATE_CONNECTED;
fifo_status(fifo_session);
return 0;
return 1;
}
static int
@@ -362,7 +362,7 @@ fifo_device_probe(struct output_device *device, int callback_id)
fifo_status(fifo_session);
return 0;
return 1;
}
static int

View File

@@ -754,7 +754,7 @@ pulse_device_start(struct output_device *device, int callback_id)
pulse_status(ps);
return 0;
return 1;
}
static int
@@ -768,7 +768,7 @@ pulse_device_stop(struct output_device *device, int callback_id)
stream_close(ps, close_cb);
return 0;
return 1;
}
static int
@@ -801,7 +801,7 @@ pulse_device_flush(struct output_device *device, int callback_id)
pa_threaded_mainloop_unlock(pulse.mainloop);
return 0;
return 1;
}
static int
@@ -823,7 +823,7 @@ pulse_device_probe(struct output_device *device, int callback_id)
return -1;
}
return 0;
return 1;
}
static void

View File

@@ -3759,7 +3759,7 @@ raop_cb_startup_setup(struct evrtsp_request *req, void *arg)
token = strtok_r(token, ";=", &ptr);
while (token)
{
DPRINTF(E_DBG, L_RAOP, "token: %s\n", token);
DPRINTF(E_SPAM, L_RAOP, "token: %s\n", token);
if (strcmp(token, "server_port") == 0)
{
@@ -4693,7 +4693,7 @@ raop_device_start_generic(struct output_device *device, int callback_id, bool on
ret = raop_send_req_options(rs, raop_cb_startup_options, "device_start");
if (ret == 0)
return 0;
return 1;
else
{
DPRINTF(E_WARN, L_RAOP, "Could not send verification or OPTIONS request on IPv6\n");
@@ -4719,7 +4719,7 @@ raop_device_start_generic(struct output_device *device, int callback_id, bool on
return -1;
}
return 0;
return 1;
}
static int
@@ -4741,7 +4741,9 @@ raop_device_stop(struct output_device *device, int callback_id)
rs->callback_id = callback_id;
return session_teardown(rs, "device_stop");
session_teardown(rs, "device_stop");
return 1;
}
static int
@@ -4759,7 +4761,7 @@ raop_device_flush(struct output_device *device, int callback_id)
rs->callback_id = callback_id;
return 0;
return 1;
}
static void