X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_output%2Falsa.c;h=fa7d70fa7b4021beb0d849a4f9607c72210da4c0;hb=499ecdbd7202a04b344f48ba5b572f716dbe3a52;hp=93d80545dd7eb356970fde9f730008455370fc35;hpb=dbbb4fad5a66c8c5499c3631a08440ab572b3c53;p=vlc diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c index 93d80545dd..fa7d70fa7b 100644 --- a/modules/audio_output/alsa.c +++ b/modules/audio_output/alsa.c @@ -44,9 +44,9 @@ struct aout_sys_t { snd_pcm_t *pcm; unsigned rate; /**< Sample rate */ + vlc_fourcc_t format; /**< Sample format */ uint8_t chans_table[AOUT_CHAN_MAX]; /**< Channels order table */ uint8_t chans_to_reorder; /**< Number of channels to reorder */ - uint8_t bits; /**< Bits per sample per channel */ bool soft_mute; float soft_gain; @@ -306,35 +306,14 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) switch (fmt->i_format) { - case VLC_CODEC_F64B: - pcm_format = SND_PCM_FORMAT_FLOAT64_BE; + case VLC_CODEC_FL64: + pcm_format = SND_PCM_FORMAT_FLOAT64; break; - case VLC_CODEC_F64L: - pcm_format = SND_PCM_FORMAT_FLOAT64_LE; + case VLC_CODEC_FL32: + pcm_format = SND_PCM_FORMAT_FLOAT; break; - case VLC_CODEC_F32B: - pcm_format = SND_PCM_FORMAT_FLOAT_BE; - break; - case VLC_CODEC_F32L: - pcm_format = SND_PCM_FORMAT_FLOAT_LE; - break; - case VLC_CODEC_S32B: - pcm_format = SND_PCM_FORMAT_S32_BE; - break; - case VLC_CODEC_S32L: - pcm_format = SND_PCM_FORMAT_S32_LE; - break; - case VLC_CODEC_S24B: - pcm_format = SND_PCM_FORMAT_S24_3BE; - break; - case VLC_CODEC_S24L: - pcm_format = SND_PCM_FORMAT_S24_3LE; - break; - case VLC_CODEC_U24B: - pcm_format = SND_PCM_FORMAT_U24_3BE; - break; - case VLC_CODEC_U24L: - pcm_format = SND_PCM_FORMAT_U24_3LE; + case VLC_CODEC_S32N: + pcm_format = SND_PCM_FORMAT_S32; break; case VLC_CODEC_S16N: pcm_format = SND_PCM_FORMAT_S16; @@ -481,7 +460,10 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) channels = popcount (fmt->i_physical_channels); } else + { + sys->chans_to_reorder = 0; channels = 2; + } fmt->i_original_channels = fmt->i_physical_channels; /* By default, ALSA plug will pad missing channels with zeroes, which is @@ -584,11 +566,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE; fmt->i_frame_length = A52_FRAME_NB; } - else - { - aout_FormatPrepare (fmt); - sys->bits = fmt->i_bitspersample; - } + sys->format = fmt->i_format; aout->time_get = TimeGet; aout->play = Play; @@ -632,7 +610,7 @@ static void Play (audio_output_t *aout, block_t *block) if (sys->chans_to_reorder != 0) aout_ChannelReorder(block->p_buffer, block->i_buffer, - sys->chans_to_reorder, sys->chans_table, sys->bits); + sys->chans_to_reorder, sys->chans_table, sys->format); snd_pcm_t *pcm = sys->pcm; @@ -762,11 +740,6 @@ static int EnumDevices(vlc_object_t *obj, char const *varname, return n; } -static int DevicesEnum (audio_output_t *aout, char ***idp, char ***namep) -{ - return EnumDevices (VLC_OBJECT(aout), NULL, idp, namep); -} - static int DeviceSelect (audio_output_t *aout, const char *id) { aout_sys_t *sys = aout->sys; @@ -797,9 +770,24 @@ static int Open(vlc_object_t *obj) aout->start = Start; aout->stop = Stop; aout_SoftVolumeInit (aout); - aout->device_enum = DevicesEnum; aout->device_select = DeviceSelect; aout_DeviceReport (aout, sys->device); + + /* ALSA does not support hot-plug events so list devices at startup */ + char **ids, **names; + int count = EnumDevices (VLC_OBJECT(aout), NULL, &ids, &names); + if (count >= 0) + { + for (int i = 0; i < count; i++) + { + aout_HotplugReport (aout, ids[i], names[i]); + free (names[i]); + free (ids[i]); + } + free (names); + free (ids); + } + return VLC_SUCCESS; error: free (sys);