aboutsummaryrefslogtreecommitdiff
path: root/src/output/alsa_output_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/output/alsa_output_plugin.c')
-rw-r--r--src/output/alsa_output_plugin.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/output/alsa_output_plugin.c b/src/output/alsa_output_plugin.c
index 4470e05e..18f65143 100644
--- a/src/output/alsa_output_plugin.c
+++ b/src/output/alsa_output_plugin.c
@@ -24,6 +24,9 @@
#include "pcm_export.h"
#include <glib.h>
+
+#include <libavutil/samplefmt.h>
+
#include <alsa/asoundlib.h>
#undef G_LOG_DOMAIN
@@ -211,27 +214,20 @@ alsa_test_default_device(void)
return true;
}
-static snd_pcm_format_t
-get_bitformat(enum sample_format sample_format)
+static snd_pcm_format_t get_bitformat(enum AVSampleFormat sample_format)
{
switch (sample_format) {
- case SAMPLE_FORMAT_UNDEFINED:
- return SND_PCM_FORMAT_UNKNOWN;
-
- case SAMPLE_FORMAT_S8:
- return SND_PCM_FORMAT_S8;
-
- case SAMPLE_FORMAT_S16:
+ case AV_SAMPLE_FMT_U8:
+ return SND_PCM_FORMAT_U8;
+ case AV_SAMPLE_FMT_S16:
return SND_PCM_FORMAT_S16;
-
- case SAMPLE_FORMAT_S24_P32:
- return SND_PCM_FORMAT_S24;
-
- case SAMPLE_FORMAT_S32:
+ case AV_SAMPLE_FMT_S32:
return SND_PCM_FORMAT_S32;
-
- case SAMPLE_FORMAT_FLOAT:
+ case AV_SAMPLE_FMT_FLT:
return SND_PCM_FORMAT_FLOAT;
+ default:
+ return SND_PCM_FORMAT_UNKNOWN;
+
}
assert(false);
@@ -300,10 +296,9 @@ alsa_try_format_or_packed(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
* Attempts to configure the specified sample format, and tries the
* reversed host byte order if was not supported.
*/
-static int
-alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
- enum sample_format sample_format,
- bool *packed_r, bool *reverse_endian_r)
+static int alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
+ enum AVSampleFormat sample_format,
+ bool *packed_r, bool *reverse_endian_r)
{
snd_pcm_format_t alsa_format = get_bitformat(sample_format);
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
@@ -343,18 +338,17 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
/* if unsupported by the hardware, try other formats */
- static const enum sample_format probe_formats[] = {
- SAMPLE_FORMAT_S24_P32,
- SAMPLE_FORMAT_S32,
- SAMPLE_FORMAT_S16,
- SAMPLE_FORMAT_S8,
- SAMPLE_FORMAT_UNDEFINED,
+ static const enum AVSampleFormat probe_formats[] = {
+ AV_SAMPLE_FMT_S32,
+ AV_SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_U8,
+ AV_SAMPLE_FMT_NONE,
};
for (unsigned i = 0;
- err == -EINVAL && probe_formats[i] != SAMPLE_FORMAT_UNDEFINED;
+ err == -EINVAL && probe_formats[i] != AV_SAMPLE_FMT_NONE;
++i) {
- const enum sample_format mpd_format = probe_formats[i];
+ const enum AVSampleFormat mpd_format = probe_formats[i];
if (mpd_format == audio_format->format)
continue;
@@ -578,13 +572,13 @@ static bool
alsa_setup_or_dsd(struct alsa_data *ad, struct audio_format *audio_format,
GError **error_r)
{
- bool shift8 = false, packed, reverse_endian;
+ bool packed, reverse_endian;
const bool success = alsa_setup(ad, audio_format, &packed, &reverse_endian, error_r);
if (!success)
return false;
- pcm_export_open(&ad->export, audio_format->format, shift8, packed, reverse_endian);
+ pcm_export_open(&ad->export, audio_format->format, packed, reverse_endian);
return true;
}