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.
This commit is contained in:
Max Kellermann 2009-10-23 10:32:25 +02:00
parent ede828c910
commit c4f895daf4
2 changed files with 8 additions and 4 deletions

View File

@ -140,9 +140,13 @@ mixer_get_volume(struct mixer *mixer, GError **error_r)
g_mutex_lock(mixer->mutex);
if (mixer->open) {
volume = mixer->plugin->get_volume(mixer, error_r);
if (volume < 0)
GError *error = NULL;
volume = mixer->plugin->get_volume(mixer, &error);
if (volume < 0 && error != NULL) {
g_propagate_error(error_r, error);
mixer_failed(mixer);
}
} else
volume = -1;

View File

@ -72,8 +72,8 @@ struct mixer_plugin {
*
* @param error_r location to store the error occuring, or
* NULL to ignore errors
* @return the current volume (0..100 including) or -1 on
* error
* @return the current volume (0..100 including) or -1 if
* unavailable or on error (error_r set, mixer will be closed)
*/
int (*get_volume)(struct mixer *mixer, GError **error_r);