aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-26 00:02:23 -0800
committerChris Robinson <[email protected]>2023-12-26 02:21:35 -0800
commit1fddc044ac765d00e64628e59edcbcd71f0046b1 (patch)
tree9e6734e0527bd418a4775c7d41c3b6a25ca4eb41 /examples
parent095d1964feacaa4ec253db028fb1e8c04f718511 (diff)
Clean up some gotos and non-optimal casts
Diffstat (limited to 'examples')
-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
5 files changed, 18 insertions, 19 deletions
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
{