output/alsa: pass PcmExport::Params to alsa_setup()
This commit is contained in:
parent
4a47265224
commit
c9761bf6af
@ -363,11 +363,11 @@ alsa_to_packed_format(snd_pcm_format_t fmt)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
alsa_try_format_or_packed(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
alsa_try_format_or_packed(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
||||||
snd_pcm_format_t fmt, bool *packed_r)
|
snd_pcm_format_t fmt, PcmExport::Params ¶ms)
|
||||||
{
|
{
|
||||||
int err = snd_pcm_hw_params_set_format(pcm, hwparams, fmt);
|
int err = snd_pcm_hw_params_set_format(pcm, hwparams, fmt);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
*packed_r = false;
|
params.pack24 = false;
|
||||||
|
|
||||||
if (err != -EINVAL)
|
if (err != -EINVAL)
|
||||||
return err;
|
return err;
|
||||||
@ -378,7 +378,7 @@ alsa_try_format_or_packed(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
|
|
||||||
err = snd_pcm_hw_params_set_format(pcm, hwparams, fmt);
|
err = snd_pcm_hw_params_set_format(pcm, hwparams, fmt);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
*packed_r = true;
|
params.pack24 = true;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -390,16 +390,16 @@ alsa_try_format_or_packed(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
static int
|
static int
|
||||||
alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
||||||
SampleFormat sample_format,
|
SampleFormat sample_format,
|
||||||
bool *packed_r, bool *reverse_endian_r)
|
PcmExport::Params ¶ms)
|
||||||
{
|
{
|
||||||
snd_pcm_format_t alsa_format = get_bitformat(sample_format);
|
snd_pcm_format_t alsa_format = get_bitformat(sample_format);
|
||||||
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
|
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
int err = alsa_try_format_or_packed(pcm, hwparams, alsa_format,
|
int err = alsa_try_format_or_packed(pcm, hwparams, alsa_format,
|
||||||
packed_r);
|
params);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
*reverse_endian_r = false;
|
params.reverse_endian = false;
|
||||||
|
|
||||||
if (err != -EINVAL)
|
if (err != -EINVAL)
|
||||||
return err;
|
return err;
|
||||||
@ -408,9 +408,9 @@ alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
|
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
err = alsa_try_format_or_packed(pcm, hwparams, alsa_format, packed_r);
|
err = alsa_try_format_or_packed(pcm, hwparams, alsa_format, params);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
*reverse_endian_r = true;
|
params.reverse_endian = true;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -421,13 +421,13 @@ alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
static int
|
static int
|
||||||
alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
||||||
AudioFormat &audio_format,
|
AudioFormat &audio_format,
|
||||||
bool *packed_r, bool *reverse_endian_r)
|
PcmExport::Params ¶ms)
|
||||||
{
|
{
|
||||||
/* try the input format first */
|
/* try the input format first */
|
||||||
|
|
||||||
int err = alsa_output_try_format(pcm, hwparams,
|
int err = alsa_output_try_format(pcm, hwparams,
|
||||||
audio_format.format,
|
audio_format.format,
|
||||||
packed_r, reverse_endian_r);
|
params);
|
||||||
|
|
||||||
/* if unsupported by the hardware, try other formats */
|
/* if unsupported by the hardware, try other formats */
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
err = alsa_output_try_format(pcm, hwparams, mpd_format,
|
err = alsa_output_try_format(pcm, hwparams, mpd_format,
|
||||||
packed_r, reverse_endian_r);
|
params);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
audio_format.format = mpd_format;
|
audio_format.format = mpd_format;
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
alsa_setup(AlsaOutput *ad, AudioFormat &audio_format,
|
alsa_setup(AlsaOutput *ad, AudioFormat &audio_format,
|
||||||
bool *packed_r, bool *reverse_endian_r, Error &error)
|
PcmExport::Params ¶ms, Error &error)
|
||||||
{
|
{
|
||||||
unsigned int sample_rate = audio_format.sample_rate;
|
unsigned int sample_rate = audio_format.sample_rate;
|
||||||
unsigned int channels = audio_format.channels;
|
unsigned int channels = audio_format.channels;
|
||||||
@ -505,7 +505,7 @@ configure_hw:
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = alsa_output_setup_format(ad->pcm, hwparams, audio_format,
|
err = alsa_output_setup_format(ad->pcm, hwparams, audio_format,
|
||||||
packed_r, reverse_endian_r);
|
params);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
error.Format(alsa_output_domain, err,
|
error.Format(alsa_output_domain, err,
|
||||||
"ALSA device \"%s\" does not support format %s: %s",
|
"ALSA device \"%s\" does not support format %s: %s",
|
||||||
@ -688,8 +688,7 @@ AlsaOutput::SetupDop(const AudioFormat audio_format,
|
|||||||
|
|
||||||
const AudioFormat check = dop_format;
|
const AudioFormat check = dop_format;
|
||||||
|
|
||||||
if (!alsa_setup(this, dop_format, ¶ms.pack24,
|
if (!alsa_setup(this, dop_format, params, error))
|
||||||
¶ms.reverse_endian, error))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* if the device allows only 32 bit, shift all DoP
|
/* if the device allows only 32 bit, shift all DoP
|
||||||
@ -723,9 +722,7 @@ AlsaOutput::SetupOrDop(AudioFormat &audio_format, Error &error)
|
|||||||
params.dop = dop && audio_format.format == SampleFormat::DSD;
|
params.dop = dop && audio_format.format == SampleFormat::DSD;
|
||||||
const bool success = params.dop
|
const bool success = params.dop
|
||||||
? SetupDop(audio_format, params, error)
|
? SetupDop(audio_format, params, error)
|
||||||
: alsa_setup(this, audio_format,
|
: alsa_setup(this, audio_format, params, error);
|
||||||
¶ms.pack24, ¶ms.reverse_endian,
|
|
||||||
error);
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user