[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker
2023-11-10 15:30:56 +01:00
committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
394 changed files with 2564 additions and 2559 deletions
+3 -3
View File
@@ -383,7 +383,7 @@ main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
if (state == NULL) {
if (!state) {
return 1;
}
@@ -446,7 +446,7 @@ main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (sprites == NULL) {
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
@@ -461,7 +461,7 @@ main(int argc, char *argv[])
soundname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
if (soundname == NULL) {
if (!soundname) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
+5 -5
View File
@@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer)
/* load the ship */
bmp_surface = SDL_LoadBMP("ship.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not ship.bmp");
}
/* set blue to transparent on the ship */
@@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer)
/* create ship texture from surface */
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (ship == NULL) {
if (!ship) {
fatalError("could not create ship texture");
}
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
@@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer)
/* load the space background */
bmp_surface = SDL_LoadBMP("space.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load space.bmp");
}
/* create space texture from surface */
space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (space == NULL) {
if (!space) {
fatalError("could not create space texture");
}
SDL_FreeSurface(bmp_surface);
@@ -179,7 +179,7 @@ main(int argc, char *argv[])
printf("There are %d joysticks available\n", SDL_NumJoysticks());
printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0));
accelerometer = SDL_JoystickOpen(0);
if (accelerometer == NULL) {
if (!accelerometer) {
fatalError("Could not open joystick (accelerometer)");
}
printf("joystick number of axis = %d\n",
+1 -1
View File
@@ -334,7 +334,7 @@ initializeTexture()
to format passed into OpenGL */
bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}
+2 -2
View File
@@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer)
SDL_Surface *bmp_surface;
/* load the bmp */
bmp_surface = SDL_LoadBMP("icon.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load bmp");
}
/* set white to transparent on the happyface */
@@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer)
/* convert RGBA surface to texture */
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (texture == NULL) {
if (!texture) {
fatalError("could not create texture");
}
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+2 -2
View File
@@ -165,7 +165,7 @@ loadFont(void)
{
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
if (surface == NULL) {
if (!surface) {
printf("Error loading bitmap: %s\n", SDL_GetError());
return 0;
} else {
@@ -183,7 +183,7 @@ loadFont(void)
SDL_BlitSurface(surface, NULL, converted, NULL);
/* create our texture */
texture = SDL_CreateTextureFromSurface(renderer, converted);
if (texture == NULL) {
if (!texture) {
printf("texture creation failed: %s\n", SDL_GetError());
} else {
/* set blend mode for our texture */
+2 -2
View File
@@ -58,11 +58,11 @@ main(int argc, char *argv[])
/* create window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
if (window == NULL) {
if (!window) {
fatalError("Could not initialize Window");
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
fatalError("Could not create renderer");
}
+2 -2
View File
@@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer)
{
SDL_Surface *bmp_surface;
bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}
brush =
SDL_CreateTextureFromSurface(renderer, bmp_surface);
SDL_FreeSurface(bmp_surface);
if (brush == NULL) {
if (!brush) {
fatalError("could not create brush texture");
}
/* additive blending -- laying strokes on top of eachother makes them brighter */
+1 -1
View File
@@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
640, 480,
SDL_WINDOW_SHOWN
);
if (window == NULL) {
if (!window) {
fprintf(stderr, "could not create window: %s\n", SDL_GetError());
return 1;
}
+1 -1
View File
@@ -533,7 +533,7 @@ void SDL_GetVersion(SDL_version *ver)
static SDL_bool check_hint = SDL_TRUE;
static SDL_bool legacy_version = SDL_FALSE;
if (ver == NULL) {
if (!ver) {
return;
}
+8 -8
View File
@@ -114,11 +114,11 @@ static void SDL_GenerateAssertionReport(void)
const SDL_assert_data *item = triggered_assertions;
/* only do this if the app hasn't assigned an assertion handler. */
if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) {
if ((item) && (assertion_handler != SDL_PromptAssertion)) {
debug_print("\n\nSDL assertion report.\n");
debug_print("All SDL assertions between last init/quit:\n\n");
while (item != NULL) {
while (item) {
debug_print(
"'%s'\n"
" * %s (%s:%d)\n"
@@ -206,7 +206,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
/* let env. variable override, so unit tests won't block in a GUI. */
envr = SDL_getenv("SDL_ASSERT");
if (envr != NULL) {
if (envr) {
if (message != stack_buf) {
SDL_free(message);
}
@@ -342,9 +342,9 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
#ifndef SDL_THREADS_DISABLED
static SDL_SpinLock spinlock = 0;
SDL_AtomicLock(&spinlock);
if (assertion_mutex == NULL) { /* never called SDL_Init()? */
if (!assertion_mutex) { /* never called SDL_Init()? */
assertion_mutex = SDL_CreateMutex();
if (assertion_mutex == NULL) {
if (!assertion_mutex) {
SDL_AtomicUnlock(&spinlock);
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
}
@@ -409,7 +409,7 @@ void SDL_AssertionsQuit(void)
#if SDL_ASSERT_LEVEL > 0
SDL_GenerateAssertionReport();
#ifndef SDL_THREADS_DISABLED
if (assertion_mutex != NULL) {
if (assertion_mutex) {
SDL_DestroyMutex(assertion_mutex);
assertion_mutex = NULL;
}
@@ -437,7 +437,7 @@ void SDL_ResetAssertionReport(void)
{
SDL_assert_data *next = NULL;
SDL_assert_data *item;
for (item = triggered_assertions; item != NULL; item = next) {
for (item = triggered_assertions; item; item = next) {
next = (SDL_assert_data *)item->next;
item->always_ignore = SDL_FALSE;
item->trigger_count = 0;
@@ -454,7 +454,7 @@ SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void)
SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata)
{
if (userdata != NULL) {
if (userdata) {
*userdata = assertion_userdata;
}
return assertion_handler;
+15 -15
View File
@@ -54,7 +54,7 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla
{
SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue));
if (queue == NULL) {
if (!queue) {
SDL_OutOfMemory();
} else {
const size_t packetlen = _packetlen ? _packetlen : 1024;
@@ -101,7 +101,7 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
SDL_DataQueuePacket *prev = NULL;
size_t i;
if (queue == NULL) {
if (!queue) {
return;
}
@@ -144,16 +144,16 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
{
SDL_DataQueuePacket *packet;
SDL_assert(queue != NULL);
SDL_assert(queue);
packet = queue->pool;
if (packet != NULL) {
if (packet) {
/* we have one available in the pool. */
queue->pool = packet->next;
} else {
/* Have to allocate a new one! */
packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size);
if (packet == NULL) {
if (!packet) {
return NULL;
}
}
@@ -163,7 +163,7 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
packet->next = NULL;
SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0));
if (queue->tail == NULL) {
if (!queue->tail) {
queue->head = packet;
} else {
queue->tail->next = packet;
@@ -182,7 +182,7 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
size_t origlen;
size_t datalen;
if (queue == NULL) {
if (!queue) {
return SDL_InvalidParamError("queue");
}
@@ -194,13 +194,13 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
while (len > 0) {
SDL_DataQueuePacket *packet = queue->tail;
SDL_assert(packet == NULL || (packet->datalen <= packet_size));
if (packet == NULL || (packet->datalen >= packet_size)) {
SDL_assert(!packet || (packet->datalen <= packet_size));
if (!packet || (packet->datalen >= packet_size)) {
/* tail packet missing or completely full; we need a new packet. */
packet = AllocateDataQueuePacket(queue);
if (packet == NULL) {
if (!packet) {
/* uhoh, reset so we've queued nothing new, free what we can. */
if (origtail == NULL) {
if (!origtail) {
packet = queue->head; /* whole queue. */
} else {
packet = origtail->next; /* what we added to existing queue. */
@@ -238,7 +238,7 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
Uint8 *ptr = buf;
SDL_DataQueuePacket *packet;
if (queue == NULL) {
if (!queue) {
return 0;
}
@@ -267,7 +267,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
Uint8 *ptr = buf;
SDL_DataQueuePacket *packet;
if (queue == NULL) {
if (!queue) {
return 0;
}
@@ -286,7 +286,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */
queue->head = packet->next;
SDL_assert((packet->next != NULL) || (packet == queue->tail));
SDL_assert((packet->next) || (packet == queue->tail));
packet->next = queue->pool;
queue->pool = packet;
}
@@ -294,7 +294,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0));
if (queue->head == NULL) {
if (!queue->head) {
queue->tail = NULL; /* in case we drained the queue entirely. */
}
+1 -1
View File
@@ -28,7 +28,7 @@
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
/* Ignore call if invalid format pointer was passed */
if (fmt != NULL) {
if (fmt) {
va_list ap;
int result;
SDL_error *error = SDL_GetErrBuf();
+1 -1
View File
@@ -29,7 +29,7 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
static const char k_rgchHexToASCII[] = "0123456789abcdef";
int i;
if ((pszGUID == NULL) || (cbGUID <= 0)) {
if ((!pszGUID) || (cbGUID <= 0)) {
return;
}
+16 -16
View File
@@ -51,7 +51,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
SDL_Hint *hint;
SDL_HintWatch *entry;
if (name == NULL) {
if (!name) {
return SDL_FALSE;
}
@@ -66,7 +66,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
return SDL_FALSE;
}
if (hint->value != value &&
(value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
(!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@@ -83,7 +83,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
/* Couldn't find the hint, add a new one */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (hint == NULL) {
if (!hint) {
return SDL_FALSE;
}
hint->name = SDL_strdup(name);
@@ -101,16 +101,16 @@ SDL_bool SDL_ResetHint(const char *name)
SDL_Hint *hint;
SDL_HintWatch *entry;
if (name == NULL) {
if (!name) {
return SDL_FALSE;
}
env = SDL_getenv(name);
for (hint = SDL_hints; hint; hint = hint->next) {
if (SDL_strcmp(name, hint->name) == 0) {
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
if ((!env && hint->value) ||
(env && !hint->value) ||
(env && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@@ -135,9 +135,9 @@ void SDL_ResetHints(void)
for (hint = SDL_hints; hint; hint = hint->next) {
env = SDL_getenv(hint->name);
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
if ((!env && hint->value) ||
(env && !hint->value) ||
(env && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@@ -164,7 +164,7 @@ const char *SDL_GetHint(const char *name)
env = SDL_getenv(name);
for (hint = SDL_hints; hint; hint = hint->next) {
if (SDL_strcmp(name, hint->name) == 0) {
if (env == NULL || hint->priority == SDL_HINT_OVERRIDE) {
if (!env || hint->priority == SDL_HINT_OVERRIDE) {
return hint->value;
}
break;
@@ -175,7 +175,7 @@ const char *SDL_GetHint(const char *name)
SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value)
{
if (value == NULL || !*value) {
if (!value || !*value) {
return default_value;
}
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
@@ -196,7 +196,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
SDL_HintWatch *entry;
const char *value;
if (name == NULL || !*name) {
if (!name || !*name) {
SDL_InvalidParamError("name");
return;
}
@@ -208,7 +208,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
SDL_DelHintCallback(name, callback, userdata);
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
if (entry == NULL) {
if (!entry) {
SDL_OutOfMemory();
return;
}
@@ -220,10 +220,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
break;
}
}
if (hint == NULL) {
if (!hint) {
/* Need to add a hint entry for this watcher */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (hint == NULL) {
if (!hint) {
SDL_OutOfMemory();
SDL_free(entry);
return;
+2 -2
View File
@@ -28,7 +28,7 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent)
{
SDL_ListNode *node = SDL_malloc(sizeof(*node));
if (node == NULL) {
if (!node) {
return SDL_OutOfMemory();
}
@@ -44,7 +44,7 @@ void SDL_ListPop(SDL_ListNode **head, void **ent)
SDL_ListNode **ptr = head;
/* Invalid or empty */
if (head == NULL || *head == NULL) {
if (!head || !*head) {
return;
}
+6 -6
View File
@@ -106,7 +106,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
void SDL_LogInit(void)
{
if (log_function_mutex == NULL) {
if (!log_function_mutex) {
/* if this fails we'll try to continue without it. */
log_function_mutex = SDL_CreateMutex();
}
@@ -299,7 +299,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
return;
}
if (log_function_mutex == NULL) {
if (!log_function_mutex) {
/* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */
log_function_mutex = SDL_CreateMutex();
}
@@ -317,7 +317,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) {
/* Allocate exactly what we need, including the zero-terminator */
message = (char *)SDL_malloc(len_plus_term);
if (message == NULL) {
if (!message) {
return;
}
va_copy(aq, ap);
@@ -453,7 +453,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}
@@ -462,7 +462,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("ux0:/data/SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}
@@ -471,7 +471,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}
+1 -1
View File
@@ -67,7 +67,7 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
/* Terrible terrible damage */
static SDL_mutex *_spinlock_mutex;
if (_spinlock_mutex == NULL) {
if (!_spinlock_mutex) {
/* Race condition on first lock... */
_spinlock_mutex = SDL_CreateMutex();
}
+1 -1
View File
@@ -962,7 +962,7 @@ int SDL_AudioInit(const char *driver_name)
}
}
driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL;
driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL;
}
} else {
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
+18 -18
View File
@@ -266,7 +266,7 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt)
/* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
/* Make sure there's data to convert */
if (cvt->buf == NULL) {
if (!cvt->buf) {
return SDL_SetError("No buffer allocated for conversion");
}
@@ -517,7 +517,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
/* we keep no streaming state here, so pad with silence on both ends. */
padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float));
if (padding == NULL) {
if (!padding) {
SDL_OutOfMemory();
return;
}
@@ -614,7 +614,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels,
}
filter = ChooseCVTResampler(dst_channels);
if (filter == NULL) {
if (!filter) {
return SDL_SetError("No conversion available for these rates");
}
@@ -687,7 +687,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
SDL_AudioFilter channel_converter = NULL;
/* Sanity check target pointer */
if (cvt == NULL) {
if (!cvt) {
return SDL_InvalidParamError("cvt");
}
@@ -782,7 +782,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0]));
channel_converter = channel_converters[src_channels - 1][dst_channels - 1];
if ((channel_converter == NULL) != (src_channels == dst_channels)) {
if ((!channel_converter) != (src_channels == dst_channels)) {
/* All combinations of supported channel counts should have been handled by now, but let's be defensive */
return SDL_SetError("Invalid channel combination");
} else if (channel_converter != NULL) {
@@ -878,7 +878,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
ptr = stream->work_buffer_base;
} else {
ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32);
if (ptr == NULL) {
if (!ptr) {
SDL_OutOfMemory();
return NULL;
}
@@ -950,12 +950,12 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream)
if (SRC_available) {
state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
if (state == NULL) {
if (!state) {
SDL_SetError("src_new() failed: %s", SRC_src_strerror(result));
}
}
if (state == NULL) {
if (!state) {
SDL_CleanupAudioStreamResampler_SRC(stream);
return SDL_FALSE;
}
@@ -1027,7 +1027,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
}
retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@@ -1053,7 +1053,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels;
retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float));
if (retval->resampler_padding == NULL) {
if (!retval->resampler_padding) {
SDL_FreeAudioStream(retval);
SDL_OutOfMemory();
return NULL;
@@ -1062,7 +1062,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size);
if (retval->staging_buffer_size > 0) {
retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size);
if (retval->staging_buffer == NULL) {
if (!retval->staging_buffer) {
SDL_FreeAudioStream(retval);
SDL_OutOfMemory();
return NULL;
@@ -1169,7 +1169,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
#endif
workbuf = EnsureStreamBufferSize(stream, workbuflen);
if (workbuf == NULL) {
if (!workbuf) {
return -1; /* probably out of memory. */
}
@@ -1260,10 +1260,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
#endif
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
if (buf == NULL) {
if (!buf) {
return SDL_InvalidParamError("buf");
}
if (len == 0) {
@@ -1315,7 +1315,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
{
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
@@ -1373,10 +1373,10 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
#endif
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
if (buf == NULL) {
if (!buf) {
return SDL_InvalidParamError("buf");
}
if (len <= 0) {
@@ -1397,7 +1397,7 @@ int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
void SDL_AudioStreamClear(SDL_AudioStream *stream)
{
if (stream == NULL) {
if (!stream) {
SDL_InvalidParamError("stream");
} else {
SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);
+3 -3
View File
@@ -81,16 +81,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
const char *audiodev;
char audiopath[1024];
if (test == NULL) {
if (!test) {
test = test_stub;
}
/* Figure out what our audio device is */
audiodev = SDL_getenv("SDL_PATH_DSP");
if (audiodev == NULL) {
if (!audiodev) {
audiodev = SDL_getenv("AUDIODEV");
}
if (audiodev == NULL) {
if (!audiodev) {
if (classic) {
audiodev = _PATH_DEV_AUDIO;
} else {
+18 -18
View File
@@ -264,7 +264,7 @@ static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, U
int res;
dumpstr = SDL_malloc(bufsize);
if (dumpstr == NULL) {
if (!dumpstr) {
return;
}
dumpstr[0] = 0;
@@ -441,7 +441,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
file->decoderdata = coeffdata; /* Freed in cleanup. */
if (coeffdata == NULL) {
if (!coeffdata) {
return SDL_OutOfMemory();
}
coeffdata->coeff = &coeffdata->aligndummy;
@@ -684,7 +684,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
state.output.pos = 0;
state.output.size = outputsize / sizeof(Sint16);
state.output.data = (Sint16 *)SDL_calloc(1, outputsize);
if (state.output.data == NULL) {
if (!state.output.data) {
return SDL_OutOfMemory();
}
@@ -1075,12 +1075,12 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
state.output.pos = 0;
state.output.size = outputsize / sizeof(Sint16);
state.output.data = (Sint16 *)SDL_malloc(outputsize);
if (state.output.data == NULL) {
if (!state.output.data) {
return SDL_OutOfMemory();
}
cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8));
if (cstate == NULL) {
if (!cstate) {
SDL_free(state.output.data);
return SDL_OutOfMemory();
}
@@ -1235,7 +1235,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (src == NULL) {
if (!src) {
return SDL_OutOfMemory();
}
chunk->data = NULL;
@@ -1366,7 +1366,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (ptr == NULL) {
if (!ptr) {
return SDL_OutOfMemory();
}
@@ -1442,7 +1442,7 @@ static WaveRiffSizeHint WaveGetRiffSizeHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "force") == 0) {
return RiffSizeForce;
} else if (SDL_strcmp(hint, "ignore") == 0) {
@@ -1461,7 +1461,7 @@ static WaveTruncationHint WaveGetTruncationHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "verystrict") == 0) {
return TruncVeryStrict;
} else if (SDL_strcmp(hint, "strict") == 0) {
@@ -1480,7 +1480,7 @@ static WaveFactChunkHint WaveGetFactChunkHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "truncate") == 0) {
return FactTruncate;
} else if (SDL_strcmp(hint, "strict") == 0) {
@@ -1497,7 +1497,7 @@ static WaveFactChunkHint WaveGetFactChunkHint()
static void WaveFreeChunkData(WaveChunk *chunk)
{
if (chunk->data != NULL) {
if (chunk->data) {
SDL_free(chunk->data);
chunk->data = NULL;
}
@@ -1546,7 +1546,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
if (length > 0) {
chunk->data = (Uint8 *)SDL_malloc(length);
if (chunk->data == NULL) {
if (!chunk->data) {
return SDL_OutOfMemory();
}
@@ -1612,7 +1612,7 @@ static int WaveReadFormat(WaveFile *file)
return SDL_SetError("Data of WAVE fmt chunk too big");
}
fmtsrc = SDL_RWFromConstMem(chunk->data, (int)chunk->size);
if (fmtsrc == NULL) {
if (!fmtsrc) {
return SDL_OutOfMemory();
}
@@ -1787,7 +1787,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
SDL_zero(datachunk);
envchunkcountlimit = SDL_getenv("SDL_WAVE_CHUNK_LIMIT");
if (envchunkcountlimit != NULL) {
if (envchunkcountlimit) {
unsigned int count;
if (SDL_sscanf(envchunkcountlimit, "%u", &count) == 1) {
chunkcountlimit = count <= SDL_MAX_UINT32 ? count : SDL_MAX_UINT32;
@@ -2085,16 +2085,16 @@ SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec,
SDL_zero(file);
/* Make sure we are passed a valid data source */
if (src == NULL) {
if (!src) {
/* Error may come from RWops. */
return NULL;
} else if (spec == NULL) {
} else if (!spec) {
SDL_InvalidParamError("spec");
return NULL;
} else if (audio_buf == NULL) {
} else if (!audio_buf) {
SDL_InvalidParamError("audio_buf");
return NULL;
} else if (audio_len == NULL) {
} else if (!audio_len) {
SDL_InvalidParamError("audio_len");
return NULL;
}
+12 -12
View File
@@ -77,8 +77,8 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
aaudio_result_t res;
LOGI(__func__);
SDL_assert((captureDevice == NULL) || !iscapture);
SDL_assert((audioDevice == NULL) || iscapture);
SDL_assert((!captureDevice) || !iscapture);
SDL_assert((!audioDevice) || iscapture);
if (iscapture) {
if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) {
@@ -94,14 +94,14 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
}
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
private = this->hidden;
ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq);
ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels);
if(devname != NULL) {
if(devname) {
int aaudio_device_id = SDL_atoi(devname);
LOGI("Opening device id %d", aaudio_device_id);
ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, aaudio_device_id);
@@ -153,7 +153,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
private->mixlen = this->spec.size;
private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen);
if (private->mixbuf == NULL) {
if (!private->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(private->mixbuf, this->spec.silence, this->spec.size);
@@ -285,7 +285,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
SDL_zero(ctx);
ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO);
if (ctx.handle == NULL) {
if (!ctx.handle) {
LOGI("SDL couldn't find " LIB_AAUDIO_SO);
goto failure;
}
@@ -300,7 +300,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
goto failure;
}
if (ctx.builder == NULL) {
if (!ctx.builder) {
LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL");
goto failure;
}
@@ -344,7 +344,7 @@ void aaudio_PauseDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->stream) {
@@ -365,7 +365,7 @@ void aaudio_PauseDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->stream) {
@@ -393,7 +393,7 @@ void aaudio_ResumeDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->resume) {
@@ -411,7 +411,7 @@ void aaudio_ResumeDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->resume) {
@@ -441,7 +441,7 @@ SDL_bool aaudio_DetectBrokenPlayState(void)
int64_t framePosition, timeNanoseconds;
aaudio_result_t res;
if (audioDevice == NULL || !audioDevice->hidden) {
if (!audioDevice || !audioDevice->hidden) {
return SDL_FALSE;
}
+20 -20
View File
@@ -98,7 +98,7 @@ static void *alsa_handle = NULL;
static int load_alsa_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(alsa_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@@ -166,7 +166,7 @@ static int load_alsa_syms(void)
static void UnloadALSALibrary(void)
{
if (alsa_handle != NULL) {
if (alsa_handle) {
SDL_UnloadObject(alsa_handle);
alsa_handle = NULL;
}
@@ -175,9 +175,9 @@ static void UnloadALSALibrary(void)
static int LoadALSALibrary(void)
{
int retval = 0;
if (alsa_handle == NULL) {
if (!alsa_handle) {
alsa_handle = SDL_LoadObject(alsa_library);
if (alsa_handle == NULL) {
if (!alsa_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@@ -208,13 +208,13 @@ static const char *get_audio_device(void *handle, const int channels)
{
const char *device;
if (handle != NULL) {
if (handle) {
return (const char *)handle;
}
/* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */
device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
if (device != NULL) {
if (device) {
return device;
}
@@ -539,7 +539,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -687,7 +687,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);
@@ -717,7 +717,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
char *handle = NULL;
char *ptr;
if (dev == NULL) {
if (!dev) {
return;
}
@@ -727,7 +727,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
Make sure not to free the storage associated with desc in this case */
if (hint) {
desc = ALSA_snd_device_name_get_hint(hint, "DESC");
if (desc == NULL) {
if (!desc) {
SDL_free(dev);
return;
}
@@ -735,20 +735,20 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
desc = (char *)name;
}
SDL_assert(name != NULL);
SDL_assert(name);
/* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output".
just chop the extra lines off, this seems to get a reasonable device
name without extra details. */
ptr = SDL_strchr(desc, '\n');
if (ptr != NULL) {
if (ptr) {
*ptr = '\0';
}
/*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/
handle = SDL_strdup(name);
if (handle == NULL) {
if (!handle) {
if (hint) {
free(desc);
}
@@ -800,7 +800,7 @@ static void ALSA_HotplugIteration(void)
if we can find a preferred prefix for the system. */
for (i = 0; hints[i]; i++) {
char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (name == NULL) {
if (!name) {
continue;
}
@@ -829,20 +829,20 @@ static void ALSA_HotplugIteration(void)
char *name;
/* if we didn't find a device name prefix we like at all... */
if ((match == NULL) && (defaultdev != i)) {
if ((!match) && (defaultdev != i)) {
continue; /* ...skip anything that isn't the default device. */
}
name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (name == NULL) {
if (!name) {
continue;
}
/* only want physical hardware interfaces */
if (match == NULL || (SDL_strncmp(name, match, match_len) == 0)) {
if (!match || (SDL_strncmp(name, match, match_len) == 0)) {
char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0);
const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0);
const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0);
const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0);
SDL_bool have_output = SDL_FALSE;
SDL_bool have_input = SDL_FALSE;
@@ -940,7 +940,7 @@ static void ALSA_Deinitialize(void)
ALSA_Device *next;
#if SDL_ALSA_HOTPLUG_THREAD
if (ALSA_hotplug_thread != NULL) {
if (ALSA_hotplug_thread) {
SDL_AtomicSet(&ALSA_hotplug_shutdown, 1);
SDL_WaitThread(ALSA_hotplug_thread, NULL);
ALSA_hotplug_thread = NULL;
+8 -8
View File
@@ -41,8 +41,8 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture;
SDL_assert((captureDevice == NULL) || !iscapture);
SDL_assert((audioDevice == NULL) || iscapture);
SDL_assert((!captureDevice) || !iscapture);
SDL_assert((!audioDevice) || iscapture);
if (iscapture) {
captureDevice = this;
@@ -51,7 +51,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
}
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
@@ -71,7 +71,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
{
int audio_device_id = 0;
if (devname != NULL) {
if (devname) {
audio_device_id = SDL_atoi(devname);
}
if (Android_JNI_OpenAudioDevice(iscapture, audio_device_id, &this->spec) < 0) {
@@ -149,7 +149,7 @@ void ANDROIDAUDIO_PauseDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (SDL_AtomicGet(&audioDevice->paused)) {
/* The device is already paused, leave it alone */
@@ -161,7 +161,7 @@ void ANDROIDAUDIO_PauseDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (SDL_AtomicGet(&captureDevice->paused)) {
/* The device is already paused, leave it alone */
@@ -179,7 +179,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->resume) {
SDL_AtomicSet(&audioDevice->paused, 0);
@@ -188,7 +188,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->resume) {
SDL_AtomicSet(&captureDevice->paused, 0);
+5 -5
View File
@@ -88,7 +88,7 @@ static struct
static void UnloadARTSLibrary()
{
if (arts_handle != NULL) {
if (arts_handle) {
SDL_UnloadObject(arts_handle);
arts_handle = NULL;
}
@@ -98,9 +98,9 @@ static int LoadARTSLibrary(void)
{
int i, retval = -1;
if (arts_handle == NULL) {
if (!arts_handle) {
arts_handle = SDL_LoadObject(arts_library);
if (arts_handle != NULL) {
if (arts_handle) {
retval = 0;
for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
*arts_functions[i].func =
@@ -214,7 +214,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -281,7 +281,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+9 -9
View File
@@ -64,7 +64,7 @@ static void DSOUND_Unload(void)
pDirectSoundCaptureCreate8 = NULL;
pDirectSoundCaptureEnumerateW = NULL;
if (DSoundDLL != NULL) {
if (DSoundDLL) {
SDL_UnloadObject(DSoundDLL);
DSoundDLL = NULL;
}
@@ -77,7 +77,7 @@ static int DSOUND_Load(void)
DSOUND_Unload();
DSoundDLL = SDL_LoadObject("DSOUND.DLL");
if (DSoundDLL == NULL) {
if (!DSoundDLL) {
SDL_SetError("DirectSound: failed to load DSOUND.DLL");
} else {
/* Now make sure we have DirectX 8 or better... */
@@ -172,7 +172,7 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO
const int iscapture = (int)((size_t)data);
if (guid != NULL) { /* skip default device */
char *str = WIN_LookupAudioDeviceName(desc, guid);
if (str != NULL) {
if (str) {
LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID));
SDL_memcpy(cpyguid, guid, sizeof(GUID));
@@ -354,7 +354,7 @@ static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
}
SDL_assert(ptr1len == this->spec.size);
SDL_assert(ptr2 == NULL);
SDL_assert(!ptr2);
SDL_assert(ptr2len == 0);
SDL_memcpy(buffer, ptr1, ptr1len);
@@ -379,18 +379,18 @@ static void DSOUND_FlushCapture(_THIS)
static void DSOUND_CloseDevice(_THIS)
{
if (this->hidden->mixbuf != NULL) {
if (this->hidden->mixbuf) {
IDirectSoundBuffer_Stop(this->hidden->mixbuf);
IDirectSoundBuffer_Release(this->hidden->mixbuf);
}
if (this->hidden->sound != NULL) {
if (this->hidden->sound) {
IDirectSound_Release(this->hidden->sound);
}
if (this->hidden->capturebuf != NULL) {
if (this->hidden->capturebuf) {
IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf);
IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf);
}
if (this->hidden->capture != NULL) {
if (this->hidden->capture) {
IDirectSoundCapture_Release(this->hidden->capture);
}
SDL_free(this->hidden);
@@ -493,7 +493,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
+7 -7
View File
@@ -98,7 +98,7 @@ static void DISKAUDIO_FlushCapture(_THIS)
static void DISKAUDIO_CloseDevice(_THIS)
{
if (_this->hidden->io != NULL) {
if (_this->hidden->io) {
SDL_RWclose(_this->hidden->io);
}
SDL_free(_this->hidden->mixbuf);
@@ -107,9 +107,9 @@ static void DISKAUDIO_CloseDevice(_THIS)
static const char *get_filename(const SDL_bool iscapture, const char *devname)
{
if (devname == NULL) {
if (!devname) {
devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
if (devname == NULL) {
if (!devname) {
devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE;
}
}
@@ -126,12 +126,12 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
_this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*_this->hidden));
if (_this->hidden == NULL) {
if (!_this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(_this->hidden);
if (envr != NULL) {
if (envr) {
_this->hidden->io_delay = SDL_atoi(envr);
} else {
_this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq);
@@ -139,14 +139,14 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
/* Open the audio device */
_this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb");
if (_this->hidden->io == NULL) {
if (!_this->hidden->io) {
return -1;
}
/* Allocate mixing buffer */
if (!iscapture) {
_this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size);
if (_this->hidden->mixbuf == NULL) {
if (!_this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size);
+4 -4
View File
@@ -67,9 +67,9 @@ static int DSP_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
@@ -86,7 +86,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -228,7 +228,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+2 -2
View File
@@ -70,7 +70,7 @@ static void HandleAudioProcess(_THIS)
return;
}
if (this->stream == NULL) { /* no conversion necessary. */
if (!this->stream) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
@@ -130,7 +130,7 @@ static void HandleCaptureProcess(_THIS)
/* okay, we've got an interleaved float32 array in C now. */
if (this->stream == NULL) { /* no conversion necessary. */
if (!this->stream) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
+5 -5
View File
@@ -66,7 +66,7 @@ static struct
static void UnloadESDLibrary()
{
if (esd_handle != NULL) {
if (esd_handle) {
SDL_UnloadObject(esd_handle);
esd_handle = NULL;
}
@@ -76,7 +76,7 @@ static int LoadESDLibrary(void)
{
int i, retval = -1;
if (esd_handle == NULL) {
if (!esd_handle) {
esd_handle = SDL_LoadObject(esd_library);
if (esd_handle) {
retval = 0;
@@ -185,7 +185,7 @@ static char *get_progname(void)
if (fp != NULL) {
if (fgets(temp, sizeof(temp) - 1, fp)) {
progname = SDL_strrchr(temp, '/');
if (progname == NULL) {
if (!progname) {
progname = temp;
} else {
progname = progname + 1;
@@ -206,7 +206,7 @@ static int ESD_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -264,7 +264,7 @@ static int ESD_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+5 -5
View File
@@ -79,7 +79,7 @@ static struct
static void UnloadFusionSoundLibrary()
{
if (fs_handle != NULL) {
if (fs_handle) {
SDL_UnloadObject(fs_handle);
fs_handle = NULL;
}
@@ -89,9 +89,9 @@ static int LoadFusionSoundLibrary(void)
{
int i, retval = -1;
if (fs_handle == NULL) {
if (!fs_handle) {
fs_handle = SDL_LoadObject(fs_library);
if (fs_handle != NULL) {
if (fs_handle) {
retval = 0;
for (i = 0; i < SDL_arraysize(fs_functions); ++i) {
*fs_functions[i].func =
@@ -175,7 +175,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -250,7 +250,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+1 -1
View File
@@ -59,7 +59,7 @@ static void FillSound(void *device, void *stream, size_t len,
} else {
SDL_assert(audio->spec.size == len);
if (audio->stream == NULL) { /* no conversion necessary. */
if (!audio->stream) { /* no conversion necessary. */
callback(audio->callbackspec.userdata, (Uint8 *) stream, len);
} else { /* streaming/converting */
const int stream_len = audio->callbackspec.size;
+6 -6
View File
@@ -58,7 +58,7 @@ static void *jack_handle = NULL;
static int load_jack_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(jack_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@@ -73,7 +73,7 @@ static int load_jack_sym(const char *fn, void **addr)
static void UnloadJackLibrary(void)
{
if (jack_handle != NULL) {
if (jack_handle) {
SDL_UnloadObject(jack_handle);
jack_handle = NULL;
}
@@ -82,9 +82,9 @@ static void UnloadJackLibrary(void)
static int LoadJackLibrary(void)
{
int retval = 0;
if (jack_handle == NULL) {
if (!jack_handle) {
jack_handle = SDL_LoadObject(jack_library);
if (jack_handle == NULL) {
if (!jack_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@@ -341,7 +341,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
/* Build SDL's ports, which we will connect to the device ports. */
this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
if (this->hidden->sdlports == NULL) {
if (!this->hidden->sdlports) {
SDL_free(audio_ports);
return SDL_OutOfMemory();
}
@@ -400,7 +400,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
/* Make sure a JACK server is running and available. */
jack_status_t status;
jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL);
if (client == NULL) {
if (!client) {
UnloadJackLibrary();
return SDL_FALSE;
}
+3 -3
View File
@@ -89,7 +89,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
float mix[12];
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
@@ -127,14 +127,14 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS);
if (data_vaddr == NULL) {
if (!data_vaddr) {
return SDL_OutOfMemory();
}
+2 -2
View File
@@ -62,7 +62,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta
} else {
SDL_assert(_this->spec.size == len);
if (_this->stream == NULL) { /* no conversion necessary. */
if (!_this->stream) { /* no conversion necessary. */
callback(_this->callbackspec.userdata, stream, len);
} else { /* streaming/converting */
const int stream_len = _this->callbackspec.size;
@@ -103,7 +103,7 @@ static int NACLAUDIO_OpenDevice(_THIS, const char *devname)
const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig();
private = (SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*private));
if (private == NULL) {
if (!private) {
return SDL_OutOfMemory();
}
+7 -7
View File
@@ -59,7 +59,7 @@ static void *nas_handle = NULL;
static int load_nas_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(nas_handle, fn);
if (*addr == NULL) {
if (!*addr) {
return 0;
}
return 1;
@@ -94,7 +94,7 @@ static int load_nas_syms(void)
static void UnloadNASLibrary(void)
{
if (nas_handle != NULL) {
if (nas_handle) {
SDL_UnloadObject(nas_handle);
nas_handle = NULL;
}
@@ -103,9 +103,9 @@ static void UnloadNASLibrary(void)
static int LoadNASLibrary(void)
{
int retval = 0;
if (nas_handle == NULL) {
if (!nas_handle) {
nas_handle = SDL_LoadObject(nas_library);
if (nas_handle == NULL) {
if (!nas_handle) {
/* Copy error string so we can use it in a new SDL_SetError(). */
const char *origerr = SDL_GetError();
const size_t len = SDL_strlen(origerr) + 1;
@@ -305,7 +305,7 @@ static int NAS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -389,7 +389,7 @@ static int NAS_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
@@ -410,7 +410,7 @@ static SDL_bool NAS_Init(SDL_AudioDriverImpl * impl)
return SDL_FALSE;
} else {
AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
if (aud == NULL) {
if (!aud) {
SDL_SetError("NAS: AuOpenServer() failed (no audio server?)");
return SDL_FALSE;
}
+4 -4
View File
@@ -202,16 +202,16 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -296,7 +296,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+3 -3
View File
@@ -320,7 +320,7 @@ static int openslES_CreatePCMRecorder(_THIS)
/* Create the sound buffers */
audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size);
if (audiodata->mixbuff == NULL) {
if (!audiodata->mixbuff) {
LOGE("mixbuffer allocate - out of memory");
goto failed;
}
@@ -566,7 +566,7 @@ static int openslES_CreatePCMPlayer(_THIS)
/* Create the sound buffers */
audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size);
if (audiodata->mixbuff == NULL) {
if (!audiodata->mixbuff) {
LOGE("mixbuffer allocate - out of memory");
goto failed;
}
@@ -591,7 +591,7 @@ failed:
static int openslES_OpenDevice(_THIS, const char *devname)
{
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
+3 -3
View File
@@ -43,7 +43,7 @@ static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault)
char* end;
char* envval = SDL_getenv(name);
if (envval == NULL)
if (!envval)
return ulDefault;
ulValue = SDL_strtoul(envval, &end, 10);
@@ -351,7 +351,7 @@ static void OS2_CloseDevice(_THIS)
debug_os2("Enter");
if (pAData == NULL)
if (!pAData)
return;
pAData->ulState = 2;
@@ -429,7 +429,7 @@ static int OS2_OpenDevice(_THIS, const char *devname)
}
pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
if (pAData == NULL)
if (!pAData)
return SDL_OutOfMemory();
_this->hidden = pAData;
+6 -6
View File
@@ -78,11 +78,11 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) {
audiodev = SDL_getenv("AUDIODEV");
}
if (audiodev == NULL) {
if (!audiodev) {
return -1;
}
fd = open(audiodev, flags, 0);
if (path != NULL) {
if (path) {
SDL_strlcpy(path, audiodev, maxlen);
path[maxlen - 1] = '\0';
}
@@ -110,7 +110,7 @@ static int OpenAudioPath(char *path, int maxlen, int flags, int classic)
if (stat(audiopath, &sb) == 0) {
fd = open(audiopath, flags, 0);
if (fd >= 0) {
if (path != NULL) {
if (path) {
SDL_strlcpy(path, audiopath, maxlen);
}
return fd;
@@ -232,7 +232,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -403,7 +403,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
@@ -445,7 +445,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
}
/* Check to see if we need to use SDL_IOReady() workaround */
if (workaround != NULL) {
if (workaround) {
this->hidden->frame_ticks = (float) (this->spec.samples * 1000) /
this->spec.freq;
this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
+39 -39
View File
@@ -129,7 +129,7 @@ static void *pipewire_handle = NULL;
static int pipewire_dlsym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pipewire_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@@ -145,7 +145,7 @@ static int pipewire_dlsym(const char *fn, void **addr)
static int load_pipewire_library()
{
pipewire_handle = SDL_LoadObject(pipewire_library);
return pipewire_handle != NULL ? 0 : -1;
return pipewire_handle ? 0 : -1;
}
static void unload_pipewire_library()
@@ -347,10 +347,10 @@ static void io_list_sort()
/* Find and move the default nodes to the beginning of the list */
spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
if (pipewire_default_sink_id != NULL && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) {
if (pipewire_default_sink_id && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) {
default_sink = n;
spa_list_remove(&n->link);
} else if (pipewire_default_source_id != NULL && SDL_strcmp(n->path, pipewire_default_source_id) == 0) {
} else if (pipewire_default_source_id && SDL_strcmp(n->path, pipewire_default_source_id) == 0) {
default_source = n;
spa_list_remove(&n->link);
}
@@ -442,7 +442,7 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const
/* Create the proxy object */
proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object));
if (proxy == NULL) {
if (!proxy) {
SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno);
return NULL;
}
@@ -648,15 +648,15 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons
{
struct node_object *node = object;
if (subject == PW_ID_CORE && key != NULL && value != NULL) {
if (subject == PW_ID_CORE && key && value) {
if (!SDL_strcmp(key, "default.audio.sink")) {
if (pipewire_default_sink_id != NULL) {
if (pipewire_default_sink_id) {
SDL_free(pipewire_default_sink_id);
}
pipewire_default_sink_id = get_name_from_json(value);
node->persist = SDL_TRUE;
} else if (!SDL_strcmp(key, "default.audio.source")) {
if (pipewire_default_source_id != NULL) {
if (pipewire_default_source_id) {
SDL_free(pipewire_default_source_id);
}
pipewire_default_source_id = get_name_from_json(value);
@@ -701,7 +701,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
if (node_desc && node_path) {
node = node_object_new(id, type, version, &interface_node_events, &interface_core_events);
if (node == NULL) {
if (!node) {
SDL_SetError("Pipewire: Failed to allocate interface node");
return;
}
@@ -710,7 +710,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
desc_buffer_len = SDL_strlen(node_desc) + 1;
path_buffer_len = SDL_strlen(node_path) + 1;
node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len);
if (io == NULL) {
if (!io) {
node_object_destroy(node);
SDL_OutOfMemory();
return;
@@ -731,7 +731,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
}
} else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) {
node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events);
if (node == NULL) {
if (!node) {
SDL_SetError("Pipewire: Failed to allocate metadata node");
return;
}
@@ -759,22 +759,22 @@ static int hotplug_loop_init()
spa_list_init(&hotplug_io_list);
hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL);
if (hotplug_loop == NULL) {
if (!hotplug_loop) {
return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno);
}
hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0);
if (hotplug_context == NULL) {
if (!hotplug_context) {
return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno);
}
hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0);
if (hotplug_core == NULL) {
if (!hotplug_core) {
return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno);
}
hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0);
if (hotplug_registry == NULL) {
if (!hotplug_registry) {
return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno);
}
@@ -806,11 +806,11 @@ static void hotplug_loop_destroy()
hotplug_init_complete = SDL_FALSE;
hotplug_events_enabled = SDL_FALSE;
if (pipewire_default_sink_id != NULL) {
if (pipewire_default_sink_id) {
SDL_free(pipewire_default_sink_id);
pipewire_default_sink_id = NULL;
}
if (pipewire_default_source_id != NULL) {
if (pipewire_default_source_id) {
SDL_free(pipewire_default_source_id);
pipewire_default_source_id = NULL;
}
@@ -961,7 +961,7 @@ static void output_callback(void *data)
/* See if a buffer is available */
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
if (pw_buf == NULL) {
if (!pw_buf) {
return;
}
@@ -1025,13 +1025,13 @@ static void input_callback(void *data)
}
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
if (pw_buf == NULL) {
if (!pw_buf) {
return;
}
spa_buf = pw_buf->buffer;
(src = (Uint8 *)spa_buf->datas[0].data);
if (src == NULL) {
if (!src) {
return;
}
@@ -1079,7 +1079,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride;
this->spec.size = buffer->buffer->datas[0].maxsize;
}
} else if (this->hidden->buffer == NULL) {
} else if (!this->hidden->buffer) {
/*
* The latency of source nodes can change, so buffering is always required.
*
@@ -1137,7 +1137,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
struct SDL_PrivateAudioData *priv;
struct pw_properties *props;
const char *app_name, *stream_name, *stream_role, *error;
Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle);
Uint32 node_id = !this->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle);
SDL_bool iscapture = this->iscapture;
int res;
@@ -1146,15 +1146,15 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
/* Get the hints for the application name, stream name and role */
app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
if (app_name == NULL || *app_name == '\0') {
if (!app_name || *app_name == '\0') {
app_name = SDL_GetHint(SDL_HINT_APP_NAME);
if (app_name == NULL || *app_name == '\0') {
if (!app_name || *app_name == '\0') {
app_name = "SDL Application";
}
}
stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
if (stream_name == NULL || *stream_name == '\0') {
if (!stream_name || *stream_name == '\0') {
stream_name = "Audio Stream";
}
@@ -1163,20 +1163,20 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
* but 'Game' seems more appropriate for the majority of SDL applications.
*/
stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE);
if (stream_role == NULL || *stream_role == '\0') {
if (!stream_role || *stream_role == '\0') {
stream_role = "Game";
}
/* Initialize the Pipewire stream info from the SDL audio spec */
initialize_spa_info(&this->spec, &spa_info);
params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info);
if (params == NULL) {
if (!params) {
return SDL_SetError("Pipewire: Failed to set audio format parameters");
}
priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
this->hidden = priv;
if (priv == NULL) {
if (!priv) {
return SDL_OutOfMemory();
}
@@ -1190,23 +1190,23 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
(void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle);
priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL);
if (priv->loop == NULL) {
if (!priv->loop) {
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
}
/* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */
props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL);
if (props == NULL) {
if (!props) {
return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno);
}
priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0);
if (priv->context == NULL) {
if (!priv->context) {
return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno);
}
props = PIPEWIRE_pw_properties_new(NULL, NULL);
if (props == NULL) {
if (!props) {
return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno);
}
@@ -1232,7 +1232,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
node = io_list_get_by_id(node_id);
if (node != NULL) {
if (node) {
PIPEWIRE_pw_properties_set(props, PW_KEY_TARGET_OBJECT, node->path);
}
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
@@ -1244,7 +1244,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
/* Create the new stream */
priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props,
iscapture ? &stream_input_events : &stream_output_events, this);
if (priv->stream == NULL) {
if (!priv->stream) {
return SDL_SetError("Pipewire: Failed to create stream (%i)", errno);
}
@@ -1272,7 +1272,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
}
/* If this is a capture stream, make sure the intermediate buffer was successfully allocated. */
if (iscapture && priv->buffer == NULL) {
if (iscapture && !priv->buffer) {
return SDL_SetError("Pipewire: Failed to allocate source buffer");
}
@@ -1313,13 +1313,13 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
if (iscapture) {
if (pipewire_default_source_id == NULL) {
if (!pipewire_default_source_id) {
ret = SDL_SetError("PipeWire could not find a default source");
goto failed;
}
target = pipewire_default_source_id;
} else {
if (pipewire_default_sink_id == NULL) {
if (!pipewire_default_sink_id) {
ret = SDL_SetError("PipeWire could not find a default sink");
goto failed;
}
@@ -1327,12 +1327,12 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is
}
node = io_list_get_by_path(target);
if (node == NULL) {
if (!node) {
ret = SDL_SetError("PipeWire device list is out of sync with defaults");
goto failed;
}
if (name != NULL) {
if (name) {
*name = SDL_strdup(node->name);
}
SDL_copyp(spec, &node->spec);
+3 -3
View File
@@ -42,7 +42,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -90,7 +90,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@@ -129,7 +129,7 @@ static void PS2AUDIO_CloseDevice(_THIS)
this->hidden->channel = -1;
}
if (this->hidden->rawbuf != NULL) {
if (this->hidden->rawbuf) {
free(this->hidden->rawbuf);
this->hidden->rawbuf = NULL;
}
+3 -3
View File
@@ -52,7 +52,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -108,7 +108,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@@ -156,7 +156,7 @@ static void PSPAUDIO_CloseDevice(_THIS)
this->hidden->channel = -1;
}
if (this->hidden->rawbuf != NULL) {
if (this->hidden->rawbuf) {
free(this->hidden->rawbuf);
this->hidden->rawbuf = NULL;
}
+29 -29
View File
@@ -125,7 +125,7 @@ static void *pulseaudio_handle = NULL;
static int load_pulseaudio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pulseaudio_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@@ -140,7 +140,7 @@ static int load_pulseaudio_sym(const char *fn, void **addr)
static void UnloadPulseAudioLibrary(void)
{
if (pulseaudio_handle != NULL) {
if (pulseaudio_handle) {
SDL_UnloadObject(pulseaudio_handle);
pulseaudio_handle = NULL;
}
@@ -149,9 +149,9 @@ static void UnloadPulseAudioLibrary(void)
static int LoadPulseAudioLibrary(void)
{
int retval = 0;
if (pulseaudio_handle == NULL) {
if (!pulseaudio_handle) {
pulseaudio_handle = SDL_LoadObject(pulseaudio_library);
if (pulseaudio_handle == NULL) {
if (!pulseaudio_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@@ -257,7 +257,7 @@ static const char *getAppName(void)
} else {
const char *verstr = PULSEAUDIO_pa_get_library_version();
retval = "SDL Application"; /* the "oh well" default. */
if (verstr != NULL) {
if (verstr) {
int maj, min, patch;
if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) {
if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) {
@@ -275,7 +275,7 @@ static const char *getAppName(void)
static void WaitForPulseOperation(pa_operation *o)
{
/* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
SDL_assert(pulseaudio_threaded_mainloop != NULL);
SDL_assert(pulseaudio_threaded_mainloop);
if (o) {
while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */
@@ -286,7 +286,7 @@ static void WaitForPulseOperation(pa_operation *o)
static void DisconnectFromPulseServer(void)
{
if (pulseaudio_threaded_mainloop != NULL) {
if (pulseaudio_threaded_mainloop) {
PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop);
}
if (pulseaudio_context) {
@@ -294,7 +294,7 @@ static void DisconnectFromPulseServer(void)
PULSEAUDIO_pa_context_unref(pulseaudio_context);
pulseaudio_context = NULL;
}
if (pulseaudio_threaded_mainloop != NULL) {
if (pulseaudio_threaded_mainloop) {
PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop);
pulseaudio_threaded_mainloop = NULL;
}
@@ -310,8 +310,8 @@ static int ConnectToPulseServer(void)
pa_mainloop_api *mainloop_api = NULL;
int state = 0;
SDL_assert(pulseaudio_threaded_mainloop == NULL);
SDL_assert(pulseaudio_context == NULL);
SDL_assert(!pulseaudio_threaded_mainloop);
SDL_assert(!pulseaudio_context);
/* Set up a new main loop */
if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) {
@@ -334,7 +334,7 @@ static int ConnectToPulseServer(void)
SDL_assert(mainloop_api); /* this never fails, right? */
pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName());
if (pulseaudio_context == NULL) {
if (!pulseaudio_context) {
SDL_SetError("pa_context_new() failed");
goto failed;
}
@@ -445,7 +445,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
while (SDL_AtomicGet(&this->enabled)) {
if (h->capturebuf != NULL) {
if (h->capturebuf) {
const int cpy = SDL_min(buflen, h->capturelen);
SDL_memcpy(buffer, h->capturebuf, cpy);
/*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/
@@ -478,7 +478,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
SDL_assert(nbytes > 0);
/* If data == NULL, then the buffer had a hole, ignore that */
if (data == NULL) {
if (!data) {
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
} else {
/* store this fragment's data, start feeding it to SDL. */
@@ -501,7 +501,7 @@ static void PULSEAUDIO_FlushCapture(_THIS)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
if (h->capturebuf != NULL) {
if (h->capturebuf) {
PULSEAUDIO_pa_stream_drop(h->stream);
h->capturebuf = NULL;
h->capturelen = 0;
@@ -530,7 +530,7 @@ static void PULSEAUDIO_CloseDevice(_THIS)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
if (this->hidden->stream) {
if (this->hidden->capturebuf != NULL) {
if (this->hidden->capturebuf) {
PULSEAUDIO_pa_stream_drop(this->hidden->stream);
}
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
@@ -566,7 +566,7 @@ static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool is
{
const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1;
if (handle == NULL) { /* NULL == default device. */
if (!handle) { /* NULL == default device. */
return SDL_TRUE;
}
@@ -596,12 +596,12 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
int format = PA_SAMPLE_INVALID;
int retval = 0;
SDL_assert(pulseaudio_threaded_mainloop != NULL);
SDL_assert(pulseaudio_context != NULL);
SDL_assert(pulseaudio_threaded_mainloop);
SDL_assert(pulseaudio_context);
/* Initialize all variables that we clean on shutdown */
h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -651,7 +651,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
h->mixlen = this->spec.size;
h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen);
if (h->mixbuf == NULL) {
if (!h->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(h->mixbuf, this->spec.silence, this->spec.size);
@@ -686,7 +686,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
&pacmap /* channel map */
);
if (h->stream == NULL) {
if (!h->stream) {
retval = SDL_SetError("Could not set up PulseAudio stream");
} else {
int rc;
@@ -694,7 +694,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL);
/* now that we have multi-device support, don't move a stream from
a device that was unplugged to something else, unless we're default. */
if (h->device_name != NULL) {
if (h->device_name) {
flags |= PA_STREAM_DONT_MOVE;
}
@@ -772,8 +772,8 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last,
SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1));
}
if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) {
if (default_sink_name != NULL) {
if (default_sink_path && SDL_strcmp(i->name, default_sink_path) == 0) {
if (default_sink_name) {
SDL_free(default_sink_name);
}
default_sink_name = SDL_strdup(i->description);
@@ -803,8 +803,8 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la
SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1));
}
if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) {
if (default_source_name != NULL) {
if (default_source_path && SDL_strcmp(i->name, default_source_path) == 0) {
if (default_source_name) {
SDL_free(default_source_name);
}
default_source_name = SDL_strdup(i->description);
@@ -909,12 +909,12 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int
char *target;
if (iscapture) {
if (default_source_name == NULL) {
if (!default_source_name) {
return SDL_SetError("PulseAudio could not find a default source");
}
target = default_source_name;
} else {
if (default_sink_name == NULL) {
if (!default_sink_name) {
return SDL_SetError("PulseAudio could not find a default sink");
}
target = default_sink_name;
@@ -923,7 +923,7 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int
numdevices = SDL_GetNumAudioDevices(iscapture);
for (i = 0; i < numdevices; i += 1) {
if (SDL_strcmp(SDL_GetAudioDeviceName(i, iscapture), target) == 0) {
if (name != NULL) {
if (name) {
*name = SDL_strdup(target);
}
SDL_GetAudioDeviceSpec(i, iscapture, spec);
+4 -4
View File
@@ -232,7 +232,7 @@ static Uint8 *QSA_GetDeviceBuf(_THIS)
static void QSA_CloseDevice(_THIS)
{
if (this->hidden->audio_handle != NULL) {
if (this->hidden->audio_handle) {
#if _NTO_VERSION < 710
if (!this->iscapture) {
/* Finish playing available samples */
@@ -267,14 +267,14 @@ static int QSA_OpenDevice(_THIS, const char *devname)
(sizeof
(struct
SDL_PrivateAudioData)));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
if (device != NULL) {
if (device) {
/* Open requested audio device */
this->hidden->deviceno = device->deviceno;
this->hidden->cardno = device->cardno;
@@ -387,7 +387,7 @@ static int QSA_OpenDevice(_THIS, const char *devname)
*/
this->hidden->pcm_buf =
(Uint8 *) SDL_malloc(this->hidden->pcm_len);
if (this->hidden->pcm_buf == NULL) {
if (!this->hidden->pcm_buf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->pcm_buf, this->spec.silence,
+11 -11
View File
@@ -73,7 +73,7 @@ static void *sndio_handle = NULL;
static int load_sndio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(sndio_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@@ -113,7 +113,7 @@ static int load_sndio_syms(void)
static void UnloadSNDIOLibrary(void)
{
if (sndio_handle != NULL) {
if (sndio_handle) {
SDL_UnloadObject(sndio_handle);
sndio_handle = NULL;
}
@@ -122,9 +122,9 @@ static void UnloadSNDIOLibrary(void)
static int LoadSNDIOLibrary(void)
{
int retval = 0;
if (sndio_handle == NULL) {
if (!sndio_handle) {
sndio_handle = SDL_LoadObject(sndio_library);
if (sndio_handle == NULL) {
if (!sndio_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@@ -211,10 +211,10 @@ static Uint8 *SNDIO_GetDeviceBuf(_THIS)
static void SNDIO_CloseDevice(_THIS)
{
if (this->hidden->pfd != NULL) {
if (this->hidden->pfd) {
SDL_free(this->hidden->pfd);
}
if (this->hidden->dev != NULL) {
if (this->hidden->dev) {
SNDIO_sio_stop(this->hidden->dev);
SNDIO_sio_close(this->hidden->dev);
}
@@ -230,7 +230,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -238,16 +238,16 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
this->hidden->mixlen = this->spec.size;
/* Capture devices must be non-blocking for SNDIO_FlushCapture */
this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
this->hidden->dev = SNDIO_sio_open(devname ? devname : SIO_DEVANY,
iscapture ? SIO_REC : SIO_PLAY, iscapture);
if (this->hidden->dev == NULL) {
if (!this->hidden->dev) {
return SDL_SetError("sio_open() failed");
}
/* Allocate the pollfd array for capture devices */
if (iscapture) {
this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev));
if (this->hidden->pfd == NULL) {
if (!this->hidden->pfd) {
return SDL_OutOfMemory();
}
}
@@ -315,7 +315,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);
+5 -5
View File
@@ -194,16 +194,16 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@@ -305,7 +305,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
(this->spec.freq / 8);
this->hidden->frequency = 8;
this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize);
if (this->hidden->ulaw_buf == NULL) {
if (!this->hidden->ulaw_buf) {
return SDL_OutOfMemory();
}
this->spec.channels = 1;
@@ -325,7 +325,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
+3 -3
View File
@@ -67,7 +67,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden, 0, sizeof(*this->hidden));
@@ -98,7 +98,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@@ -162,7 +162,7 @@ static void VITAAUD_CloseDevice(_THIS)
this->hidden->port = -1;
}
if (!this->iscapture && this->hidden->rawbuf != NULL) {
if (!this->iscapture && this->hidden->rawbuf) {
free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
this->hidden->rawbuf = NULL;
}
+9 -9
View File
@@ -114,7 +114,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
/* make sure our scratch buffer can cover the new device spec. */
if (this->spec.size > this->work_buffer_len) {
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);
if (ptr == NULL) {
if (!ptr) {
return SDL_OutOfMemory();
}
this->work_buffer = ptr;
@@ -181,7 +181,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS)
if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) {
return (Uint8 *)buffer;
}
SDL_assert(buffer == NULL);
SDL_assert(!buffer);
}
return (Uint8 *)buffer;
@@ -189,7 +189,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS)
static void WASAPI_PlayDevice(_THIS)
{
if (this->hidden->render != NULL) { /* definitely activated? */
if (this->hidden->render) { /* definitely activated? */
/* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */
WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0));
}
@@ -407,7 +407,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
HRESULT ret = S_OK;
DWORD streamflags = 0;
SDL_assert(client != NULL);
SDL_assert(client);
#if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */
this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
@@ -415,7 +415,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
this->hidden->event = CreateEventW(NULL, 0, 0, NULL);
#endif
if (this->hidden->event == NULL) {
if (!this->hidden->event) {
return WIN_SetError("WASAPI can't create an event handle");
}
@@ -424,7 +424,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret);
}
SDL_assert(waveformat != NULL);
SDL_assert(waveformat);
this->hidden->waveformat = waveformat;
this->spec.channels = (Uint8)waveformat->nChannels;
@@ -502,7 +502,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret);
}
SDL_assert(capture != NULL);
SDL_assert(capture);
this->hidden->capture = capture;
ret = IAudioClient_Start(client);
if (FAILED(ret)) {
@@ -516,7 +516,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret);
}
SDL_assert(render != NULL);
SDL_assert(render);
this->hidden->render = render;
ret = IAudioClient_Start(client);
if (FAILED(ret)) {
@@ -537,7 +537,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
+2 -2
View File
@@ -120,11 +120,11 @@ int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery)
IMMDevice_Release(device);
if (FAILED(ret)) {
SDL_assert(this->hidden->client == NULL);
SDL_assert(!this->hidden->client);
return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret);
}
SDL_assert(this->hidden->client != NULL);
SDL_assert(this->hidden->client);
if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */
return -1;
}

Some files were not shown because too many files have changed in this diff Show More