aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--al/effects/chorus.cpp4
-rw-r--r--al/effects/fshifter.cpp4
-rw-r--r--al/effects/modulator.cpp2
-rw-r--r--al/effects/vmorpher.cpp6
-rw-r--r--al/source.cpp146
-rw-r--r--alc/alu.cpp12
-rw-r--r--alc/backends/oss.cpp14
-rw-r--r--alc/backends/portaudio.cpp17
-rw-r--r--alc/backends/pulseaudio.cpp5
-rw-r--r--alc/backends/sndio.cpp131
-rw-r--r--examples/alconvolve.c15
-rw-r--r--examples/alffplay.cpp3
-rw-r--r--examples/almultireverb.c6
-rw-r--r--examples/alstream.c9
-rw-r--r--examples/alstreamcb.cpp4
-rw-r--r--utils/makemhr/loaddef.cpp6
16 files changed, 190 insertions, 194 deletions
diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp
index dba59d1d..913d1215 100644
--- a/al/effects/chorus.cpp
+++ b/al/effects/chorus.cpp
@@ -49,7 +49,7 @@ inline ALenum EnumFromWaveform(ChorusWaveform type)
EffectProps genDefaultChorusProps() noexcept
{
ChorusProps props{};
- props.Waveform = *WaveformFromEnum(AL_CHORUS_DEFAULT_WAVEFORM);
+ props.Waveform = WaveformFromEnum(AL_CHORUS_DEFAULT_WAVEFORM).value();
props.Phase = AL_CHORUS_DEFAULT_PHASE;
props.Rate = AL_CHORUS_DEFAULT_RATE;
props.Depth = AL_CHORUS_DEFAULT_DEPTH;
@@ -61,7 +61,7 @@ EffectProps genDefaultChorusProps() noexcept
EffectProps genDefaultFlangerProps() noexcept
{
FlangerProps props{};
- props.Waveform = *WaveformFromEnum(AL_FLANGER_DEFAULT_WAVEFORM);
+ props.Waveform = WaveformFromEnum(AL_FLANGER_DEFAULT_WAVEFORM).value();
props.Phase = AL_FLANGER_DEFAULT_PHASE;
props.Rate = AL_FLANGER_DEFAULT_RATE;
props.Depth = AL_FLANGER_DEFAULT_DEPTH;
diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp
index 6f19e0dd..556244ac 100644
--- a/al/effects/fshifter.cpp
+++ b/al/effects/fshifter.cpp
@@ -45,8 +45,8 @@ EffectProps genDefaultProps() noexcept
{
FshifterProps props{};
props.Frequency = AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY;
- props.LeftDirection = *DirectionFromEmum(AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION);
- props.RightDirection = *DirectionFromEmum(AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION);
+ props.LeftDirection = DirectionFromEmum(AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION).value();
+ props.RightDirection = DirectionFromEmum(AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION).value();
return props;
}
diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp
index 566b333e..7e9424c0 100644
--- a/al/effects/modulator.cpp
+++ b/al/effects/modulator.cpp
@@ -47,7 +47,7 @@ EffectProps genDefaultProps() noexcept
ModulatorProps props{};
props.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
props.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF;
- props.Waveform = *WaveformFromEmum(AL_RING_MODULATOR_DEFAULT_WAVEFORM);
+ props.Waveform = WaveformFromEmum(AL_RING_MODULATOR_DEFAULT_WAVEFORM).value();
return props;
}
diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp
index a986ddf7..35a64d32 100644
--- a/al/effects/vmorpher.cpp
+++ b/al/effects/vmorpher.cpp
@@ -126,11 +126,11 @@ EffectProps genDefaultProps() noexcept
{
VmorpherProps props{};
props.Rate = AL_VOCAL_MORPHER_DEFAULT_RATE;
- props.PhonemeA = *PhenomeFromEnum(AL_VOCAL_MORPHER_DEFAULT_PHONEMEA);
- props.PhonemeB = *PhenomeFromEnum(AL_VOCAL_MORPHER_DEFAULT_PHONEMEB);
+ props.PhonemeA = PhenomeFromEnum(AL_VOCAL_MORPHER_DEFAULT_PHONEMEA).value();
+ props.PhonemeB = PhenomeFromEnum(AL_VOCAL_MORPHER_DEFAULT_PHONEMEB).value();
props.PhonemeACoarseTuning = AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING;
props.PhonemeBCoarseTuning = AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING;
- props.Waveform = *WaveformFromEmum(AL_VOCAL_MORPHER_DEFAULT_WAVEFORM);
+ props.Waveform = WaveformFromEmum(AL_VOCAL_MORPHER_DEFAULT_WAVEFORM).value();
return props;
}
diff --git a/al/source.cpp b/al/source.cpp
index a440a04b..bf96a769 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -3407,90 +3407,94 @@ FORCE_ALIGN void AL_APIENTRY alSourceQueueBuffersDirect(ALCcontext *context, ALu
std::unique_lock<std::mutex> buflock{device->BufferLock};
const size_t NewListStart{source->mQueue.size()};
- ALbufferQueueItem *BufferList{nullptr};
- for(ALsizei i{0};i < nb;i++)
- {
- bool fmt_mismatch{false};
- ALbuffer *buffer{buffers[i] ? LookupBuffer(device, buffers[i]) : nullptr};
- if(buffers[i] && !buffer)
- {
- context->setError(AL_INVALID_NAME, "Queueing invalid buffer ID %u", buffers[i]);
- goto buffer_error;
- }
- if(buffer)
+ try {
+ ALbufferQueueItem *BufferList{nullptr};
+ for(ALsizei i{0};i < nb;i++)
{
- if(buffer->mSampleRate < 1)
+ bool fmt_mismatch{false};
+ ALbuffer *buffer{buffers[i] ? LookupBuffer(device, buffers[i]) : nullptr};
+ if(buffers[i] && !buffer)
{
- context->setError(AL_INVALID_OPERATION, "Queueing buffer %u with no format",
- buffer->id);
- goto buffer_error;
+ context->setError(AL_INVALID_NAME, "Queueing invalid buffer ID %u", buffers[i]);
+ throw std::exception{};
}
- if(buffer->mCallback)
+ if(buffer)
{
- context->setError(AL_INVALID_OPERATION, "Queueing callback buffer %u", buffer->id);
- goto buffer_error;
+ if(buffer->mSampleRate < 1)
+ {
+ context->setError(AL_INVALID_OPERATION, "Queueing buffer %u with no format",
+ buffer->id);
+ throw std::exception{};
+ }
+ if(buffer->mCallback)
+ {
+ context->setError(AL_INVALID_OPERATION, "Queueing callback buffer %u",
+ buffer->id);
+ throw std::exception{};
+ }
+ if(buffer->MappedAccess != 0 && !(buffer->MappedAccess&AL_MAP_PERSISTENT_BIT_SOFT))
+ {
+ context->setError(AL_INVALID_OPERATION,
+ "Queueing non-persistently mapped buffer %u", buffer->id);
+ throw std::exception{};
+ }
}
- if(buffer->MappedAccess != 0 && !(buffer->MappedAccess&AL_MAP_PERSISTENT_BIT_SOFT))
+
+ source->mQueue.emplace_back();
+ if(!BufferList)
+ BufferList = &source->mQueue.back();
+ else
{
- context->setError(AL_INVALID_OPERATION,
- "Queueing non-persistently mapped buffer %u", buffer->id);
- goto buffer_error;
+ auto &item = source->mQueue.back();
+ BufferList->mNext.store(&item, std::memory_order_relaxed);
+ BufferList = &item;
}
- }
-
- source->mQueue.emplace_back();
- if(!BufferList)
- BufferList = &source->mQueue.back();
- else
- {
- auto &item = source->mQueue.back();
- BufferList->mNext.store(&item, std::memory_order_relaxed);
- BufferList = &item;
- }
- if(!buffer) continue;
- BufferList->mBlockAlign = buffer->mBlockAlign;
- BufferList->mSampleLen = buffer->mSampleLen;
- BufferList->mLoopEnd = buffer->mSampleLen;
- BufferList->mSamples = buffer->mData.data();
- BufferList->mBuffer = buffer;
- IncrementRef(buffer->ref);
-
- if(BufferFmt == nullptr)
- BufferFmt = buffer;
- else
- {
- fmt_mismatch |= BufferFmt->mSampleRate != buffer->mSampleRate;
- fmt_mismatch |= BufferFmt->mChannels != buffer->mChannels;
- fmt_mismatch |= BufferFmt->mType != buffer->mType;
- if(BufferFmt->isBFormat())
+ if(!buffer) continue;
+ BufferList->mBlockAlign = buffer->mBlockAlign;
+ BufferList->mSampleLen = buffer->mSampleLen;
+ BufferList->mLoopEnd = buffer->mSampleLen;
+ BufferList->mSamples = buffer->mData.data();
+ BufferList->mBuffer = buffer;
+ IncrementRef(buffer->ref);
+
+ if(BufferFmt == nullptr)
+ BufferFmt = buffer;
+ else
{
- fmt_mismatch |= BufferFmt->mAmbiLayout != buffer->mAmbiLayout;
- fmt_mismatch |= BufferFmt->mAmbiScaling != buffer->mAmbiScaling;
+ fmt_mismatch |= BufferFmt->mSampleRate != buffer->mSampleRate;
+ fmt_mismatch |= BufferFmt->mChannels != buffer->mChannels;
+ fmt_mismatch |= BufferFmt->mType != buffer->mType;
+ if(BufferFmt->isBFormat())
+ {
+ fmt_mismatch |= BufferFmt->mAmbiLayout != buffer->mAmbiLayout;
+ fmt_mismatch |= BufferFmt->mAmbiScaling != buffer->mAmbiScaling;
+ }
+ fmt_mismatch |= BufferFmt->mAmbiOrder != buffer->mAmbiOrder;
}
- fmt_mismatch |= BufferFmt->mAmbiOrder != buffer->mAmbiOrder;
- }
- if(fmt_mismatch) UNLIKELY
- {
- context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format\n"
- " Expected: %uhz, %s, %s ; Got: %uhz, %s, %s\n", BufferFmt->mSampleRate,
- NameFromFormat(BufferFmt->mType), NameFromFormat(BufferFmt->mChannels),
- buffer->mSampleRate, NameFromFormat(buffer->mType),
- NameFromFormat(buffer->mChannels));
-
- buffer_error:
- /* A buffer failed (invalid ID or format), so unlock and release
- * each buffer we had.
- */
- auto iter = source->mQueue.begin() + ptrdiff_t(NewListStart);
- for(;iter != source->mQueue.end();++iter)
+ if(fmt_mismatch) UNLIKELY
{
- if(ALbuffer *buf{iter->mBuffer})
- DecrementRef(buf->ref);
+ context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format\n"
+ " Expected: %uhz, %s, %s ; Got: %uhz, %s, %s\n", BufferFmt->mSampleRate,
+ NameFromFormat(BufferFmt->mType), NameFromFormat(BufferFmt->mChannels),
+ buffer->mSampleRate, NameFromFormat(buffer->mType),
+ NameFromFormat(buffer->mChannels));
+ throw std::exception{};
}
- source->mQueue.resize(NewListStart);
- return;
}
}
+ catch(...) {
+ /* A buffer failed (invalid ID or format), or there was some other
+ * unexpected error, so unlock and release each buffer we had.
+ */
+ auto iter = source->mQueue.begin() + ptrdiff_t(NewListStart);
+ for(;iter != source->mQueue.end();++iter)
+ {
+ if(ALbuffer *buf{iter->mBuffer})
+ DecrementRef(buf->ref);
+ }
+ source->mQueue.resize(NewListStart);
+ return;
+ }
/* All buffers good. */
buflock.unlock();
diff --git a/alc/alu.cpp b/alc/alu.cpp
index eb3dee5f..9e7a758e 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -678,16 +678,16 @@ void AmbiRotator(AmbiRotateMatrix &matrix, const int order)
auto P = [](const int i, const int l, const int a, const int n, const size_t last_band,
const AmbiRotateMatrix &R)
{
- const float ri1{ R[ 1+2][static_cast<size_t>(i+2)]};
- const float rim1{R[-1+2][static_cast<size_t>(i+2)]};
- const float ri0{ R[ 0+2][static_cast<size_t>(i+2)]};
+ const float ri1{ R[ 1+2][static_cast<size_t>(i+2_z)]};
+ const float rim1{R[-1+2][static_cast<size_t>(i+2_z)]};
+ const float ri0{ R[ 0+2][static_cast<size_t>(i+2_z)]};
const size_t y{last_band + static_cast<size_t>(a+l-1)};
if(n == -l)
- return ri1*R[last_band][y] + rim1*R[last_band + static_cast<size_t>(l-1)*2][y];
+ return ri1*R[last_band][y] + rim1*R[last_band + static_cast<size_t>(l-1_z)*2][y];
if(n == l)
- return ri1*R[last_band + static_cast<size_t>(l-1)*2][y] - rim1*R[last_band][y];
- return ri0*R[last_band + static_cast<size_t>(n+l-1)][y];
+ return ri1*R[last_band + static_cast<size_t>(l-1_z)*2][y] - rim1*R[last_band][y];
+ return ri0*R[last_band + static_cast<size_t>(l-1_z+n)][y];
};
auto U = [P](const int l, const int m, const int n, const size_t last_band,
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index 50bed5ee..d541b534 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -367,11 +367,9 @@ bool OSSPlayback::reset()
uint numFragmentsLogSize{(periods << 16) | log2FragmentSize};
audio_buf_info info{};
- const char *err;
-#define CHECKERR(func) if((func) < 0) { \
- err = #func; \
- goto err; \
-}
+#define CHECKERR(func) if((func) < 0) \
+ throw al::backend_exception{al::backend_error::DeviceError, "%s failed: %s\n", #func, strerror(errno)};
+
/* Don't fail if SETFRAGMENT fails. We can handle just about anything
* that's reported back via GETOSPACE */
ioctl(mFd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize);
@@ -379,12 +377,6 @@ bool OSSPlayback::reset()
CHECKERR(ioctl(mFd, SNDCTL_DSP_CHANNELS, &numChannels));
CHECKERR(ioctl(mFd, SNDCTL_DSP_SPEED, &ossSpeed));
CHECKERR(ioctl(mFd, SNDCTL_DSP_GETOSPACE, &info));
- if(false)
- {
- err:
- ERR("%s failed: %s\n", err, strerror(errno));
- return false;
- }
#undef CHECKERR
if(mDevice->channelsFromFmt() != numChannels)
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 2ccb1c64..a8bd00fd 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -148,7 +148,6 @@ void PortPlayback::open(std::string_view name)
break;
}
-retry_open:
static constexpr auto writeCallback = [](const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo,
const PaStreamCallbackFlags statusFlags, void *userData) noexcept
@@ -157,17 +156,13 @@ retry_open:
framesPerBuffer, timeInfo, statusFlags);
};
PaStream *stream{};
- PaError err{Pa_OpenStream(&stream, nullptr, &params, mDevice->Frequency, mDevice->UpdateSize,
- paNoFlag, writeCallback, this)};
- if(err != paNoError)
+ while(PaError err{Pa_OpenStream(&stream, nullptr, &params, mDevice->Frequency,
+ mDevice->UpdateSize, paNoFlag, writeCallback, this)})
{
- if(params.sampleFormat == paFloat32)
- {
- params.sampleFormat = paInt16;
- goto retry_open;
- }
- throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
- Pa_GetErrorText(err)};
+ if(params.sampleFormat != paFloat32)
+ throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
+ Pa_GetErrorText(err)};
+ params.sampleFormat = paInt16;
}
Pa_CloseStream(mStream);
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index dcf01095..77d45466 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -968,8 +968,9 @@ bool PulsePlayback::reset()
const auto scale = static_cast<double>(mSpec.rate) / mDevice->Frequency;
const auto perlen = static_cast<uint>(clampd(scale*mDevice->UpdateSize + 0.5, 64.0,
8192.0));
- const auto buflen = static_cast<uint>(clampd(scale*mDevice->BufferSize + 0.5, perlen*2,
- std::numeric_limits<int>::max()/mFrameSize));
+ const auto bufmax = uint{std::numeric_limits<int>::max() / mFrameSize};
+ const auto buflen = static_cast<uint>(clampd(scale*mDevice->BufferSize + 0.5, perlen*2.0,
+ bufmax));
mAttr.maxlength = ~0u;
mAttr.tlength = buflen * mFrameSize;
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index 0e667874..ce3de366 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -135,72 +135,75 @@ bool SndioPlayback::reset()
SioPar par;
auto tryfmt = mDevice->FmtType;
-retry_params:
- switch(tryfmt)
+ while(true)
{
- case DevFmtByte:
- par.bits = 8;
- par.sig = 1;
- break;
- case DevFmtUByte:
- par.bits = 8;
- par.sig = 0;
- break;
- case DevFmtShort:
- par.bits = 16;
- par.sig = 1;
- break;
- case DevFmtUShort:
- par.bits = 16;
- par.sig = 0;
- break;
- case DevFmtFloat:
- case DevFmtInt:
- par.bits = 32;
- par.sig = 1;
- break;
- case DevFmtUInt:
- par.bits = 32;
- par.sig = 0;
- break;
- }
- par.bps = SIO_BPS(par.bits);
- par.le = SIO_LE_NATIVE;
- par.msb = 1;
-
- par.rate = mDevice->Frequency;
- par.pchan = mDevice->channelsFromFmt();
-
- par.round = mDevice->UpdateSize;
- par.appbufsz = mDevice->BufferSize - mDevice->UpdateSize;
- if(!par.appbufsz) par.appbufsz = mDevice->UpdateSize;
+ switch(tryfmt)
+ {
+ case DevFmtByte:
+ par.bits = 8;
+ par.sig = 1;
+ break;
+ case DevFmtUByte:
+ par.bits = 8;
+ par.sig = 0;
+ break;
+ case DevFmtShort:
+ par.bits = 16;
+ par.sig = 1;
+ break;
+ case DevFmtUShort:
+ par.bits = 16;
+ par.sig = 0;
+ break;
+ case DevFmtFloat:
+ case DevFmtInt:
+ par.bits = 32;
+ par.sig = 1;
+ break;
+ case DevFmtUInt:
+ par.bits = 32;
+ par.sig = 0;
+ break;
+ }
+ par.bps = SIO_BPS(par.bits);
+ par.le = SIO_LE_NATIVE;
+ par.msb = 1;
+
+ par.rate = mDevice->Frequency;
+ par.pchan = mDevice->channelsFromFmt();
+
+ par.round = mDevice->UpdateSize;
+ par.appbufsz = mDevice->BufferSize - mDevice->UpdateSize;
+ if(!par.appbufsz) par.appbufsz = mDevice->UpdateSize;
+
+ try {
+ if(!sio_setpar(mSndHandle, &par))
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "Failed to set device parameters"};
+
+ par.clear();
+ if(!sio_getpar(mSndHandle, &par))
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "Failed to get device parameters"};
+
+ if(par.bps > 1 && par.le != SIO_LE_NATIVE)
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "%s-endian samples not supported", par.le ? "Little" : "Big"};
+ if(par.bits < par.bps*8 && !par.msb)
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "MSB-padded samples not supported (%u of %u bits)", par.bits, par.bps*8};
+ if(par.pchan < 1)
+ throw al::backend_exception{al::backend_error::DeviceError,
+ "No playback channels on device"};
- try {
- if(!sio_setpar(mSndHandle, &par))
- throw al::backend_exception{al::backend_error::DeviceError,
- "Failed to set device parameters"};
-
- par.clear();
- if(!sio_getpar(mSndHandle, &par))
- throw al::backend_exception{al::backend_error::DeviceError,
- "Failed to get device parameters"};
-
- if(par.bps > 1 && par.le != SIO_LE_NATIVE)
- throw al::backend_exception{al::backend_error::DeviceError,
- "%s-endian samples not supported", par.le ? "Little" : "Big"};
- if(par.bits < par.bps*8 && !par.msb)
- throw al::backend_exception{al::backend_error::DeviceError,
- "MSB-padded samples not supported (%u of %u bits)", par.bits, par.bps*8};
- if(par.pchan < 1)
- throw al::backend_exception{al::backend_error::DeviceError,
- "No playback channels on device"};
- }
- catch(al::backend_exception &e) {
- if(tryfmt == DevFmtShort)
- throw;
- par.clear();
- tryfmt = DevFmtShort;
- goto retry_params;
+ break;
+ }
+ catch(al::backend_exception &e) {
+ if(tryfmt == DevFmtShort)
+ throw;
+ par.clear();
+ tryfmt = DevFmtShort;
+ }
}
if(par.bps == 1)
diff --git a/examples/alconvolve.c b/examples/alconvolve.c
index d194d270..597d6ea2 100644
--- a/examples/alconvolve.c
+++ b/examples/alconvolve.c
@@ -361,10 +361,10 @@ static ALuint LoadSound(const char *filename)
}
namepart = strrchr(filename, '/');
- if(namepart || (namepart=strrchr(filename, '\\')))
- namepart++;
- else
- namepart = filename;
+ if(!namepart) namepart = strrchr(filename, '\\');
+ if(!namepart) namepart = filename;
+ else namepart++;
+
printf("Loading: %s (%s, %dhz, %" PRId64 " samples / %.2f seconds)\n", namepart,
FormatName(format), sfinfo.samplerate, sfinfo.frames,
(double)sfinfo.frames / sfinfo.samplerate);
@@ -557,10 +557,9 @@ int main(int argc, char **argv)
continue;
namepart = strrchr(argv[i], '/');
- if(namepart || (namepart=strrchr(argv[i], '\\')))
- namepart++;
- else
- namepart = argv[i];
+ if(!namepart) namepart = strrchr(argv[i], '\\');
+ if(!namepart) namepart = argv[i];
+ else namepart++;
printf("Playing: %s (%s, %dhz)\n", namepart, FormatName(player->format),
player->sfinfo.samplerate);
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp
index a7633bfa..cfbe5564 100644
--- a/examples/alffplay.cpp
+++ b/examples/alffplay.cpp
@@ -1297,7 +1297,7 @@ int AudioState::handler()
mSamplesLen = decodeFrame();
mSamplesPos = mSamplesLen;
} while(mSamplesLen > 0);
- goto finish;
+ break;
}
ALenum state;
@@ -1378,7 +1378,6 @@ int AudioState::handler()
mSrcCond.wait_for(srclock, sleep_time);
}
-finish:
alSourceRewind(mSource);
alSourcei(mSource, AL_BUFFER, 0);
diff --git a/examples/almultireverb.c b/examples/almultireverb.c
index d1deae5a..f9a46c4f 100644
--- a/examples/almultireverb.c
+++ b/examples/almultireverb.c
@@ -108,7 +108,8 @@ static int LoadEffect(ALuint effect, const EFXEAXREVERBPROPERTIES *reverb)
* the needed panning vectors).
*/
alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
- if((err=alGetError()) != AL_NO_ERROR)
+ err = alGetError();
+ if(err != AL_NO_ERROR)
{
fprintf(stderr, "Failed to set EAX Reverb: %s (0x%04x)\n", alGetString(err), err);
return 0;
@@ -140,7 +141,8 @@ static int LoadEffect(ALuint effect, const EFXEAXREVERBPROPERTIES *reverb)
alEffecti(effect, AL_EAXREVERB_DECAY_HFLIMIT, reverb->iDecayHFLimit);
/* Check if an error occurred, and return failure if so. */
- if((err=alGetError()) != AL_NO_ERROR)
+ err = alGetError();
+ if(err != AL_NO_ERROR)
{
fprintf(stderr, "Error setting up reverb: %s\n", alGetString(err));
return 0;
diff --git a/examples/alstream.c b/examples/alstream.c
index c781f3d7..028290f5 100644
--- a/examples/alstream.c
+++ b/examples/alstream.c
@@ -294,7 +294,7 @@ static int OpenPlayerFile(StreamPlayer *player, const char *filename)
player->block_count = player->sfinfo.samplerate / player->sampleblockalign;
player->block_count = player->block_count * BufferMillisec / 1000;
- player->membuf = malloc((size_t)(player->block_count * player->byteblockalign));
+ player->membuf = malloc((size_t)player->block_count * (size_t)player->byteblockalign);
return 1;
}
@@ -488,10 +488,9 @@ int main(int argc, char **argv)
/* Get the name portion, without the path, for display. */
namepart = strrchr(argv[i], '/');
- if(namepart || (namepart=strrchr(argv[i], '\\')))
- namepart++;
- else
- namepart = argv[i];
+ if(!namepart) namepart = strrchr(argv[i], '\\');
+ if(!namepart) namepart = argv[i];
+ else namepart++;
printf("Playing: %s (%s, %dhz)\n", namepart, FormatName(player->format),
player->sfinfo.samplerate);
diff --git a/examples/alstreamcb.cpp b/examples/alstreamcb.cpp
index 2da33b21..ebf3d3b0 100644
--- a/examples/alstreamcb.cpp
+++ b/examples/alstreamcb.cpp
@@ -195,12 +195,12 @@ struct StreamPlayer {
if(mSampleFormat == SampleType::Int16)
{
mSamplesPerBlock = 1;
- mBytesPerBlock = static_cast<size_t>(mSfInfo.channels * 2);
+ mBytesPerBlock = static_cast<size_t>(mSfInfo.channels) * 2;
}
else if(mSampleFormat == SampleType::Float)
{
mSamplesPerBlock = 1;
- mBytesPerBlock = static_cast<size_t>(mSfInfo.channels * 4);
+ mBytesPerBlock = static_cast<size_t>(mSfInfo.channels) * 4;
}
else
{
diff --git a/utils/makemhr/loaddef.cpp b/utils/makemhr/loaddef.cpp
index b33dbc75..05bcfd2e 100644
--- a/utils/makemhr/loaddef.cpp
+++ b/utils/makemhr/loaddef.cpp
@@ -907,7 +907,8 @@ static int ReadWaveList(std::istream &istream, const SourceRefT *src, const Byte
fprintf(stderr, "\nError: Bad read from file '%s'.\n", src->mPath.data());
return 0;
}
- istream.seekg(static_cast<long>(src->mOffset * block), std::ios::cur);
+ using off_type = std::istream::off_type;
+ istream.seekg(off_type(src->mOffset) * off_type(block), std::ios::cur);
if(!ReadWaveData(istream, src, order, n, &hrir[0]))
return 0;
return 1;
@@ -939,7 +940,8 @@ static int ReadWaveList(std::istream &istream, const SourceRefT *src, const Byte
count = chunkSize / block;
if(count > skip)
{
- istream.seekg(static_cast<long>(skip * block), std::ios::cur);
+ using off_type = std::istream::off_type;
+ istream.seekg(off_type(skip) * off_type(block), std::ios::cur);
chunkSize -= skip * block;
count -= skip;
skip = 0;