aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-01 00:32:27 -0800
committerChris Robinson <[email protected]>2018-01-01 00:32:27 -0800
commitdad17a7d91fb60d8a854fa86933f002d413258de (patch)
tree0be0086f4c4c3ca1d99c267d852d8da707b23f11
parent830adf6ae8c2eaf50da6318950d123f28718327e (diff)
Use a std::array for the buffers in alffplay
-rw-r--r--examples/alffplay.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp
index e414c4f8..6d92cdba 100644
--- a/examples/alffplay.cpp
+++ b/examples/alffplay.cpp
@@ -150,19 +150,18 @@ struct AudioState {
std::recursive_mutex mSrcMutex;
ALuint mSource{0};
- ALuint mBuffers[AUDIO_BUFFER_QUEUE_SIZE];
+ std::array<ALuint,AUDIO_BUFFER_QUEUE_SIZE> mBuffers;
ALsizei mBufferIdx{0};
AudioState(MovieState &movie) : mMovie(movie)
{
- for(auto &buf : mBuffers)
- buf = 0;
+ std::fill(mBuffers.begin(), mBuffers.end(), 0);
}
~AudioState()
{
if(mSource)
alDeleteSources(1, &mSource);
- alDeleteBuffers(AUDIO_BUFFER_QUEUE_SIZE, mBuffers);
+ alDeleteBuffers(mBuffers.size(), mBuffers.data());
av_frame_free(&mDecodedFrame);
swr_free(&mSwresCtx);
@@ -677,7 +676,7 @@ int AudioState::handler()
goto finish;
}
- alGenBuffers(AUDIO_BUFFER_QUEUE_SIZE, mBuffers);
+ alGenBuffers(mBuffers.size(), mBuffers.data());
alGenSources(1, &mSource);
if(do_direct_out)
@@ -705,7 +704,7 @@ int AudioState::handler()
/* Refill the buffer queue. */
ALint queued;
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
- while(queued < AUDIO_BUFFER_QUEUE_SIZE)
+ while((ALuint)queued < mBuffers.size())
{
int audio_size;
@@ -715,7 +714,7 @@ int AudioState::handler()
if(audio_size <= 0) break;
ALuint bufid = mBuffers[mBufferIdx++];
- mBufferIdx %= AUDIO_BUFFER_QUEUE_SIZE;
+ mBufferIdx %= mBuffers.size();
alBufferData(bufid, mFormat, samples, audio_size, mCodecCtx->sample_rate);
alSourceQueueBuffers(mSource, 1, &bufid);
@@ -733,8 +732,8 @@ int AudioState::handler()
* since this likely means we're late, and rewind the source to get
* it back into an AL_INITIAL state.
*/
- alSourcei(mSource, AL_BUFFER, 0);
alSourceRewind(mSource);
+ alSourcei(mSource, AL_BUFFER, 0);
continue;
}