mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
drivers/audio/es8311: Fix setting sample rate and bits per sample
When setting the sample rate (`es8311_setsamplerate`) and the bits per sample (`es8311_setbitspersample`), check their return value in `es8311_configure`. Also, this commit ensures that these functions are called after `es8311_reset` to avoid these values to be set to the default values.
This commit is contained in:
parent
24954800a7
commit
c755218295
1 changed files with 21 additions and 9 deletions
|
@ -1033,19 +1033,25 @@ static int es8311_configure(FAR struct audio_lowerhalf_s *dev,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
es8311_audio_output(priv);
|
||||||
|
es8311_reset(priv);
|
||||||
|
|
||||||
/* Save the current stream configuration */
|
/* Save the current stream configuration */
|
||||||
|
|
||||||
priv->samprate = caps->ac_controls.hw[0];
|
priv->samprate = caps->ac_controls.hw[0];
|
||||||
priv->bpsamp = caps->ac_controls.b[2];
|
priv->bpsamp = caps->ac_controls.b[2];
|
||||||
|
|
||||||
es8311_audio_output(priv);
|
ret = es8311_setsamplerate(priv) == -ENOTTY ? OK : ret;
|
||||||
es8311_reset(priv);
|
if (ret < 0)
|
||||||
es8311_setsamplerate(priv);
|
{
|
||||||
es8311_setbitspersample(priv);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = es8311_setbitspersample(priv) == -ENOTTY ? OK : ret;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_TYPE_INPUT:
|
case AUDIO_TYPE_INPUT:
|
||||||
{
|
{
|
||||||
audinfo(" AUDIO_TYPE_INPUT:\n");
|
audinfo(" AUDIO_TYPE_INPUT:\n");
|
||||||
audinfo(" Number of channels: %u\n", caps->ac_channels);
|
audinfo(" Number of channels: %u\n", caps->ac_channels);
|
||||||
|
@ -1074,15 +1080,21 @@ static int es8311_configure(FAR struct audio_lowerhalf_s *dev,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
es8311_audio_input(priv);
|
||||||
|
es8311_reset(priv);
|
||||||
|
|
||||||
/* Save the current stream configuration */
|
/* Save the current stream configuration */
|
||||||
|
|
||||||
priv->samprate = caps->ac_controls.hw[0];
|
priv->samprate = caps->ac_controls.hw[0];
|
||||||
priv->bpsamp = caps->ac_controls.b[2];
|
priv->bpsamp = caps->ac_controls.b[2];
|
||||||
|
|
||||||
es8311_audio_input(priv);
|
ret = es8311_setsamplerate(priv) == -ENOTTY ? OK : ret;
|
||||||
es8311_reset(priv);
|
if (ret != OK)
|
||||||
es8311_setsamplerate(priv);
|
{
|
||||||
es8311_setbitspersample(priv);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = es8311_setbitspersample(priv) == -ENOTTY ? OK : ret;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue