Cleanup add brace (#6545)
* Add braces after if conditions
* More add braces after if conditions
* Add braces after while() conditions
* Fix compilation because of macro being modified
* Add braces to for loop
* Add braces after if/goto
* Move comments up
* Remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements after merge
* Fix inconsistent patterns are xxx == NULL vs !xxx
* More "{}" for "if() break;" and "if() continue;"
* More "{}" after if() short statement
* More "{}" after "if () return;" statement
* More fix inconsistent patterns are xxx == NULL vs !xxx
* Revert some modificaion on SDL_RLEaccel.c
* SDL_RLEaccel: no short statement
* Cleanup 'if' where the bracket is in a new line
* Cleanup 'while' where the bracket is in a new line
* Cleanup 'for' where the bracket is in a new line
* Cleanup 'else' where the bracket is in a new line
This commit is contained in:
@@ -509,11 +509,9 @@ SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
|
||||
} else {
|
||||
mark_device_removed(handle, current_audio.outputDevices, ¤t_audio.outputDevicesRemoved);
|
||||
}
|
||||
for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++)
|
||||
{
|
||||
for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++) {
|
||||
device = open_devices[device_index];
|
||||
if (device != NULL && device->handle == handle)
|
||||
{
|
||||
if (device != NULL && device->handle == handle) {
|
||||
device_was_opened = SDL_TRUE;
|
||||
SDL_OpenedAudioDeviceDisconnected(device);
|
||||
break;
|
||||
@@ -977,7 +975,7 @@ SDL_AudioInit(const char *driver_name)
|
||||
}
|
||||
} else {
|
||||
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
|
||||
if(bootstrap[i]->demand_only) {
|
||||
if (bootstrap[i]->demand_only) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ ResamplerPadding(const int inrate, const int outrate)
|
||||
return 0;
|
||||
}
|
||||
if (inrate > outrate) {
|
||||
return (int) SDL_ceilf(((float) (RESAMPLER_SAMPLES_PER_ZERO_CROSSING * inrate) / ((float) outrate)));
|
||||
return (int)SDL_ceilf(((float)(RESAMPLER_SAMPLES_PER_ZERO_CROSSING * inrate) / ((float)outrate)));
|
||||
}
|
||||
return RESAMPLER_SAMPLES_PER_ZERO_CROSSING;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
|
||||
outtime = outtimeincr * i;
|
||||
}
|
||||
|
||||
return outframes * chans * sizeof (float);
|
||||
return outframes * chans * sizeof(float);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -485,7 +485,7 @@ SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format
|
||||
|
||||
/* we keep no streaming state here, so pad with silence on both ends. */
|
||||
padding = (float *) SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof (float));
|
||||
if (!padding) {
|
||||
if (padding == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
@@ -583,7 +583,7 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels,
|
||||
!!! FIXME in 2.1: We need to store data for this resampler, because the cvt structure doesn't store the original sample rates,
|
||||
!!! FIXME in 2.1: so we steal the ninth and tenth slot. :( */
|
||||
if (cvt->filter_index >= (SDL_AUDIOCVT_MAX_FILTERS-2)) {
|
||||
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS-2);
|
||||
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS - 2);
|
||||
}
|
||||
cvt->filters[SDL_AUDIOCVT_MAX_FILTERS-1] = (SDL_AudioFilter) (uintptr_t) src_rate;
|
||||
cvt->filters[SDL_AUDIOCVT_MAX_FILTERS] = (SDL_AudioFilter) (uintptr_t) dst_rate;
|
||||
@@ -785,7 +785,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||
}
|
||||
|
||||
cvt->needed = (cvt->filter_index != 0);
|
||||
return (cvt->needed);
|
||||
return cvt->needed;
|
||||
}
|
||||
|
||||
typedef int (*SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen);
|
||||
@@ -832,7 +832,7 @@ EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
||||
ptr = stream->work_buffer_base;
|
||||
} else {
|
||||
ptr = (Uint8 *) SDL_realloc(stream->work_buffer_base, newlen + 32);
|
||||
if (!ptr) {
|
||||
if (ptr == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -908,12 +908,12 @@ SetupLibSampleRateResampling(SDL_AudioStream *stream)
|
||||
|
||||
if (SRC_available) {
|
||||
state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
|
||||
if (!state) {
|
||||
if (state == NULL) {
|
||||
SDL_SetError("src_new() failed: %s", SRC_src_strerror(result));
|
||||
}
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
if (state == NULL) {
|
||||
SDL_CleanupAudioStreamResampler_SRC(stream);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -980,7 +980,7 @@ SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||
SDL_AudioStream *retval;
|
||||
|
||||
retval = (SDL_AudioStream *) SDL_calloc(1, sizeof (SDL_AudioStream));
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in
|
||||
#endif
|
||||
|
||||
workbuf = EnsureStreamBufferSize(stream, workbuflen);
|
||||
if (!workbuf) {
|
||||
if (workbuf == NULL) {
|
||||
return -1; /* probably out of memory. */
|
||||
}
|
||||
|
||||
@@ -1190,8 +1190,9 @@ SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, in
|
||||
|
||||
if (maxputbytes) {
|
||||
const int maxbytes = *maxputbytes;
|
||||
if (buflen > maxbytes)
|
||||
if (buflen > maxbytes) {
|
||||
buflen = maxbytes;
|
||||
}
|
||||
*maxputbytes -= buflen;
|
||||
}
|
||||
|
||||
@@ -1214,10 +1215,10 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
||||
SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
|
||||
#endif
|
||||
|
||||
if (!stream) {
|
||||
if (stream == NULL) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
if (!buf) {
|
||||
if (buf == NULL) {
|
||||
return SDL_InvalidParamError("buf");
|
||||
}
|
||||
if (len == 0) {
|
||||
@@ -1269,7 +1270,7 @@ SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
||||
|
||||
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
if (stream == NULL) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
|
||||
@@ -1287,8 +1288,9 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
||||
const SDL_bool first_run = stream->first_run;
|
||||
const int filled = stream->staging_buffer_filled;
|
||||
int actual_input_frames = filled / stream->src_sample_frame_size;
|
||||
if (!first_run)
|
||||
if (!first_run) {
|
||||
actual_input_frames += stream->resampler_padding_samples / stream->pre_resample_channels;
|
||||
}
|
||||
|
||||
if (actual_input_frames > 0) { /* don't bother if nothing to flush. */
|
||||
/* This is how many bytes we're expecting without silence appended. */
|
||||
@@ -1327,10 +1329,10 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
|
||||
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
|
||||
#endif
|
||||
|
||||
if (!stream) {
|
||||
if (stream == NULL) {
|
||||
return SDL_InvalidParamError("stream");
|
||||
}
|
||||
if (!buf) {
|
||||
if (buf == NULL) {
|
||||
return SDL_InvalidParamError("buf");
|
||||
}
|
||||
if (len <= 0) {
|
||||
@@ -1340,20 +1342,20 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
|
||||
return SDL_SetError("Can't request partial sample frames");
|
||||
}
|
||||
|
||||
return (int) SDL_ReadFromDataQueue(stream->queue, buf, len);
|
||||
return (int)SDL_ReadFromDataQueue(stream->queue, buf, len);
|
||||
}
|
||||
|
||||
/* number of converted/resampled bytes available */
|
||||
int
|
||||
SDL_AudioStreamAvailable(SDL_AudioStream *stream)
|
||||
{
|
||||
return stream ? (int) SDL_CountDataQueue(stream->queue) : 0;
|
||||
return stream ? (int)SDL_CountDataQueue(stream->queue) : 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AudioStreamClear(SDL_AudioStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
if (stream == NULL) {
|
||||
SDL_InvalidParamError("stream");
|
||||
} else {
|
||||
SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
|
||||
|
||||
@@ -83,8 +83,9 @@ SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int classic, int (*
|
||||
const char *audiodev;
|
||||
char audiopath[1024];
|
||||
|
||||
if (test == NULL)
|
||||
if (test == NULL) {
|
||||
test = test_stub;
|
||||
}
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
||||
|
||||
@@ -818,7 +818,7 @@ IMA_ADPCM_Init(WaveFile *file, size_t datalength)
|
||||
/* There's no specification for this, but it's basically the same
|
||||
* format because the extensible header has wSampePerBlocks too.
|
||||
*/
|
||||
} else {
|
||||
} else {
|
||||
/* The Standards Update says there 'should' be 2 bytes for wSamplesPerBlock. */
|
||||
if (chunk->size >= 20 && format->extsize >= 2) {
|
||||
format->samplesperblock = chunk->data[18] | ((Uint16)chunk->data[19] << 8);
|
||||
@@ -899,14 +899,18 @@ IMA_ADPCM_ProcessNibble(Sint8 *cindex, Sint16 lastsample, Uint8 nybble)
|
||||
* (nybble & 0x8 ? -1 : 1) * ((nybble & 0x7) * step / 4 + step / 8)
|
||||
*/
|
||||
delta = step >> 3;
|
||||
if (nybble & 0x04)
|
||||
if (nybble & 0x04) {
|
||||
delta += step;
|
||||
if (nybble & 0x02)
|
||||
}
|
||||
if (nybble & 0x02) {
|
||||
delta += step >> 1;
|
||||
if (nybble & 0x01)
|
||||
}
|
||||
if (nybble & 0x01) {
|
||||
delta += step >> 2;
|
||||
if (nybble & 0x08)
|
||||
}
|
||||
if (nybble & 0x08) {
|
||||
delta = -delta;
|
||||
}
|
||||
|
||||
sample = lastsample + delta;
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ SDL_bool aaudio_DetectBrokenPlayState( void )
|
||||
int64_t framePosition, timeNanoseconds;
|
||||
aaudio_result_t res;
|
||||
|
||||
if ( !audioDevice || !audioDevice->hidden ) {
|
||||
if (audioDevice == NULL || !audioDevice->hidden ) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ get_audio_device(void *handle, const int channels)
|
||||
const char *device;
|
||||
|
||||
if (handle != NULL) {
|
||||
return (const char *) handle;
|
||||
return (const char *)handle;
|
||||
}
|
||||
|
||||
/* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */
|
||||
@@ -398,8 +398,7 @@ ALSA_PlayDevice(_THIS)
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (status == 0) {
|
||||
} else if (status == 0) {
|
||||
/* No frames were written (no available space in pcm device).
|
||||
Allow other threads to catch up. */
|
||||
Uint32 delay = (frames_left / 2 * 1000) / this->spec.freq;
|
||||
@@ -414,7 +413,7 @@ ALSA_PlayDevice(_THIS)
|
||||
static Uint8 *
|
||||
ALSA_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
return this->hidden->mixbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -438,8 +437,7 @@ ALSA_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||
if (status == -EAGAIN) {
|
||||
ALSA_snd_pcm_wait(this->hidden->pcm_handle, wait_time);
|
||||
status = 0;
|
||||
}
|
||||
else if (status < 0) {
|
||||
} else if (status < 0) {
|
||||
/*printf("ALSA: capture error %d\n", status);*/
|
||||
status = ALSA_snd_pcm_recover(this->hidden->pcm_handle, status, 0);
|
||||
if (status < 0) {
|
||||
@@ -500,7 +498,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
status = ALSA_snd_pcm_hw_params_set_period_size_near(
|
||||
this->hidden->pcm_handle, hwparams, &persize, NULL);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Need to at least double buffer */
|
||||
@@ -508,19 +506,19 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
status = ALSA_snd_pcm_hw_params_set_periods_min(
|
||||
this->hidden->pcm_handle, hwparams, &periods, NULL);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = ALSA_snd_pcm_hw_params_set_periods_first(
|
||||
this->hidden->pcm_handle, hwparams, &periods, NULL);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* "set" the hardware with the desired parameters */
|
||||
status = ALSA_snd_pcm_hw_params(this->hidden->pcm_handle, hwparams);
|
||||
if ( status < 0 ) {
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
this->spec.samples = persize;
|
||||
@@ -536,7 +534,7 @@ ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
persize, periods, bufsize);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -572,8 +570,7 @@ ALSA_OpenDevice(_THIS, const char *devname)
|
||||
SND_PCM_NONBLOCK);
|
||||
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't open audio device: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't open audio device: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
|
||||
this->hidden->pcm_handle = pcm_handle;
|
||||
@@ -582,16 +579,14 @@ ALSA_OpenDevice(_THIS, const char *devname)
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
status = ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't get hardware config: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't get hardware config: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
|
||||
/* SDL only uses interleaved sample output */
|
||||
status = ALSA_snd_pcm_hw_params_set_access(pcm_handle, hwparams,
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't set interleaved access: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't set interleaved access: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
|
||||
/* Try for a closest match on audio format */
|
||||
@@ -673,8 +668,7 @@ ALSA_OpenDevice(_THIS, const char *devname)
|
||||
status = ALSA_snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams,
|
||||
&rate, NULL);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't set audio frequency: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't set audio frequency: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
this->spec.freq = rate;
|
||||
|
||||
@@ -688,24 +682,20 @@ ALSA_OpenDevice(_THIS, const char *devname)
|
||||
snd_pcm_sw_params_alloca(&swparams);
|
||||
status = ALSA_snd_pcm_sw_params_current(pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't get software config: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't get software config: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("Couldn't set minimum available samples: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("Couldn't set minimum available samples: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
status =
|
||||
ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't set start threshold: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("ALSA: Couldn't set start threshold: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
status = ALSA_snd_pcm_sw_params(pcm_handle, swparams);
|
||||
if (status < 0) {
|
||||
return SDL_SetError("Couldn't set software audio parameters: %s",
|
||||
ALSA_snd_strerror(status));
|
||||
return SDL_SetError("Couldn't set software audio parameters: %s", ALSA_snd_strerror(status));
|
||||
}
|
||||
|
||||
/* Calculate the final parameters for this audio specification */
|
||||
@@ -746,7 +736,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
|
||||
char *handle = NULL;
|
||||
char *ptr;
|
||||
|
||||
if (!dev) {
|
||||
if (dev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -756,7 +746,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
|
||||
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) {
|
||||
if (desc == NULL) {
|
||||
SDL_free(dev);
|
||||
return;
|
||||
}
|
||||
@@ -776,7 +766,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
|
||||
/*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/
|
||||
|
||||
handle = SDL_strdup(name);
|
||||
if (!handle) {
|
||||
if (handle == NULL) {
|
||||
if (hint) {
|
||||
free(desc);
|
||||
}
|
||||
@@ -789,8 +779,9 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
|
||||
* enumeration time
|
||||
*/
|
||||
SDL_AddAudioDevice(iscapture, desc, NULL, handle);
|
||||
if (hint)
|
||||
if (hint) {
|
||||
free(desc);
|
||||
}
|
||||
dev->name = handle;
|
||||
dev->iscapture = iscapture;
|
||||
dev->next = *pSeen;
|
||||
@@ -829,7 +820,7 @@ 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) {
|
||||
if (name == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -858,17 +849,17 @@ ALSA_HotplugIteration(void)
|
||||
char *name;
|
||||
|
||||
/* if we didn't find a device name prefix we like at all... */
|
||||
if ((!match) && (defaultdev != i)) {
|
||||
if ((match == NULL) && (defaultdev != i)) {
|
||||
continue; /* ...skip anything that isn't the default device. */
|
||||
}
|
||||
|
||||
name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
|
||||
if (!name) {
|
||||
if (name == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* only want physical hardware interfaces */
|
||||
if (!match || (SDL_strncmp(name, match, match_len) == 0)) {
|
||||
if (match == NULL || (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);
|
||||
@@ -893,8 +884,12 @@ ALSA_HotplugIteration(void)
|
||||
}
|
||||
dev->next = seen;
|
||||
seen = dev;
|
||||
if (isinput) have_input = SDL_TRUE;
|
||||
if (isoutput) have_output = SDL_TRUE;
|
||||
if (isinput) {
|
||||
have_input = SDL_TRUE;
|
||||
}
|
||||
if (isoutput) {
|
||||
have_output = SDL_TRUE;
|
||||
}
|
||||
} else {
|
||||
prev = dev;
|
||||
}
|
||||
|
||||
@@ -146,26 +146,24 @@ void ANDROIDAUDIO_PauseDevices(void)
|
||||
{
|
||||
/* TODO: Handle multiple devices? */
|
||||
struct SDL_PrivateAudioData *private;
|
||||
if(audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
if (audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
|
||||
if (SDL_AtomicGet(&audioDevice->paused)) {
|
||||
/* The device is already paused, leave it alone */
|
||||
private->resume = SDL_FALSE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SDL_LockMutex(audioDevice->mixer_lock);
|
||||
SDL_AtomicSet(&audioDevice->paused, 1);
|
||||
private->resume = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(captureDevice != NULL && captureDevice->hidden != NULL) {
|
||||
if (captureDevice != NULL && captureDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) captureDevice->hidden;
|
||||
if (SDL_AtomicGet(&captureDevice->paused)) {
|
||||
/* The device is already paused, leave it alone */
|
||||
private->resume = SDL_FALSE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SDL_LockMutex(captureDevice->mixer_lock);
|
||||
SDL_AtomicSet(&captureDevice->paused, 1);
|
||||
private->resume = SDL_TRUE;
|
||||
@@ -178,7 +176,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
|
||||
{
|
||||
/* TODO: Handle multiple devices? */
|
||||
struct SDL_PrivateAudioData *private;
|
||||
if(audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
if (audioDevice != NULL && audioDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) audioDevice->hidden;
|
||||
if (private->resume) {
|
||||
SDL_AtomicSet(&audioDevice->paused, 0);
|
||||
@@ -187,7 +185,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(captureDevice != NULL && captureDevice->hidden != NULL) {
|
||||
if (captureDevice != NULL && captureDevice->hidden != NULL) {
|
||||
private = (struct SDL_PrivateAudioData *) captureDevice->hidden;
|
||||
if (private->resume) {
|
||||
SDL_AtomicSet(&captureDevice->paused, 0);
|
||||
|
||||
@@ -293,7 +293,7 @@ DSOUND_GetDeviceBuf(_THIS)
|
||||
}
|
||||
if (result != DS_OK) {
|
||||
SetDSerror("DirectSound GetCurrentPosition", result);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
cursor /= this->spec.size;
|
||||
#ifdef DEBUG_SOUND
|
||||
@@ -328,9 +328,9 @@ DSOUND_GetDeviceBuf(_THIS)
|
||||
}
|
||||
if (result != DS_OK) {
|
||||
SetDSerror("DirectSound Lock", result);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
return (this->hidden->locked_buf);
|
||||
return this->hidden->locked_buf;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -65,7 +65,7 @@ DISKAUDIO_PlayDevice(_THIS)
|
||||
static Uint8 *
|
||||
DISKAUDIO_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (_this->hidden->mixbuf);
|
||||
return _this->hidden->mixbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -80,12 +80,13 @@ DSP_OpenDevice(_THIS, const char *devname)
|
||||
|
||||
/* Make sure fragment size stays a power of 2, or OSS fails. */
|
||||
/* I don't know which of these are actually legal values, though... */
|
||||
if (this->spec.channels > 8)
|
||||
if (this->spec.channels > 8) {
|
||||
this->spec.channels = 8;
|
||||
else if (this->spec.channels > 4)
|
||||
} else if (this->spec.channels > 4) {
|
||||
this->spec.channels = 4;
|
||||
else if (this->spec.channels > 2)
|
||||
} else if (this->spec.channels > 2) {
|
||||
this->spec.channels = 2;
|
||||
}
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
@@ -258,13 +259,13 @@ DSP_PlayDevice(_THIS)
|
||||
static Uint8 *
|
||||
DSP_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
return this->hidden->mixbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
DSP_CaptureFromDevice(_THIS, void *buffer, int buflen)
|
||||
{
|
||||
return (int) read(this->hidden->audio_fd, buffer, buflen);
|
||||
return (int)read(this->hidden->audio_fd, buffer, buflen);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -206,7 +206,7 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
|
||||
/* create context */
|
||||
result = MAIN_THREAD_EM_ASM_INT({
|
||||
if(typeof(Module['SDL3']) === 'undefined') {
|
||||
if (typeof(Module['SDL3']) === 'undefined') {
|
||||
Module['SDL3'] = {};
|
||||
}
|
||||
var SDL3 = Module['SDL3'];
|
||||
|
||||
@@ -310,7 +310,7 @@ JACK_OpenDevice(_THIS, const char *devname)
|
||||
}
|
||||
|
||||
devports = JACK_jack_get_ports(client, NULL, NULL, JackPortIsPhysical | sysportflags);
|
||||
if (!devports || !devports[0]) {
|
||||
if (devports == NULL || !devports[0]) {
|
||||
return SDL_SetError("No physical JACK ports available");
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ NETBSDAUDIO_PlayDevice(_THIS)
|
||||
static Uint8 *
|
||||
NETBSDAUDIO_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (this->hidden->mixbuf);
|
||||
return this->hidden->mixbuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ openslES_CreatePCMPlayer(_THIS)
|
||||
it can be done as described here:
|
||||
https://developer.android.com/ndk/guides/audio/opensl/android-extensions.html#floating-point
|
||||
*/
|
||||
if(SDL_GetAndroidSDKVersion() >= 21) {
|
||||
if (SDL_GetAndroidSDKVersion() >= 21) {
|
||||
SDL_AudioFormat test_format;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||
@@ -498,7 +498,7 @@ openslES_CreatePCMPlayer(_THIS)
|
||||
break;
|
||||
}
|
||||
|
||||
if(SDL_AUDIO_ISFLOAT(this->spec.format)) {
|
||||
if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
|
||||
/* Copy all setup into PCM EX structure */
|
||||
format_pcm_ex.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
|
||||
format_pcm_ex.endianness = format_pcm.endianness;
|
||||
|
||||
@@ -1062,7 +1062,7 @@ input_callback(void *data)
|
||||
}
|
||||
|
||||
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
|
||||
if (!pw_buf) {
|
||||
if (pw_buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1186,15 +1186,15 @@ 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 || *app_name == '\0') {
|
||||
if (app_name == NULL || *app_name == '\0') {
|
||||
app_name = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (!app_name || *app_name == '\0') {
|
||||
if (app_name == NULL || *app_name == '\0') {
|
||||
app_name = "SDL Application";
|
||||
}
|
||||
}
|
||||
|
||||
stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
|
||||
if (!stream_name || *stream_name == '\0') {
|
||||
if (stream_name == NULL || *stream_name == '\0') {
|
||||
stream_name = "Audio Stream";
|
||||
}
|
||||
|
||||
@@ -1203,7 +1203,7 @@ 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 || *stream_role == '\0') {
|
||||
if (stream_role == NULL || *stream_role == '\0') {
|
||||
stream_role = "Game";
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,9 @@ static void PS2AUDIO_Deinitialize(void)
|
||||
|
||||
static SDL_bool PS2AUDIO_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
if(init_audio_driver() < 0)
|
||||
if (init_audio_driver() < 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = PS2AUDIO_OpenDevice;
|
||||
|
||||
@@ -102,7 +102,7 @@ PSPAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
|
||||
static void PSPAUDIO_PlayDevice(_THIS)
|
||||
{
|
||||
if (this->spec.freq != 44100){
|
||||
if (this->spec.freq != 44100) {
|
||||
Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
|
||||
SDL_assert(this->spec.channels == 2);
|
||||
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, mixbuf);
|
||||
@@ -128,7 +128,7 @@ static Uint8 *PSPAUDIO_GetDeviceBuf(_THIS)
|
||||
static void PSPAUDIO_CloseDevice(_THIS)
|
||||
{
|
||||
if (this->hidden->channel >= 0) {
|
||||
if (this->spec.freq != 44100){
|
||||
if (this->spec.freq != 44100) {
|
||||
sceAudioSRCChRelease();
|
||||
} else {
|
||||
sceAudioChRelease(this->hidden->channel);
|
||||
|
||||
@@ -49,17 +49,11 @@ static SDL_bool include_monitors = SDL_FALSE;
|
||||
#if (PA_API_VERSION < 12)
|
||||
/** Return non-zero if the passed state is one of the connected states */
|
||||
static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
|
||||
return
|
||||
x == PA_CONTEXT_CONNECTING ||
|
||||
x == PA_CONTEXT_AUTHORIZING ||
|
||||
x == PA_CONTEXT_SETTING_NAME ||
|
||||
x == PA_CONTEXT_READY;
|
||||
return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY;
|
||||
}
|
||||
/** Return non-zero if the passed state is one of the connected states */
|
||||
static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
|
||||
return
|
||||
x == PA_STREAM_CREATING ||
|
||||
x == PA_STREAM_READY;
|
||||
return x == PA_STREAM_CREATING || x == PA_STREAM_READY;
|
||||
}
|
||||
#endif /* pulseaudio <= 0.9.10 */
|
||||
|
||||
@@ -308,7 +302,7 @@ ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context)
|
||||
SDL_assert(mainloop_api); /* this never fails, right? */
|
||||
|
||||
context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName());
|
||||
if (!context) {
|
||||
if (context == NULL) {
|
||||
PULSEAUDIO_pa_mainloop_free(mainloop);
|
||||
return SDL_SetError("pa_context_new() failed");
|
||||
}
|
||||
@@ -541,7 +535,7 @@ FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *h
|
||||
SinkDeviceNameCallback, &h->device_name));
|
||||
}
|
||||
|
||||
return (h->device_name != NULL);
|
||||
return h->device_name != NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -78,7 +78,7 @@ VITAAUD_OpenDevice(_THIS, const char *devname)
|
||||
}
|
||||
}
|
||||
|
||||
if(!test_format) {
|
||||
if (!test_format) {
|
||||
return SDL_SetError("Unsupported audio format");
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ VITAAUD_OpenDevice(_THIS, const char *devname)
|
||||
format = SCE_AUDIO_OUT_MODE_STEREO;
|
||||
}
|
||||
|
||||
if(this->spec.freq < 48000) {
|
||||
if (this->spec.freq < 48000) {
|
||||
port = SCE_AUDIO_OUT_PORT_TYPE_BGM;
|
||||
}
|
||||
|
||||
|
||||
@@ -387,8 +387,7 @@ WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid)
|
||||
if (SDL_wcscmp(i->str, devid) == 0) {
|
||||
if (prev) {
|
||||
prev->next = next;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
deviceid_list = next;
|
||||
}
|
||||
SDL_RemoveAudioDevice(iscapture, i->str);
|
||||
@@ -419,7 +418,7 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENS
|
||||
}
|
||||
|
||||
devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist));
|
||||
if (!devidlist) {
|
||||
if (devidlist == NULL) {
|
||||
return; /* oh well. */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user