Commit c4f895da authored by Max Kellermann's avatar Max Kellermann

mixer_plugin: get_volume() may return -1 if unavailable

If the method get_volume() returns -1 and no error object is set, then the volume is currently unavailable, but the mixer should not be closed immediately.
parent ede828c9
...@@ -140,9 +140,13 @@ mixer_get_volume(struct mixer *mixer, GError **error_r) ...@@ -140,9 +140,13 @@ mixer_get_volume(struct mixer *mixer, GError **error_r)
g_mutex_lock(mixer->mutex); g_mutex_lock(mixer->mutex);
if (mixer->open) { if (mixer->open) {
volume = mixer->plugin->get_volume(mixer, error_r); GError *error = NULL;
if (volume < 0)
volume = mixer->plugin->get_volume(mixer, &error);
if (volume < 0 && error != NULL) {
g_propagate_error(error_r, error);
mixer_failed(mixer); mixer_failed(mixer);
}
} else } else
volume = -1; volume = -1;
......
...@@ -72,8 +72,8 @@ struct mixer_plugin { ...@@ -72,8 +72,8 @@ struct mixer_plugin {
* *
* @param error_r location to store the error occuring, or * @param error_r location to store the error occuring, or
* NULL to ignore errors * NULL to ignore errors
* @return the current volume (0..100 including) or -1 on * @return the current volume (0..100 including) or -1 if
* error * unavailable or on error (error_r set, mixer will be closed)
*/ */
int (*get_volume)(struct mixer *mixer, GError **error_r); int (*get_volume)(struct mixer *mixer, GError **error_r);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment