From 16ce6c75068de80a417571b48830b4e41b2ee8b5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 23 Jul 2021 11:00:27 +1000 Subject: [PATCH] Audio_Close/Audio_Stop don't need to return anything --- readme.md | 2 +- src/Audio.c | 22 +++++++++------------- src/Audio.h | 6 +++--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/readme.md b/readme.md index fde249315..aa9aaaf80 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ Otherwise, you will have to [compile the game yourself](#using-visual-studio-com ### Compiling - Windows ##### Using Visual Studio -Open ClassiCube.sln and compile it. +Open ClassiCube.sln *(File -> Open -> Project/Solution)* and compile it *(Build -> Build Solution)*. If you get a ```The Windows SDK version 5.1 was not found``` compilation error, [see here for how to fix](doc/compile-fixes.md#visual-studio-unsupported-platform-toolset) diff --git a/src/Audio.c b/src/Audio.c index bb038d94e..816f895ab 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -242,9 +242,9 @@ cc_result Audio_Play(struct AudioContext* ctx) { return _alGetError(); } -cc_result Audio_Stop(struct AudioContext* ctx) { +void Audio_Stop(struct AudioContext* ctx) { _alSourceStop(ctx->source); - return _alGetError(); + _alGetError(); } cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available) { @@ -349,9 +349,8 @@ cc_result Audio_BufferData(struct AudioContext* ctx, int idx, void* data, cc_uin cc_result Audio_Play(struct AudioContext* ctx) { return 0; } -cc_result Audio_Stop(struct AudioContext* ctx) { - if (!ctx->handle) return 0; - return waveOutReset(ctx->handle); +void Audio_Stop(struct AudioContext* ctx) { + if (ctx->handle) waveOutReset(ctx->handle); } cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available) { @@ -538,12 +537,11 @@ cc_result Audio_Play(struct AudioContext* ctx) { return (*ctx->bqPlayerPlayer)->SetPlayState(ctx->bqPlayerPlayer, SL_PLAYSTATE_PLAYING); } -cc_result Audio_Stop(struct AudioContext* ctx) { - if (!ctx->bqPlayerPlayer) return 0; +void Audio_Stop(struct AudioContext* ctx) { + if (!ctx->bqPlayerPlayer) return; - /* According to OpenSL ES spec, Clear can never fail anyways */ (*ctx->bqPlayerQueue)->Clear(ctx->bqPlayerQueue); - return (*ctx->bqPlayerPlayer)->SetPlayState(ctx->bqPlayerPlayer, SL_PLAYSTATE_STOPPED); + (*ctx->bqPlayerPlayer)->SetPlayState(ctx->bqPlayerPlayer, SL_PLAYSTATE_STOPPED); } cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available) { @@ -597,7 +595,7 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, struct AudioFormat* format) return Backend_SetFormat(ctx, format); } -cc_result Audio_Close(struct AudioContext* ctx) { +void Audio_Close(struct AudioContext* ctx) { cc_bool finished; Audio_Stop(ctx); Audio_IsFinished(ctx, &finished); /* unqueue buffers */ @@ -605,7 +603,7 @@ cc_result Audio_Close(struct AudioContext* ctx) { ctx->count = 0; ctx->format.channels = 0; ctx->format.sampleRate = 0; - return Backend_Reset(ctx); + Backend_Reset(ctx); } @@ -874,9 +872,7 @@ static void Sounds_FreeOutputs(struct SoundOutput* outputs) { int i; for (i = 0; i < AUDIO_MAX_HANDLES; i++) { if (!outputs[i].ctx.count) continue; - Audio_Close(&outputs[i].ctx); - outputs[i].ctx.count = 0; Mem_Free(outputs[i].buffer); outputs[i].buffer = NULL; diff --git a/src/Audio.h b/src/Audio.h index 66a46f746..29e540a25 100644 --- a/src/Audio.h +++ b/src/Audio.h @@ -27,8 +27,8 @@ struct AudioFormat { cc_uint16 channels; int sampleRate; }; /* Initialises an audio context. */ void Audio_Init(struct AudioContext* ctx, int buffers); -/* Stops playing audio, unqueues buffers, then frees the audio context. */ -cc_result Audio_Close(struct AudioContext* ctx); +/* Stops playing audio, and then frees the audio context. */ +void Audio_Close(struct AudioContext* ctx); /* Returns the format audio is played in. */ struct AudioFormat* Audio_GetFormat(struct AudioContext* ctx); /* Sets the format of the audio data to be played. */ @@ -40,7 +40,7 @@ cc_result Audio_BufferData(struct AudioContext* ctx, int idx, void* data, cc_uin /* Begins playing audio. Audio_BufferData must have been used before this. */ cc_result Audio_Play(struct AudioContext* ctx); /* Immediately stops the currently playing audio. */ -cc_result Audio_Stop(struct AudioContext* ctx); +void Audio_Stop(struct AudioContext* ctx); /* Returns whether the given buffer is available for playing data. */ cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available); /* Returns whether all buffers have finished playing. */