aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-02-17 17:13:00 -0800
committerChris Robinson <[email protected]>2020-02-17 17:13:25 -0800
commit3122c3b4a109b7d6e288bdde055fc4bbae5517bc (patch)
treeb2eb3a251a243d3a5f9a7566c343bc614c9ff8cc /al
parentc8dfd248185359d86410340741122943524ed10b (diff)
Handle running the buffer callback in the voice
Diffstat (limited to 'al')
-rw-r--r--al/buffer.cpp7
-rw-r--r--al/buffer.h2
-rw-r--r--al/source.cpp4
3 files changed, 6 insertions, 7 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index b2543434..96c6b4fc 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -594,11 +594,8 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
if UNLIKELY(static_cast<long>(SrcType) != static_cast<long>(DstType))
SETERR_RETURN(context, AL_INVALID_ENUM,, "Unsupported callback format");
- if(!ALBuf->mData.empty())
- {
- ALBuf->mData.clear();
- ALBuf->mData.shrink_to_fit();
- }
+ ALBuf->mData = al::vector<al::byte,16>(FrameSizeFromFmt(DstChannels, DstType) *
+ size_t{BUFFERSIZE + (MAX_RESAMPLER_PADDING>>1)});
ALBuf->Callback = callback;
ALBuf->UserData = userptr;
diff --git a/al/buffer.h b/al/buffer.h
index d1c3c747..61ae1863 100644
--- a/al/buffer.h
+++ b/al/buffer.h
@@ -61,6 +61,8 @@ enum FmtChannels : unsigned char {
ALuint BytesFromFmt(FmtType type) noexcept;
ALuint ChannelsFromFmt(FmtChannels chans) noexcept;
+inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type) noexcept
+{ return ChannelsFromFmt(chans) * BytesFromFmt(type); }
struct ALbuffer {
diff --git a/al/source.cpp b/al/source.cpp
index bc850a6d..d456401c 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -2764,9 +2764,8 @@ START_API_FUNC
assert(voice != voices_end);
auto vidx = static_cast<ALuint>(std::distance(context->mVoices.data(), voice));
- voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release);
- source->PropsClean.test_and_set(std::memory_order_acquire);
+ source->PropsClean.test_and_set(std::memory_order_acq_rel);
UpdateSourceProps(source, voice, context.get());
/* A source that's not playing or paused has any offset applied when it
@@ -2804,6 +2803,7 @@ START_API_FUNC
voice->mFlags = start_fading ? VOICE_IS_FADING : 0;
if(source->SourceType == AL_STATIC) voice->mFlags |= VOICE_IS_STATIC;
+ voice->mNumCallbackSamples = 0;
/* Don't need to set the VOICE_IS_AMBISONIC flag if the device is not
* higher order than the voice. No HF scaling is necessary to mix it.