diff --git a/drivers/audio/es8311.c b/drivers/audio/es8311.c index 296c75cb58..8d497f05a2 100644 --- a/drivers/audio/es8311.c +++ b/drivers/audio/es8311.c @@ -1033,19 +1033,25 @@ static int es8311_configure(FAR struct audio_lowerhalf_s *dev, break; } + es8311_audio_output(priv); + es8311_reset(priv); + /* Save the current stream configuration */ priv->samprate = caps->ac_controls.hw[0]; priv->bpsamp = caps->ac_controls.b[2]; - es8311_audio_output(priv); - es8311_reset(priv); - es8311_setsamplerate(priv); - es8311_setbitspersample(priv); + ret = es8311_setsamplerate(priv) == -ENOTTY ? OK : ret; + if (ret < 0) + { + break; + } + + ret = es8311_setbitspersample(priv) == -ENOTTY ? OK : ret; } break; - case AUDIO_TYPE_INPUT: + case AUDIO_TYPE_INPUT: { audinfo(" AUDIO_TYPE_INPUT:\n"); audinfo(" Number of channels: %u\n", caps->ac_channels); @@ -1074,15 +1080,21 @@ static int es8311_configure(FAR struct audio_lowerhalf_s *dev, break; } + es8311_audio_input(priv); + es8311_reset(priv); + /* Save the current stream configuration */ priv->samprate = caps->ac_controls.hw[0]; priv->bpsamp = caps->ac_controls.b[2]; - es8311_audio_input(priv); - es8311_reset(priv); - es8311_setsamplerate(priv); - es8311_setbitspersample(priv); + ret = es8311_setsamplerate(priv) == -ENOTTY ? OK : ret; + if (ret != OK) + { + break; + } + + ret = es8311_setbitspersample(priv) == -ENOTTY ? OK : ret; } break;