diff options
author | Chris Robinson <[email protected]> | 2019-12-21 20:43:46 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-12-21 20:43:46 -0800 |
commit | 2e6a55a87ce24a9303c3039609b41fb0eb302483 (patch) | |
tree | f3bb706cac1689ac9233da4bdd78a9530b5c078a /alc/backends/alsa.cpp | |
parent | c2ca617ed60e26878a6ac10aaf0dc644b6a24d29 (diff) |
Handle padding between device sample frames
The padding must be constant and sample type aligned (e.g. some fixed multiple
of two bytes between the start of two consecutive frames for 16-bit output).
The intent is to always have the ability for stereo output with WASAPI even if
the device has some other unsupported configuration, as long as front-left and
front-right exist.
Diffstat (limited to 'alc/backends/alsa.cpp')
-rw-r--r-- | alc/backends/alsa.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index 7dc3c3c4..236e7a2f 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -446,6 +446,7 @@ int AlsaPlayback::mixerProc() SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); + const size_t samplebits{mDevice->bytesFromFmt() * 8}; const snd_pcm_uframes_t update_size{mDevice->UpdateSize}; const snd_pcm_uframes_t buffer_size{mDevice->BufferSize}; while(!mKillNow.load(std::memory_order_acquire)) @@ -507,7 +508,7 @@ int AlsaPlayback::mixerProc() } char *WritePtr{static_cast<char*>(areas->addr) + (offset * areas->step / 8)}; - aluMixData(mDevice, WritePtr, static_cast<ALuint>(frames)); + aluMixData(mDevice, WritePtr, static_cast<ALuint>(frames), areas->step / samplebits); snd_pcm_sframes_t commitres{snd_pcm_mmap_commit(mPcmHandle, offset, frames)}; if(commitres < 0 || (static_cast<snd_pcm_uframes_t>(commitres)-frames) != 0) @@ -529,6 +530,7 @@ int AlsaPlayback::mixerNoMMapProc() SetRTPriority(); althrd_setname(MIXER_THREAD_NAME); + const size_t frame_step{mDevice->channelsFromFmt()}; const snd_pcm_uframes_t update_size{mDevice->UpdateSize}; const snd_pcm_uframes_t buffer_size{mDevice->BufferSize}; while(!mKillNow.load(std::memory_order_acquire)) @@ -574,7 +576,7 @@ int AlsaPlayback::mixerNoMMapProc() std::lock_guard<AlsaPlayback> _{*this}; al::byte *WritePtr{mBuffer.data()}; avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size())); - aluMixData(mDevice, WritePtr, static_cast<ALuint>(avail)); + aluMixData(mDevice, WritePtr, static_cast<ALuint>(avail), frame_step); while(avail > 0) { snd_pcm_sframes_t ret{snd_pcm_writei(mPcmHandle, WritePtr, |