[vlc-devel] [PATCH 4/5] wasapi: add 24bits support

Rémi Denis-Courmont remi at remlab.net
Fri Oct 25 12:17:23 CEST 2019


I disagree and this contradicts earlier decisions here.

Le 25 octobre 2019 10:16:28 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>
>On Thu, Oct 24, 2019, at 18:29, Rémi Denis-Courmont wrote:
>> So what? Some cards don't support PCM at all, or only some really
>weird formats. That's why we use the OS-provided HAL.
>
>In that case, we can also add support for such format.
>
>Yes, we must use the OS-provided HAL by default. But we can still add
>an advanced option to enable exclusive mode. I know a lot of audiophile
>would like to play their 24bit 96khz directly. Even if I know that
>16bit 48khz cover fully the hearing range.
>
>> 
>> I don't think this belongs in VLC. We already decided to drop 24-bits
>PCM earlier.
>
>Who ? when ? Do you have a trace ?
>
>> 
>> Le 24 octobre 2019 15:37:12 GMT+03:00, Thomas Guillem
><thomas at gllm.fr> a écrit :
>>> But don't use VLC_CODEC_S24N as this fourcc is not handled by any
>audio
>>> filters. Instead, request VLC_CODEC_S32N to VLC and do the
>conversion
>>> internally.
>>> 
>>> This commit is needed by the next commit since some sound cards only
>support
>>> 24bits. modules/audio_output/wasapi.c | 30
>+++++++++++++++++++++++++++---
>>>  1 file changed, 27 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/modules/audio_output/wasapi.c
>b/modules/audio_output/wasapi.c
>>> index d6105169b8e..daa946f8afc 100644
>>> --- a/modules/audio_output/wasapi.c
>>> +++ b/modules/audio_output/wasapi.c
>>> @@ -106,6 +106,7 @@ typedef struct aout_stream_sys
>>>      unsigned block_align;
>>>      UINT64 written; /**< Frames written to the buffer */
>>>      UINT32 frames; /**< Total buffer size (frames) */
>>> +    bool s24s32; /**< Output configured as S24N, but input as S32N
>*/
>>>  } aout_stream_sys_t;
>>>  
>>>  static void ResetTimer(aout_stream_t *s)
>>> @@ -268,7 +269,28 @@ static HRESULT Play(aout_stream_t *s, block_t
>*block, vlc_tick_t date)
>>>  
>>>          const size_t copy = frames * sys->block_align;
>>>  
>>> -        memcpy(dst, block->p_buffer, copy);
>>> +        if (!sys->s24s32)
>>> +        {
>>> +            memcpy(dst, block->p_buffer, copy);
>>> +            block->p_buffer += copy;
>>> +            block->i_buffer -= copy;
>>> +        }
>>> +        else
>>> +        {
>>> +            /* Convert back S32L to S24L. The following is doing
>the opposite
>>> +             * of S24LDecode() from codec/araw.c */
>>> +            BYTE *end = dst + copy;
>>> +            while (dst < end)
>>> +            {
>>> +                dst[0] = block->p_buffer[1];
>>> +                dst[1] = block->p_buffer[2];
>>> +                dst[2] = block->p_buffer[3];
>>> +                dst += 3;
>>> +                block->p_buffer += 4;
>>> +                block->i_buffer -= 4;
>>> +            }
>>> +
>>> +        }
>>>          hr = IAudioRenderClient_ReleaseBuffer(render, frames, 0);
>>>          if (FAILED(hr))
>>>          {
>>> @@ -276,8 +298,6 @@ static HRESULT Play(aout_stream_t *s, block_t
>*block, vlc_tick_t date)
>>>              break;
>>>          }
>>>  
>>> -        block->p_buffer += copy;
>>> -        block->i_buffer -= copy;
>>>          block->i_nb_samples -= frames;
>>>          sys->written += frames;
>>>          if (block->i_nb_samples == 0)
>>> @@ -512,6 +532,7 @@ static int vlc_FromWave(const WAVEFORMATEX
>*restrict wf,
>>>              switch (wf->wBitsPerSample)
>>>              {
>>>                  case 32:
>>> +                case 24:
>>>                      audio->i_format = VLC_CODEC_S32N;
>>>                      break;
>>>                  case 16:
>>> @@ -679,6 +700,9 @@ static HRESULT Start(aout_stream_t *s,
>audio_sample_format_t *restrict pfmt,
>>>      sys->format = fmt.i_format;
>>>      sys->block_align = pwf->nBlockAlign;
>>>      sys->rate = pwf->nSamplesPerSec;
>>> +    sys->s24s32 = pwf->wBitsPerSample == 24 && fmt.i_format ==
>VLC_CODEC_S32N;
>>> +    if (sys->s24s32)
>>> +        msg_Dbg(s, "audio device configured as s24");
>>>  
>>>      hr = IAudioClient_Initialize(sys->client, shared_mode, 0,
>buffer_duration,
>>>                                   0, pwf, sid);
>> 
>> -- 
>> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez
>excuser ma brièveté. 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20191025/1fc3a49f/attachment.html>


More information about the vlc-devel mailing list