Audio_Close/Audio_Stop don't need to return anything

This commit is contained in:
UnknownShadow200 2021-07-23 11:00:27 +10:00
parent 7c16d1e584
commit 16ce6c7506
3 changed files with 13 additions and 17 deletions

View File

@ -39,7 +39,7 @@ Otherwise, you will have to [compile the game yourself](#using-visual-studio-com
### Compiling - Windows ### Compiling - Windows
##### Using Visual Studio ##### 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) 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)

View File

@ -242,9 +242,9 @@ cc_result Audio_Play(struct AudioContext* ctx) {
return _alGetError(); return _alGetError();
} }
cc_result Audio_Stop(struct AudioContext* ctx) { void Audio_Stop(struct AudioContext* ctx) {
_alSourceStop(ctx->source); _alSourceStop(ctx->source);
return _alGetError(); _alGetError();
} }
cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available) { 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_Play(struct AudioContext* ctx) { return 0; }
cc_result Audio_Stop(struct AudioContext* ctx) { void Audio_Stop(struct AudioContext* ctx) {
if (!ctx->handle) return 0; if (ctx->handle) waveOutReset(ctx->handle);
return waveOutReset(ctx->handle);
} }
cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available) { 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); return (*ctx->bqPlayerPlayer)->SetPlayState(ctx->bqPlayerPlayer, SL_PLAYSTATE_PLAYING);
} }
cc_result Audio_Stop(struct AudioContext* ctx) { void Audio_Stop(struct AudioContext* ctx) {
if (!ctx->bqPlayerPlayer) return 0; if (!ctx->bqPlayerPlayer) return;
/* According to OpenSL ES spec, Clear can never fail anyways */
(*ctx->bqPlayerQueue)->Clear(ctx->bqPlayerQueue); (*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) { 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); return Backend_SetFormat(ctx, format);
} }
cc_result Audio_Close(struct AudioContext* ctx) { void Audio_Close(struct AudioContext* ctx) {
cc_bool finished; cc_bool finished;
Audio_Stop(ctx); Audio_Stop(ctx);
Audio_IsFinished(ctx, &finished); /* unqueue buffers */ Audio_IsFinished(ctx, &finished); /* unqueue buffers */
@ -605,7 +603,7 @@ cc_result Audio_Close(struct AudioContext* ctx) {
ctx->count = 0; ctx->count = 0;
ctx->format.channels = 0; ctx->format.channels = 0;
ctx->format.sampleRate = 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; int i;
for (i = 0; i < AUDIO_MAX_HANDLES; i++) { for (i = 0; i < AUDIO_MAX_HANDLES; i++) {
if (!outputs[i].ctx.count) continue; if (!outputs[i].ctx.count) continue;
Audio_Close(&outputs[i].ctx); Audio_Close(&outputs[i].ctx);
outputs[i].ctx.count = 0;
Mem_Free(outputs[i].buffer); Mem_Free(outputs[i].buffer);
outputs[i].buffer = NULL; outputs[i].buffer = NULL;

View File

@ -27,8 +27,8 @@ struct AudioFormat { cc_uint16 channels; int sampleRate; };
/* Initialises an audio context. */ /* Initialises an audio context. */
void Audio_Init(struct AudioContext* ctx, int buffers); void Audio_Init(struct AudioContext* ctx, int buffers);
/* Stops playing audio, unqueues buffers, then frees the audio context. */ /* Stops playing audio, and then frees the audio context. */
cc_result Audio_Close(struct AudioContext* ctx); void Audio_Close(struct AudioContext* ctx);
/* Returns the format audio is played in. */ /* Returns the format audio is played in. */
struct AudioFormat* Audio_GetFormat(struct AudioContext* ctx); struct AudioFormat* Audio_GetFormat(struct AudioContext* ctx);
/* Sets the format of the audio data to be played. */ /* 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. */ /* Begins playing audio. Audio_BufferData must have been used before this. */
cc_result Audio_Play(struct AudioContext* ctx); cc_result Audio_Play(struct AudioContext* ctx);
/* Immediately stops the currently playing audio. */ /* 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. */ /* Returns whether the given buffer is available for playing data. */
cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available); cc_result Audio_IsAvailable(struct AudioContext* ctx, int idx, cc_bool* available);
/* Returns whether all buffers have finished playing. */ /* Returns whether all buffers have finished playing. */