Skip to content

Commit

Permalink
audio: Make sure a few bitflag checks convert to bools correctly.
Browse files Browse the repository at this point in the history
This might just be defensive coding, but better safe than sorry on this.
  • Loading branch information
icculus committed Dec 3, 2024
1 parent ec2ef5f commit 65c9a58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/audio/SDL_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const bool recording)
// bit #0 of devid is set for playback devices and unset for recording.
// bit #1 of devid is set for physical devices and unset for logical.
const bool devid_recording = !(devid & (1 << 0));
const bool isphysical = (devid & (1 << 1));
const bool isphysical = !!(devid & (1 << 1));
if (isphysical && (devid_recording == recording) && (devid < highest)) {
highest = devid;
result = (SDL_AudioDevice *) value;
Expand Down Expand Up @@ -1065,7 +1065,7 @@ void SDL_QuitAudio(void)
while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) {
// bit #1 of devid is set for physical devices and unset for logical.
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
const bool isphysical = (devid & (1<<1));
const bool isphysical = !!(devid & (1<<1));
if (isphysical) {
DestroyPhysicalAudioDevice((SDL_AudioDevice *) value);
}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
// bit #0 of devid is set for playback devices and unset for recording.
// bit #1 of devid is set for physical devices and unset for logical.
const bool devid_recording = !(devid & (1<<0));
const bool isphysical = (devid & (1<<1));
const bool isphysical = !!(devid & (1<<1));
if (isphysical && (devid_recording == recording)) {
SDL_assert(devs_seen < num_devices);
result[devs_seen++] = devid;
Expand Down Expand Up @@ -1419,7 +1419,7 @@ SDL_AudioDevice *SDL_FindPhysicalAudioDeviceByCallback(bool (*callback)(SDL_Audi
while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
// bit #1 of devid is set for physical devices and unset for logical.
const bool isphysical = (devid & (1<<1));
const bool isphysical = !!(devid & (1<<1));
if (isphysical) {
SDL_AudioDevice *device = (SDL_AudioDevice *) value;
if (callback(device, userdata)) { // found it?
Expand Down

0 comments on commit 65c9a58

Please sign in to comment.