Skip to content

Commit

Permalink
WASAPI: Round sample size to the nearest multiple of 8 bits
Browse files Browse the repository at this point in the history
This allows to use formats such as 24 bit PCM with a 32 bit container.
  • Loading branch information
davidebeatrici committed Mar 19, 2024
1 parent 24f71f0 commit 8208f26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_VISIBILITY_PRESET hidden)

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

Expand Down
3 changes: 2 additions & 1 deletion src/backends/WASAPI/WASAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "Backend.h"

#include <bit>
#include <cstring>
#include <functional>
#include <thread>
Expand Down Expand Up @@ -665,7 +666,7 @@ static constexpr WAVEFORMATEXTENSIBLE configToWaveFormat(const FluxConfig &confi
fmtBasic.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
fmtBasic.nChannels = config.channels;
fmtBasic.nSamplesPerSec = config.sampleRate;
fmtBasic.wBitsPerSample = fmt.Samples.wValidBitsPerSample;
fmtBasic.wBitsPerSample = std::bit_ceil(config.sampleBits);
fmtBasic.nBlockAlign = fmtBasic.nChannels * fmtBasic.wBitsPerSample / 8;
fmtBasic.nAvgBytesPerSec = fmtBasic.nBlockAlign * fmtBasic.nSamplesPerSec;

Expand Down

0 comments on commit 8208f26

Please sign in to comment.