[vlc-devel] [PATCH 3/9] aout: change bytes_per_frame/i_frame_length for S/PDIF
Thomas Guillem
thomas at gllm.fr
Wed Oct 5 18:37:46 CEST 2016
Use channel count and bitspersample to calculate bytes_per_frame.
i_frame_length is now 1 for S/PDIF formats.
A channel count of 2 will result of a bytes_per_frame of 4.
For TRUEHD/MLP, channels will be 8, then bytes_per_frame will be 16.
Comment: one commit per module ?
---
modules/audio_output/adummy.c | 4 ++--
modules/audio_output/alsa.c | 4 ++--
modules/audio_output/auhal.c | 6 +++---
modules/audio_output/directsound.c | 4 ++--
modules/audio_output/file.c | 4 ++--
modules/audio_output/oss.c | 4 ++--
modules/audio_output/pulse.c | 3 +++
modules/audio_output/wasapi.c | 7 ++++++-
modules/audio_output/waveout.c | 6 +++---
9 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/modules/audio_output/adummy.c b/modules/audio_output/adummy.c
index a973aed..d144d54 100644
--- a/modules/audio_output/adummy.c
+++ b/modules/audio_output/adummy.c
@@ -58,8 +58,8 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
if (AOUT_FMT_SPDIF(fmt) && var_InheritBool(aout, "spdif"))
{
fmt->i_format = VLC_CODEC_SPDIFL;
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
}
else
fmt->i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N;
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index a3e0944..cee40d3 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -579,8 +579,8 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
/* Setup audio_output_t */
if (spdif)
{
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
}
sys->format = fmt->i_format;
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index de64f42..a966a94 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1068,11 +1068,11 @@ static int StartSPDIF(audio_output_t * p_aout, audio_sample_format_t *fmt)
fmt->i_format = VLC_CODEC_SPDIFB;
else
fmt->i_format = VLC_CODEC_SPDIFL;
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
+ aout_FormatPrepare(fmt);
fmt->i_rate = (unsigned int)desired_stream_format.mSampleRate;
p_sys->i_rate = fmt->i_rate;
- aout_FormatPrepare(fmt);
/* Add IOProc callback */
err = AudioDeviceCreateIOProcID(p_sys->i_selected_dev,
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 8518c4c..5a1e331 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -656,8 +656,8 @@ static HRESULT Start( vlc_object_t *obj, aout_stream_sys_t *sys,
fmt.i_format = VLC_CODEC_SPDIFL;
/* Calculate the frame size in bytes */
- fmt.i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt.i_frame_length = A52_FRAME_NB;
+ fmt.i_physical_channels = fmt.i_original_channels = 0;
+ fmt.i_channels = 2;
}
else
{
diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
index 3a36aa9..05fdb2e 100644
--- a/modules/audio_output/file.c
+++ b/modules/audio_output/file.c
@@ -199,8 +199,8 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
fmt->i_format = format_int[i];
if ( AOUT_FMT_SPDIF( fmt ) )
{
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
}
/* Channels number */
diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index ba1a0f6..90801c6 100644
--- a/modules/audio_output/oss.c
+++ b/modules/audio_output/oss.c
@@ -204,8 +204,8 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
if (spdif)
{
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
}
else
{
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index a088e44..bbd0119 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -833,6 +833,9 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
/* Favor digital pass-through if available*/
if (encoding != PA_ENCODING_INVALID) {
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
+
formatv[formatc] = pa_format_info_new();
formatv[formatc]->encoding = encoding;
pa_format_info_set_rate(formatv[formatc], ss.rate);
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index a90d2da..b13dedf 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -279,6 +279,8 @@ static void vlc_HdmiToWave(WAVEFORMATEXTENSIBLE_IEC61937 *restrict wf_iec61937,
wf_iec61937->dwEncodedChannelCount = audio->i_channels;
wf_iec61937->dwAverageBytesPerSec = 0;
+ audio->i_physical_channels = audio->i_original_channels = 0;
+ audio->i_channels = wf->Format.nChannels;
audio->i_format = VLC_CODEC_SPDIFL;
}
@@ -299,7 +301,6 @@ static void vlc_SpdifToWave(WAVEFORMATEXTENSIBLE *restrict wf,
default:
vlc_assert_unreachable();
}
- audio->i_format = VLC_CODEC_SPDIFL;
wf->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wf->Format.nChannels = 2; /* To prevent channel re-ordering */
@@ -312,6 +313,10 @@ static void vlc_SpdifToWave(WAVEFORMATEXTENSIBLE *restrict wf,
wf->Samples.wValidBitsPerSample = wf->Format.wBitsPerSample;
wf->dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+
+ audio->i_physical_channels = audio->i_original_channels = 0;
+ audio->i_channels = wf->Format.nChannels;
+ audio->i_format = VLC_CODEC_SPDIFL;
}
static void vlc_ToWave(WAVEFORMATEXTENSIBLE *restrict wf,
diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c
index 3ce8158..785cccb 100644
--- a/modules/audio_output/waveout.c
+++ b/modules/audio_output/waveout.c
@@ -211,9 +211,9 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
fmt->i_format = VLC_CODEC_SPDIFL;
/* Calculate the frame size in bytes */
- fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
- fmt->i_frame_length = A52_FRAME_NB;
- p_aout->sys->i_buffer_size = fmt->i_bytes_per_frame;
+ fmt->i_physical_channels = fmt->i_original_channels = 0;
+ fmt->i_channels = 2;
+ p_aout->sys->i_buffer_size = AOUT_SPDIF_SIZE;
p_aout->sys->b_spdif = true;
}
--
2.9.3
More information about the vlc-devel
mailing list