mixer_control: don't allow mixer==NULL
As a side effect, the previous patch added the mixer==NULL checks. It is now illegal to call mixer functions with a NULL argument. Convert the runtime checks to assertions.
This commit is contained in:
parent
66a2c5669e
commit
7475ded935
@ -58,9 +58,7 @@ mixer_new(const struct mixer_plugin *plugin, const struct config_param *param)
|
|||||||
void
|
void
|
||||||
mixer_free(struct mixer *mixer)
|
mixer_free(struct mixer *mixer)
|
||||||
{
|
{
|
||||||
if (!mixer) {
|
assert(mixer != NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != NULL);
|
||||||
assert(mixer->mutex != NULL);
|
assert(mixer->mutex != NULL);
|
||||||
|
|
||||||
@ -74,9 +72,7 @@ mixer_open(struct mixer *mixer)
|
|||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
if (!mixer) {
|
assert(mixer != NULL);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != NULL);
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
@ -89,9 +85,7 @@ mixer_open(struct mixer *mixer)
|
|||||||
void
|
void
|
||||||
mixer_close(struct mixer *mixer)
|
mixer_close(struct mixer *mixer)
|
||||||
{
|
{
|
||||||
if (!mixer) {
|
assert(mixer != NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != NULL);
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
@ -104,6 +98,8 @@ mixer_get_volume(struct mixer *mixer)
|
|||||||
{
|
{
|
||||||
int volume;
|
int volume;
|
||||||
|
|
||||||
|
assert(mixer != NULL);
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
volume = mixer->plugin->get_volume(mixer);
|
volume = mixer->plugin->get_volume(mixer);
|
||||||
g_mutex_unlock(mixer->mutex);
|
g_mutex_unlock(mixer->mutex);
|
||||||
@ -116,6 +112,8 @@ mixer_set_volume(struct mixer *mixer, unsigned volume)
|
|||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
|
assert(mixer != NULL);
|
||||||
|
|
||||||
g_mutex_lock(mixer->mutex);
|
g_mutex_lock(mixer->mutex);
|
||||||
success = mixer->plugin->set_volume(mixer, volume);
|
success = mixer->plugin->set_volume(mixer, volume);
|
||||||
g_mutex_unlock(mixer->mutex);
|
g_mutex_unlock(mixer->mutex);
|
||||||
|
Loading…
Reference in New Issue
Block a user