mixer: don't reopen failed mixer automatically
If a (global) mixer has been closed due to failure, don't reopen it with every volume get/set. Leave it closed until it is explicitly opened.
This commit is contained in:
parent
1fcf09a816
commit
69759b573f
@ -28,4 +28,5 @@ mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
|
|||||||
mixer->plugin = plugin;
|
mixer->plugin = plugin;
|
||||||
mixer->mutex = g_mutex_new();
|
mixer->mutex = g_mutex_new();
|
||||||
mixer->open = false;
|
mixer->open = false;
|
||||||
|
mixer->failed = false;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,12 @@ struct mixer {
|
|||||||
* Is the mixer device currently open?
|
* Is the mixer device currently open?
|
||||||
*/
|
*/
|
||||||
bool open;
|
bool open;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has this mixer failed, and should not be reopened
|
||||||
|
* automatically?
|
||||||
|
*/
|
||||||
|
bool failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -82,6 +82,8 @@ mixer_open(struct mixer *mixer)
|
|||||||
else
|
else
|
||||||
success = mixer->open = mixer->plugin->open(mixer);
|
success = mixer->open = mixer->plugin->open(mixer);
|
||||||
|
|
||||||
|
mixer->failed = !success;
|
||||||
|
|
||||||
g_mutex_unlock(mixer->mutex);
|
g_mutex_unlock(mixer->mutex);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@ -120,6 +122,8 @@ mixer_failed(struct mixer *mixer)
|
|||||||
assert(mixer->open);
|
assert(mixer->open);
|
||||||
|
|
||||||
mixer_close(mixer);
|
mixer_close(mixer);
|
||||||
|
|
||||||
|
mixer->failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -129,7 +133,7 @@ mixer_get_volume(struct mixer *mixer)
|
|||||||
|
|
||||||
assert(mixer != NULL);
|
assert(mixer != NULL);
|
||||||
|
|
||||||
if (mixer->plugin->global && !mixer_open(mixer))
|
if (mixer->plugin->global && !mixer->failed && !mixer_open(mixer))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
@ -153,7 +157,7 @@ mixer_set_volume(struct mixer *mixer, unsigned volume)
|
|||||||
|
|
||||||
assert(mixer != NULL);
|
assert(mixer != NULL);
|
||||||
|
|
||||||
if (mixer->plugin->global && !mixer_open(mixer))
|
if (mixer->plugin->global && !mixer->failed && !mixer_open(mixer))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
|
Loading…
Reference in New Issue
Block a user