Page 1 of 1

FL32 audio format callback problem

Posted: 17 Jan 2019 10:36
by MikOfClassX
Hello all,

I'm using the FL32 format.: libvlc_audio_set_format(vlcMediaPlayer, "FL32", AUDIO_SAMPLERATE, AUDIO_CHANNELS);

in the audio_play_cb callback I am supposing the audiodata to be a interleaved array of float samples. But it seems there's something wrong :
will crash in the memcpy() very often.

Code: Select all

// here we play the audio static void audio_play_cb(void *data, const void *samples, unsigned count, int64_t pts) { // data is the pointer to caller MediaHandler *mh = (MediaHandler *)data; mh->audiomutex.lock(); size_t sz = count * AUDIO_CHANNELS * sizeof(float); float * audioData = (float *)malloc(sz); memcpy(audioData, samples, sz);

Re: FL32 audio format callback problem

Posted: 17 Jan 2019 17:31
by RĂ©mi Denis-Courmont
What you describe is "f32l" or "f32b", not "FL32".

Re: FL32 audio format callback problem

Posted: 18 Jan 2019 10:13
by MikOfClassX
Yep, I was fooled from the docs: https://www.videolan.org/developers/vlc ... layer.html

libvlc_audio_set_format()
..
..
format a four-characters string identifying the sample format (e.g. "S16N" or "FL32")

it's better to use something like:

char audiofourcc[4];
vlc_fourcc_to_char(VLC_CODEC_FL32, audiofourcc);

Apart from this, now the correct fourcc is there. No longer crashes, but the memory layout of the samples is obscure.
They don't seem to be interleaved by channels modulo. So the audio output is incorrect.

Re: FL32 audio format callback problem

Posted: 06 Apr 2019 07:29
by realnc
char audiofourcc[4];
vlc_fourcc_to_char(VLC_CODEC_FL32, audiofourcc);

Apart from this, now the correct fourcc is there. No longer crashes, but the memory layout of the samples is obscure.
They don't seem to be interleaved by channels modulo. So the audio output is incorrect.

The output is always 16-bit signed integers interleaved. libVLC ignores the requested sample format in libvlc_audio_set_format(). You always get S16L samples. Probably a bug.

Re: FL32 audio format callback problem

Posted: 07 Apr 2019 11:43
by Jean-Baptiste Kempf
Report it on the bug tracker.

Re: FL32 audio format callback problem

Posted: 09 Apr 2019 10:56
by oviano

Re: FL32 audio format callback problem

Posted: 13 Apr 2019 17:41
by MikOfClassX
Thanks oviano. I spent too much time in looking for an unexisting bug in my code.
Someone reported the bug to the gurus here ?