mirror of https://github.com/libsdl-org/SDL.git
audio: Make sure a few bitflag checks convert to bools correctly.
This might just be defensive coding, but better safe than sorry on this.
This commit is contained in:
parent
ec2ef5f9b5
commit
65c9a58f5e
|
|
@ -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;
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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?
|
||||
|
|
|
|||
Loading…
Reference in New Issue