mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Remove Audio_Stop from API
This commit is contained in:
parent
907ddd90cd
commit
b30995e14a
15
src/Audio.c
15
src/Audio.c
@ -242,7 +242,9 @@ cc_result Audio_Play(struct AudioContext* ctx) {
|
|||||||
return _alGetError();
|
return _alGetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio_Stop(struct AudioContext* ctx) {
|
static void Backend_Stop(struct AudioContext* ctx) {
|
||||||
|
if (ctx->source == -1) return;
|
||||||
|
|
||||||
_alSourceStop(ctx->source);
|
_alSourceStop(ctx->source);
|
||||||
_alGetError();
|
_alGetError();
|
||||||
}
|
}
|
||||||
@ -387,7 +389,7 @@ 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; }
|
||||||
|
|
||||||
void Audio_Stop(struct AudioContext* ctx) {
|
static void Backend_Stop(struct AudioContext* ctx) {
|
||||||
if (ctx->handle) waveOutReset(ctx->handle);
|
if (ctx->handle) waveOutReset(ctx->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +577,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio_Stop(struct AudioContext* ctx) {
|
static void Backend_Stop(struct AudioContext* ctx) {
|
||||||
if (!ctx->bqPlayerPlayer) return;
|
if (!ctx->bqPlayerPlayer) return;
|
||||||
|
|
||||||
(*ctx->bqPlayerQueue)->Clear(ctx->bqPlayerQueue);
|
(*ctx->bqPlayerQueue)->Clear(ctx->bqPlayerQueue);
|
||||||
@ -635,7 +637,7 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, struct AudioFormat* format)
|
|||||||
|
|
||||||
void Audio_Close(struct AudioContext* ctx) {
|
void Audio_Close(struct AudioContext* ctx) {
|
||||||
cc_bool finished;
|
cc_bool finished;
|
||||||
Audio_Stop(ctx);
|
Backend_Stop(ctx);
|
||||||
Audio_IsFinished(ctx, &finished); /* unqueue buffers */
|
Audio_IsFinished(ctx, &finished); /* unqueue buffers */
|
||||||
|
|
||||||
ctx->count = 0;
|
ctx->count = 0;
|
||||||
@ -812,7 +814,6 @@ static void Sounds_PlayRaw(struct SoundOutput* output, struct Sound* snd, struct
|
|||||||
void* data = snd->data;
|
void* data = snd->data;
|
||||||
void* tmp;
|
void* tmp;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
if ((res = Audio_SetFormat(&output->ctx, fmt))) { Sounds_Fail(res); return; }
|
|
||||||
|
|
||||||
/* copy to temp buffer to apply volume */
|
/* copy to temp buffer to apply volume */
|
||||||
if (volume < 100) {
|
if (volume < 100) {
|
||||||
@ -835,6 +836,7 @@ static void Sounds_PlayRaw(struct SoundOutput* output, struct Sound* snd, struct
|
|||||||
Volume_Mix16((cc_int16*)data, snd->size / 2, volume);
|
Volume_Mix16((cc_int16*)data, snd->size / 2, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((res = Audio_SetFormat(&output->ctx, fmt))) { Sounds_Fail(res); return; }
|
||||||
if ((res = Audio_BufferData(&output->ctx, 0, data, snd->size))) { Sounds_Fail(res); return; }
|
if ((res = Audio_BufferData(&output->ctx, 0, data, snd->size))) { Sounds_Fail(res); return; }
|
||||||
if ((res = Audio_Play(&output->ctx))) { Sounds_Fail(res); return; }
|
if ((res = Audio_Play(&output->ctx))) { Sounds_Fail(res); return; }
|
||||||
}
|
}
|
||||||
@ -1027,9 +1029,8 @@ static cc_result Music_PlayOgg(struct Stream* source) {
|
|||||||
if (res) break;
|
if (res) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (music_pendingStop) Audio_Stop(&music_ctx);
|
|
||||||
/* Wait until the buffers finished playing */
|
/* Wait until the buffers finished playing */
|
||||||
for (;;) {
|
while (!music_pendingStop) {
|
||||||
if (Audio_IsFinished(&music_ctx, &finished) || finished) break;
|
if (Audio_IsFinished(&music_ctx, &finished) || finished) break;
|
||||||
Thread_Sleep(10);
|
Thread_Sleep(10);
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ void Audio_PlayStepSound(cc_uint8 type);
|
|||||||
|
|
||||||
#define AUDIO_MAX_BUFFERS 4
|
#define AUDIO_MAX_BUFFERS 4
|
||||||
/* Information about a source of audio. */
|
/* Information about a source of audio. */
|
||||||
struct AudioFormat { cc_uint16 channels; int sampleRate; };
|
struct AudioFormat { int channels, sampleRate; };
|
||||||
#define AudioFormat_Eq(a, b) ((a)->channels == (b)->channels && (a)->sampleRate == (b)->sampleRate)
|
#define AudioFormat_Eq(a, b) ((a)->channels == (b)->channels && (a)->sampleRate == (b)->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, and then frees the audio context. */
|
/* Stops any playing audio and then frees the audio context. */
|
||||||
void 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);
|
||||||
@ -39,8 +39,6 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, struct AudioFormat* format);
|
|||||||
cc_result Audio_BufferData(struct AudioContext* ctx, int idx, void* data, cc_uint32 size);
|
cc_result Audio_BufferData(struct AudioContext* ctx, int idx, void* data, cc_uint32 size);
|
||||||
/* 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. */
|
|
||||||
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. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user