aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.cpp13
-rw-r--r--Alc/backends/coreaudio.cpp4
-rw-r--r--Alc/backends/dsound.cpp12
-rw-r--r--Alc/backends/jack.cpp12
-rw-r--r--Alc/backends/opensl.cpp20
-rw-r--r--Alc/backends/oss.cpp20
-rw-r--r--Alc/backends/portaudio.cpp4
-rw-r--r--Alc/backends/pulseaudio.cpp4
-rw-r--r--Alc/backends/qsa.cpp21
-rw-r--r--Alc/backends/sdl2.cpp4
-rw-r--r--Alc/backends/sndio.cpp12
-rw-r--r--Alc/backends/solaris.cpp15
-rw-r--r--Alc/backends/wasapi.cpp12
-rw-r--r--Alc/backends/wave.cpp13
-rw-r--r--Alc/backends/winmm.cpp7
15 files changed, 74 insertions, 99 deletions
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 629038b8..606877a8 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -765,7 +765,7 @@ ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
}
CHECK(snd_pcm_hw_params_set_format(self->PcmHandle, hp, format));
/* test and set channels (implicitly sets frame bits) */
- if(snd_pcm_hw_params_test_channels(self->PcmHandle, hp, ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder)) < 0)
+ if(snd_pcm_hw_params_test_channels(self->PcmHandle, hp, device->channelsFromFmt()) < 0)
{
static const enum DevFmtChannels channellist[] = {
DevFmtStereo,
@@ -785,7 +785,7 @@ ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
}
}
}
- CHECK(snd_pcm_hw_params_set_channels(self->PcmHandle, hp, ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder)));
+ CHECK(snd_pcm_hw_params_set_channels(self->PcmHandle, hp, device->channelsFromFmt()));
/* set rate (implicitly constrains period/buffer parameters) */
if(!GetConfigValueBool(device->DeviceName.c_str(), "alsa", "allow-resampler", 0) ||
!(device->Flags&DEVICE_FREQUENCY_REQUEST))
@@ -1046,7 +1046,7 @@ ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name)
/* set format (implicitly sets sample bits) */
CHECK(snd_pcm_hw_params_set_format(self->PcmHandle, hp, format));
/* set channels (implicitly sets frame bits) */
- CHECK(snd_pcm_hw_params_set_channels(self->PcmHandle, hp, ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder)));
+ CHECK(snd_pcm_hw_params_set_channels(self->PcmHandle, hp, device->channelsFromFmt()));
/* set rate (implicitly constrains period/buffer parameters) */
CHECK(snd_pcm_hw_params_set_rate(self->PcmHandle, hp, device->Frequency, 0));
/* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
@@ -1068,11 +1068,8 @@ ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name)
if(needring)
{
- self->Ring = ll_ringbuffer_create(
- device->UpdateSize*device->NumUpdates,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder),
- false
- );
+ self->Ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates,
+ device->frameSizeFromFmt(), false);
if(!self->Ring)
{
ERR("ring buffer create failed\n");
diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp
index b2f6d2d3..228d1d76 100644
--- a/Alc/backends/coreaudio.cpp
+++ b/Alc/backends/coreaudio.cpp
@@ -271,7 +271,7 @@ static ALCboolean ALCcoreAudioPlayback_reset(ALCcoreAudioPlayback *self)
}
/* setup callback */
- self->FrameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->FrameSize = device->frameSizeFromFmt();
input.inputProc = ALCcoreAudioPlayback_MixerProc;
input.inputProcRefCon = self;
@@ -622,7 +622,7 @@ static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar
// save requested format description for later use
self->Format = requestedFormat;
- self->FrameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->FrameSize = device->frameSizeFromFmt();
// Use intermediate format for sample rate conversion (outputFormat)
// Set sample rate to the same as hardware for resampling later
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 79e6b01e..5aa95f0f 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -265,7 +265,7 @@ FORCE_ALIGN int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
return 1;
}
- ALsizei FrameSize{FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder)};
+ ALsizei FrameSize{device->frameSizeFromFmt()};
DWORD FragSize{device->UpdateSize * FrameSize};
bool Playing{false};
@@ -521,8 +521,8 @@ ALCboolean ALCdsoundPlayback_reset(ALCdsoundPlayback *self)
retry_open:
hr = S_OK;
OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
- OutputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
- OutputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ OutputType.Format.nChannels = device->channelsFromFmt();
+ OutputType.Format.wBitsPerSample = device->bytesFromFmt() * 8;
OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8;
OutputType.Format.nSamplesPerSec = device->Frequency;
OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign;
@@ -805,8 +805,8 @@ ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName)
}
InputType.Format.wFormatTag = WAVE_FORMAT_PCM;
- InputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
- InputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ InputType.Format.nChannels = device->channelsFromFmt();
+ InputType.Format.wBitsPerSample = device->bytesFromFmt() * 8;
InputType.Format.nBlockAlign = InputType.Format.nChannels*InputType.Format.wBitsPerSample/8;
InputType.Format.nSamplesPerSec = device->Frequency;
InputType.Format.nAvgBytesPerSec = InputType.Format.nSamplesPerSec*InputType.Format.nBlockAlign;
@@ -904,7 +904,7 @@ ALCuint ALCdsoundCapture_availableSamples(ALCdsoundCapture *self)
if(!device->Connected.load(std::memory_order_acquire))
return static_cast<ALCuint>(ll_ringbuffer_read_space(self->Ring));
- ALsizei FrameSize{FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder)};
+ ALsizei FrameSize{device->frameSizeFromFmt()};
DWORD BufferBytes{self->BufferBytes};
DWORD LastCursor{self->Cursor};
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index d141f991..88f60c93 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -222,10 +222,7 @@ int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg)
TRACE("%u update size x%u\n", device->UpdateSize, device->NumUpdates);
self->mRing = nullptr;
- self->mRing.reset(ll_ringbuffer_create(bufsize,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder),
- true
- ));
+ self->mRing.reset(ll_ringbuffer_create(bufsize, device->frameSizeFromFmt(), true));
if(!self->mRing)
{
ERR("Failed to reallocate ringbuffer\n");
@@ -400,7 +397,7 @@ ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self)
/* Force 32-bit float output. */
device->FmtType = DevFmtFloat;
- ALsizei numchans{ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder)};
+ ALsizei numchans{device->channelsFromFmt()};
auto ports_end = std::begin(self->mPort) + numchans;
auto bad_port = std::find_if_not(std::begin(self->mPort), ports_end,
[self](jack_port_t *&port) -> bool
@@ -432,10 +429,7 @@ ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self)
}
self->mRing = nullptr;
- self->mRing.reset(ll_ringbuffer_create(bufsize,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder),
- true
- ));
+ self->mRing.reset(ll_ringbuffer_create(bufsize, device->frameSizeFromFmt(), true));
if(!self->mRing)
{
ERR("Failed to allocate ringbuffer\n");
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index c2acda3a..78212791 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -464,7 +464,7 @@ static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self)
device->FmtType = DevFmtShort;
SetDefaultWFXChannelOrder(device);
- self->mFrameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->mFrameSize = device->frameSizeFromFmt();
loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
@@ -473,9 +473,9 @@ static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self)
#ifdef SL_DATAFORMAT_PCM_EX
SLDataFormat_PCM_EX format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM_EX;
- format_pcm.numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ format_pcm.numChannels = device->channelsFromFmt();
format_pcm.sampleRate = device->Frequency * 1000;
- format_pcm.bitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ format_pcm.bitsPerSample = device->bytesFromFmt() * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(device->FmtChans);
format_pcm.endianness = IS_LITTLE_ENDIAN ? SL_BYTEORDER_LITTLEENDIAN :
@@ -484,9 +484,9 @@ static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self)
#else
SLDataFormat_PCM format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM;
- format_pcm.numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ format_pcm.numChannels = device->channelsFromFmt();
format_pcm.samplesPerSec = device->Frequency * 1000;
- format_pcm.bitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ format_pcm.bitsPerSample = device->bytesFromFmt() * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(device->FmtChans);
format_pcm.endianness = IS_LITTLE_ENDIAN ? SL_BYTEORDER_LITTLEENDIAN :
@@ -755,7 +755,7 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name
device->UpdateSize = update_len;
device->NumUpdates = (length+update_len-1) / update_len;
- self->mFrameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->mFrameSize = device->frameSizeFromFmt();
}
loc_dev.locatorType = SL_DATALOCATOR_IODEVICE;
loc_dev.deviceType = SL_IODEVICE_AUDIOINPUT;
@@ -771,9 +771,9 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name
#ifdef SL_DATAFORMAT_PCM_EX
SLDataFormat_PCM_EX format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM_EX;
- format_pcm.numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ format_pcm.numChannels = device->channelsFromFmt();
format_pcm.sampleRate = device->Frequency * 1000;
- format_pcm.bitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ format_pcm.bitsPerSample = device->bytesFromFmt() * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(device->FmtChans);
format_pcm.endianness = IS_LITTLE_ENDIAN ? SL_BYTEORDER_LITTLEENDIAN :
@@ -782,9 +782,9 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name
#else
SLDataFormat_PCM format_pcm;
format_pcm.formatType = SL_DATAFORMAT_PCM;
- format_pcm.numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ format_pcm.numChannels = device->channelsFromFmt();
format_pcm.samplesPerSec = device->Frequency * 1000;
- format_pcm.bitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ format_pcm.bitsPerSample = device->bytesFromFmt() * 8;
format_pcm.containerSize = format_pcm.bitsPerSample;
format_pcm.channelMask = GetChannelMask(device->FmtChans);
format_pcm.endianness = IS_LITTLE_ENDIAN ? SL_BYTEORDER_LITTLEENDIAN :
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index 5e8100fb..110672c7 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -298,7 +298,7 @@ int ALCplaybackOSS_mixerProc(ALCplaybackOSS *self)
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frame_size = device->frameSizeFromFmt();
ALCplaybackOSS_lock(self);
while(!self->mKillNow.load(std::memory_order_acquire) &&
@@ -417,9 +417,9 @@ ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self)
}
periods = device->NumUpdates;
- numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ numChannels = device->channelsFromFmt();
ossSpeed = device->Frequency;
- frameSize = numChannels * BytesFromDevFmt(device->FmtType);
+ frameSize = numChannels * device->bytesFromFmt();
/* According to the OSS spec, 16 bytes (log2(16)) is the minimum. */
log2FragmentSize = maxi(log2i(device->UpdateSize*frameSize), 4);
numFragmentsLogSize = (periods << 16) | log2FragmentSize;
@@ -443,7 +443,7 @@ ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self)
}
#undef CHECKERR
- if((int)ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder) != numChannels)
+ if(device->channelsFromFmt() != numChannels)
{
ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels);
return ALC_FALSE;
@@ -471,9 +471,7 @@ ALCboolean ALCplaybackOSS_start(ALCplaybackOSS *self)
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
try {
- self->mMixData.resize(device->UpdateSize * FrameSizeFromDevFmt(
- device->FmtChans, device->FmtType, device->mAmbiOrder
- ));
+ self->mMixData.resize(device->UpdateSize * device->frameSizeFromFmt());
self->mKillNow.store(AL_FALSE);
self->mThread = std::thread(ALCplaybackOSS_mixerProc, self);
@@ -558,7 +556,7 @@ int ALCcaptureOSS_recordProc(ALCcaptureOSS *self)
SetRTPriority();
althrd_setname(RECORD_THREAD_NAME);
- frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frame_size = device->frameSizeFromFmt();
while(!self->mKillNow.load())
{
@@ -651,8 +649,8 @@ ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
}
int periods{4};
- int numChannels{ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder)};
- int frameSize{numChannels * BytesFromDevFmt(device->FmtType)};
+ int numChannels{device->channelsFromFmt()};
+ int frameSize{numChannels * device->bytesFromFmt()};
int ossSpeed{static_cast<int>(device->Frequency)};
int log2FragmentSize{log2i(device->UpdateSize * device->NumUpdates *
frameSize / periods)};
@@ -682,7 +680,7 @@ ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
}
#undef CHECKERR
- if((int)ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder) != numChannels)
+ if(device->channelsFromFmt() != numChannels)
{
ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels);
close(self->fd);
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index 8b8c7fef..93384489 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -390,7 +390,7 @@ ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name)
samples = device->UpdateSize * device->NumUpdates;
samples = maxu(samples, 100 * device->Frequency / 1000);
- frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frame_size = device->frameSizeFromFmt();
self->Ring = ll_ringbuffer_create(samples, frame_size, false);
if(self->Ring == nullptr) return ALC_INVALID_VALUE;
@@ -424,7 +424,7 @@ ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name)
ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType));
return ALC_INVALID_VALUE;
}
- self->Params.channelCount = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ self->Params.channelCount = device->channelsFromFmt();
err = Pa_OpenStream(&self->Stream, &self->Params, nullptr,
device->Frequency, paFramesPerBufferUnspecified, paNoFlag,
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index b7dcd87c..cbf2992d 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -1037,7 +1037,7 @@ ALCboolean PulsePlayback_reset(PulsePlayback *self)
break;
}
self->spec.rate = device->Frequency;
- self->spec.channels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ self->spec.channels = device->channelsFromFmt();
if(pa_sample_spec_valid(&self->spec) == 0)
{
@@ -1552,7 +1552,7 @@ ALCenum PulseCapture_open(PulseCapture *self, const ALCchar *name)
}
self->spec.rate = device->Frequency;
- self->spec.channels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ self->spec.channels = device->channelsFromFmt();
if(pa_sample_spec_valid(&self->spec) == 0)
{
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index 3d09a744..f8b26878 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -210,9 +210,7 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr)
param.sched_priority=param.sched_curpriority+1;
SchedSet(0, 0, SCHED_NOCHANGE, &param);
- const ALint frame_size = FrameSizeFromDevFmt(
- device->FmtChans, device->FmtType, device->mAmbiOrder
- );
+ const ALint frame_size = device->frameSizeFromFmt();
PlaybackWrapper_lock(self);
while(!data->mKillNow.load(std::memory_order_acquire))
@@ -385,14 +383,13 @@ static ALCboolean qsa_reset_playback(PlaybackWrapper *self)
data->cparams.start_mode=SND_PCM_START_FULL;
data->cparams.stop_mode=SND_PCM_STOP_STOP;
- data->cparams.buf.block.frag_size=device->UpdateSize *
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ data->cparams.buf.block.frag_size=device->UpdateSize * device->frameSizeFromFmt();
data->cparams.buf.block.frags_max=device->NumUpdates;
data->cparams.buf.block.frags_min=device->NumUpdates;
data->cparams.format.interleave=1;
data->cparams.format.rate=device->Frequency;
- data->cparams.format.voices=ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ data->cparams.format.voices=device->channelsFromFmt();
data->cparams.format.format=format;
if ((snd_pcm_plugin_params(data->pcmHandle, &data->cparams))<0)
@@ -575,8 +572,7 @@ static ALCboolean qsa_reset_playback(PlaybackWrapper *self)
SetDefaultChannelOrder(device);
- device->UpdateSize=data->csetup.buf.block.frag_size/
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ device->UpdateSize=data->csetup.buf.block.frag_size / device->frameSizeFromFmt();
device->NumUpdates=data->csetup.buf.block.frags;
data->size=data->csetup.buf.block.frag_size;
@@ -757,14 +753,13 @@ static ALCenum qsa_open_capture(CaptureWrapper *self, const ALCchar *deviceName)
data->cparams.start_mode=SND_PCM_START_GO;
data->cparams.stop_mode=SND_PCM_STOP_STOP;
- data->cparams.buf.block.frag_size=device->UpdateSize*
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ data->cparams.buf.block.frag_size=device->UpdateSize * device->frameSizeFromFmt();
data->cparams.buf.block.frags_max=device->NumUpdates;
data->cparams.buf.block.frags_min=device->NumUpdates;
data->cparams.format.interleave=1;
data->cparams.format.rate=device->Frequency;
- data->cparams.format.voices=ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ data->cparams.format.voices=device->channelsFromFmt();
data->cparams.format.format=format;
if(snd_pcm_plugin_params(data->pcmHandle, &data->cparams) < 0)
@@ -822,7 +817,7 @@ static ALCuint qsa_available_samples(CaptureWrapper *self)
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
qsa_data *data = self->ExtraData.get();
snd_pcm_channel_status_t status;
- ALint frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ ALint frame_size = device->frameSizeFromFmt();
ALint free_size;
int rstatus;
@@ -859,7 +854,7 @@ static ALCenum qsa_capture_samples(CaptureWrapper *self, ALCvoid *buffer, ALCuin
int selectret;
struct timeval timeout;
int bytes_read;
- ALint frame_size=FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ ALint frame_size=device->frameSizeFromFmt();
ALint len=samples*frame_size;
int rstatus;
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index d643faa3..f0c98fab 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -73,7 +73,7 @@ static void ALCsdl2Backend_Construct(ALCsdl2Backend *self, ALCdevice *device)
SET_VTABLE2(ALCsdl2Backend, ALCbackend, self);
self->deviceID = 0;
- self->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->frameSize = device->frameSizeFromFmt();
self->Frequency = device->Frequency;
self->FmtChans = device->FmtChans;
self->FmtType = device->FmtType;
@@ -168,7 +168,7 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
device->UpdateSize = have.samples;
device->NumUpdates = 2; /* SDL always (tries to) use two periods. */
- self->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ self->frameSize = device->frameSizeFromFmt();
self->Frequency = device->Frequency;
self->FmtChans = device->FmtChans;
self->FmtType = device->FmtType;
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index 1dabe5ca..9ebad671 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -97,7 +97,7 @@ static int SndioPlayback_mixerProc(SndioPlayback *self)
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frameSize = device->frameSizeFromFmt();
while(!self->mKillNow.load(std::memory_order_acquire) &&
device->Connected.load(std::memory_order_acquire))
@@ -238,9 +238,7 @@ static ALCboolean SndioPlayback_start(SndioPlayback *self)
{
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
- self->data_size = device->UpdateSize * FrameSizeFromDevFmt(
- device->FmtChans, device->FmtType, device->mAmbiOrder
- );
+ self->data_size = device->UpdateSize * device->frameSizeFromFmt();
al_free(self->mix_data);
self->mix_data = al_calloc(16, self->data_size);
@@ -334,7 +332,7 @@ static int SndioCapture_recordProc(SndioCapture *self)
SetRTPriority();
althrd_setname(RECORD_THREAD_NAME);
- frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frameSize = device->frameSizeFromFmt();
while(!self->mKillNow.load(std::memory_order_acquire) &&
device->Connected.load(std::memory_order_acquire))
@@ -433,7 +431,7 @@ static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name)
par.bits = par.bps * 8;
par.le = SIO_LE_NATIVE;
par.msb = SIO_LE_NATIVE ? 0 : 1;
- par.rchan = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ par.rchan = device->channelsFromFmt();
par.rate = device->Frequency;
par.appbufsz = maxu(device->UpdateSize*device->NumUpdates, (device->Frequency+9)/10);
@@ -461,7 +459,7 @@ static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name)
(device->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) ||
(device->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) ||
(device->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) ||
- ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder) != (ALsizei)par.rchan ||
+ device->channelsFromFmt() != (ALsizei)par.rchan ||
device->Frequency != par.rate)
{
ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead\n",
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index 941ca015..8871fb93 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -114,7 +114,7 @@ static int ALCsolarisBackend_mixerProc(ALCsolarisBackend *self)
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder);
+ frame_size = device->frameSizeFromFmt();
ALCsolarisBackend_lock(self);
while(!self->mKillNow.load(std::memory_order_acquire) &&
@@ -203,7 +203,7 @@ static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self)
if(device->FmtChans != DevFmtMono)
device->FmtChans = DevFmtStereo;
- numChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ numChannels = device->channelsFromFmt();
info.play.channels = numChannels;
switch(device->FmtType)
@@ -228,7 +228,7 @@ static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self)
break;
}
- frameSize = numChannels * BytesFromDevFmt(device->FmtType);
+ frameSize = numChannels * device->bytesFromFmt();
info.play.buffer_size = device->UpdateSize*device->NumUpdates * frameSize;
if(ioctl(self->fd, AUDIO_SETINFO, &info) < 0)
@@ -237,9 +237,10 @@ static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self)
return ALC_FALSE;
}
- if(ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder) != (ALsizei)info.play.channels)
+ if(device->channelsFromFmt() != (ALsizei)info.play.channels)
{
- ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans), info.play.channels);
+ ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(device->FmtChans),
+ info.play.channels);
return ALC_FALSE;
}
@@ -259,9 +260,7 @@ static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self)
SetDefaultChannelOrder(device);
free(self->mix_data);
- self->data_size = device->UpdateSize * FrameSizeFromDevFmt(
- device->FmtChans, device->FmtType, device->mAmbiOrder
- );
+ self->data_size = device->UpdateSize * device->frameSizeFromFmt();
self->mix_data = static_cast<ALubyte*>(calloc(1, self->data_size));
return ALC_TRUE;
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index b928682f..79e4af04 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -1301,8 +1301,7 @@ FORCE_ALIGN int ALCwasapiCapture_recordProc(ALCwasapiCapture *self)
}
else
{
- ALuint framesize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType,
- device->mAmbiOrder);
+ const auto framesize = static_cast<ALuint>(device->frameSizeFromFmt());
size_t len1 = minz(data.first.len, numsamples);
size_t len2 = minz(data.second.len, numsamples-len1);
@@ -1665,8 +1664,8 @@ HRESULT ALCwasapiCapture::resetProxy()
if(device->Frequency != OutputType.Format.nSamplesPerSec || device->FmtType != srcType)
{
mSampleConv = CreateSampleConverter(
- srcType, device->FmtType, ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder),
- OutputType.Format.nSamplesPerSec, device->Frequency, BSinc24Resampler
+ srcType, device->FmtType, device->channelsFromFmt(), OutputType.Format.nSamplesPerSec,
+ device->Frequency, BSinc24Resampler
);
if(!mSampleConv)
{
@@ -1698,10 +1697,7 @@ HRESULT ALCwasapiCapture::resetProxy()
buffer_len = maxu(device->UpdateSize*device->NumUpdates, buffer_len);
ll_ringbuffer_free(mRing);
- mRing = ll_ringbuffer_create(buffer_len,
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder),
- false
- );
+ mRing = ll_ringbuffer_create(buffer_len, device->frameSizeFromFmt(), false);
if(!mRing)
{
ERR("Failed to allocate capture ring buffer\n");
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index afa948cb..463e6bd7 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -130,7 +130,7 @@ int ALCwaveBackend_mixerProc(ALCwaveBackend *self)
althrd_setname(MIXER_THREAD_NAME);
- ALsizei frameSize{FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder)};
+ const ALsizei frameSize{device->frameSizeFromFmt()};
ALint64 done{0};
auto start = std::chrono::steady_clock::now();
@@ -155,7 +155,7 @@ int ALCwaveBackend_mixerProc(ALCwaveBackend *self)
if(!IS_LITTLE_ENDIAN)
{
- const ALsizei bytesize{BytesFromDevFmt(device->FmtType)};
+ const ALsizei bytesize{device->bytesFromFmt()};
ALsizei i;
if(bytesize == 2)
@@ -284,14 +284,15 @@ ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self)
case DevFmtX71: chanmask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x200 | 0x400; break;
case DevFmtAmbi3D:
/* .amb output requires FuMa */
+ device->mAmbiOrder = mini(device->mAmbiOrder, 3);
device->mAmbiLayout = AmbiLayout::FuMa;
device->mAmbiScale = AmbiNorm::FuMa;
isbformat = 1;
chanmask = 0;
break;
}
- bits = BytesFromDevFmt(device->FmtType) * 8;
- channels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
+ bits = device->bytesFromFmt() * 8;
+ channels = device->channelsFromFmt();
fputs("RIFF", self->mFile);
fwrite32le(0xFFFFFFFF, self->mFile); // 'RIFF' header len; filled in at close
@@ -337,9 +338,7 @@ ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self)
SetDefaultWFXChannelOrder(device);
- ALuint bufsize{FrameSizeFromDevFmt(
- device->FmtChans, device->FmtType, device->mAmbiOrder
- ) * device->UpdateSize};
+ const ALuint bufsize{device->frameSizeFromFmt() * device->UpdateSize};
self->mBuffer.resize(bufsize);
return ALC_TRUE;
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index ff5d026c..362b2e5e 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -336,8 +336,7 @@ ALCboolean ALCwinmmPlayback_reset(ALCwinmmPlayback *self)
}
SetDefaultWFXChannelOrder(device);
- ALuint BufferSize{device->UpdateSize *
- FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->mAmbiOrder)};
+ ALuint BufferSize{device->UpdateSize * device->frameSizeFromFmt()};
al_free(self->WaveBuffer[0].lpData);
self->WaveBuffer[0] = WAVEHDR{};
@@ -558,8 +557,8 @@ ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *deviceName)
self->Format = WAVEFORMATEX{};
self->Format.wFormatTag = (device->FmtType == DevFmtFloat) ?
WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM;
- self->Format.nChannels = ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder);
- self->Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8;
+ self->Format.nChannels = device->channelsFromFmt();
+ self->Format.wBitsPerSample = device->bytesFromFmt() * 8;
self->Format.nBlockAlign = self->Format.wBitsPerSample *
self->Format.nChannels / 8;
self->Format.nSamplesPerSec = device->Frequency;