[vlc-commits] wasapi: simplify

Thomas Guillem git at videolan.org
Wed Sep 14 15:32:04 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 13 09:53:37 2016 +0200| [ceec14e44b3a439da3340758a356a23663ca03e5] | committer: Thomas Guillem

wasapi: simplify

Use block_align directly instead of calculating it for each blocks.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ceec14e44b3a439da3340758a356a23663ca03e5
---

 modules/audio_output/wasapi.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index 2bcfc96..44a4b80 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -80,8 +80,7 @@ typedef struct aout_stream_sys
 
     vlc_fourcc_t format; /**< Sample format */
     unsigned rate; /**< Sample rate */
-    unsigned bytes_per_frame;
-    unsigned frame_length;
+    unsigned block_align;
     UINT64 written; /**< Frames written to the buffer */
     UINT32 frames; /**< Total buffer size (frames) */
 } aout_stream_sys_t;
@@ -168,7 +167,7 @@ static HRESULT Play(aout_stream_t *s, block_t *block)
             break;
         }
 
-        const size_t copy = frames * sys->bytes_per_frame / sys->frame_length;
+        const size_t copy = frames * sys->block_align;
 
         memcpy(dst, block->p_buffer, copy);
         hr = IAudioRenderClient_ReleaseBuffer(render, frames, 0);
@@ -261,9 +260,6 @@ static void vlc_SpdifToWave(WAVEFORMATEXTENSIBLE *restrict wf,
         vlc_assert_unreachable();
     }
     audio->i_format = VLC_CODEC_SPDIFL;
-    aout_FormatPrepare (audio);
-    audio->i_bytes_per_frame = AOUT_SPDIF_SIZE;
-    audio->i_frame_length = A52_FRAME_NB;
 
     wf->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
     wf->Format.nChannels = 2; /* To prevent channel re-ordering */
@@ -459,6 +455,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
 
     sys->chans_to_reorder = vlc_CheckWaveOrder(pwf, sys->chans_table);
     sys->format = fmt.i_format;
+    sys->block_align = pwf->nBlockAlign;
 
     hr = IAudioClient_Initialize(sys->client, shared_mode, 0,
                                  AOUT_MAX_PREPARE_TIME * 10, 0, pwf, sid);
@@ -488,8 +485,6 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
 
     *pfmt = fmt;
     sys->rate = fmt.i_rate;
-    sys->bytes_per_frame = fmt.i_bytes_per_frame;
-    sys->frame_length = fmt.i_frame_length > 0 ? fmt.i_frame_length : 1;
     sys->written = 0;
     s->sys = sys;
     s->time_get = TimeGet;



More information about the vlc-commits mailing list