mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
Fix windowws audio backend
This commit is contained in:
parent
56177f94f5
commit
17f0e51a07
@ -66,11 +66,8 @@ cc_result Audio_Play(struct AudioContext* ctx);
|
|||||||
cc_result Audio_Poll(struct AudioContext* ctx, int* inUse);
|
cc_result Audio_Poll(struct AudioContext* ctx, int* inUse);
|
||||||
cc_result Audio_Pause(struct AudioContext* ctx); /* Only implemented with OpenSL ES backend */
|
cc_result Audio_Pause(struct AudioContext* ctx); /* Only implemented with OpenSL ES backend */
|
||||||
|
|
||||||
/* Whether the given audio data can be played without recreating the underlying audio device */
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data);
|
|
||||||
/* Outputs more detailed information about errors with audio. */
|
/* Outputs more detailed information about errors with audio. */
|
||||||
cc_bool Audio_DescribeError(cc_result res, cc_string* dst);
|
cc_bool Audio_DescribeError(cc_result res, cc_string* dst);
|
||||||
|
|
||||||
/* Allocates a group of chunks of data to store audio samples */
|
/* Allocates a group of chunks of data to store audio samples */
|
||||||
void Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks);
|
void Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks);
|
||||||
/* Frees a previously allocated group of chunks of data */
|
/* Frees a previously allocated group of chunks of data */
|
||||||
|
@ -10,6 +10,9 @@ void Audio_Warn(cc_result res, const char* action) {
|
|||||||
Logger_Warn(res, action, Audio_DescribeError);
|
Logger_Warn(res, action, Audio_DescribeError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Whether the given audio data can be played without recreating the underlying audio device */
|
||||||
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data);
|
||||||
|
|
||||||
/* Common/Base methods */
|
/* Common/Base methods */
|
||||||
static void AudioBase_Clear(struct AudioContext* ctx);
|
static void AudioBase_Clear(struct AudioContext* ctx);
|
||||||
static cc_bool AudioBase_AdjustSound(struct AudioContext* ctx, void** data, cc_uint32* size);
|
static cc_bool AudioBase_AdjustSound(struct AudioContext* ctx, void** data, cc_uint32* size);
|
||||||
@ -264,7 +267,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
*inUse = ctx->count - ctx->free; return 0;
|
*inUse = ctx->count - ctx->free; return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
/* Channels/Sample rate is per buffer, not a per source property */
|
/* Channels/Sample rate is per buffer, not a per source property */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -430,7 +433,7 @@ cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate
|
|||||||
void Audio_SetVolume(struct AudioContext* ctx, int volume) { ctx->volume = volume; }
|
void Audio_SetVolume(struct AudioContext* ctx, int volume) { ctx->volume = volume; }
|
||||||
|
|
||||||
cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 dataSize) {
|
cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 dataSize) {
|
||||||
cc_result res = 0;
|
cc_result res;
|
||||||
WAVEHDR* hdr;
|
WAVEHDR* hdr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -442,8 +445,8 @@ cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 data
|
|||||||
if (!(hdr->dwFlags & WHDR_DONE)) continue;
|
if (!(hdr->dwFlags & WHDR_DONE)) continue;
|
||||||
|
|
||||||
Mem_Set(hdr, 0, sizeof(WAVEHDR));
|
Mem_Set(hdr, 0, sizeof(WAVEHDR));
|
||||||
hdr->lpData = (LPSTR)ctx->_tmpData;
|
hdr->lpData = (LPSTR)chunk;
|
||||||
hdr->dwBufferLength = ctx->_tmpSize;
|
hdr->dwBufferLength = dataSize;
|
||||||
hdr->dwLoops = 1;
|
hdr->dwLoops = 1;
|
||||||
|
|
||||||
if ((res = waveOutPrepareHeader(ctx->handle, hdr, sizeof(WAVEHDR)))) return res;
|
if ((res = waveOutPrepareHeader(ctx->handle, hdr, sizeof(WAVEHDR)))) return res;
|
||||||
@ -475,7 +478,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
int channels = data->channels;
|
int channels = data->channels;
|
||||||
int sampleRate = Audio_AdjustSampleRate(data->sampleRate, data->rate);
|
int sampleRate = Audio_AdjustSampleRate(data->sampleRate, data->rate);
|
||||||
return !ctx->channels || (ctx->channels == channels && ctx->sampleRate == sampleRate);
|
return !ctx->channels || (ctx->channels == channels && ctx->sampleRate == sampleRate);
|
||||||
@ -703,7 +706,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
return !ctx->channels || (ctx->channels == data->channels && ctx->sampleRate == data->sampleRate);
|
return !ctx->channels || (ctx->channels == data->channels && ctx->sampleRate == data->sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,13 +829,11 @@ cc_result Audio_QueueChunk(struct AudioContext* ctx, void* chunk, cc_uint32 data
|
|||||||
for (int i = 0; i < ctx->count; i++)
|
for (int i = 0; i < ctx->count; i++)
|
||||||
{
|
{
|
||||||
buf = &ctx->bufs[i];
|
buf = &ctx->bufs[i];
|
||||||
//Platform_Log2("QUEUE_CHUNK: %i = %i", &ctx->chanID, &buf->status);
|
|
||||||
if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING)
|
if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
buf->data_pcm16 = chunk;
|
buf->data_pcm16 = chunk;
|
||||||
buf->nsamples = dataSize / (sizeof(cc_int16) * (ctx->stereo ? 2 : 1));
|
buf->nsamples = dataSize / (sizeof(cc_int16) * (ctx->stereo ? 2 : 1));
|
||||||
//Platform_Log1("PLAYING ON: %i", &ctx->chanID);
|
|
||||||
DSP_FlushDataCache(buf->data_pcm16, dataSize);
|
DSP_FlushDataCache(buf->data_pcm16, dataSize);
|
||||||
ndspChnWaveBufAdd(ctx->chanID, buf);
|
ndspChnWaveBufAdd(ctx->chanID, buf);
|
||||||
return 0;
|
return 0;
|
||||||
@ -850,7 +851,6 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
for (int i = 0; i < ctx->count; i++)
|
for (int i = 0; i < ctx->count; i++)
|
||||||
{
|
{
|
||||||
buf = &ctx->bufs[i];
|
buf = &ctx->bufs[i];
|
||||||
//Platform_Log2("CHECK_CHUNK: %i = %i", &ctx->chanID, &buf->status);
|
|
||||||
if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING) {
|
if (buf->status == NDSP_WBUF_QUEUED || buf->status == NDSP_WBUF_PLAYING) {
|
||||||
count++; continue;
|
count++; continue;
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,7 +1061,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,7 +1231,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1310,7 +1310,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
return interop_AudioPoll(ctx->contextID, inUse);
|
return interop_AudioPoll(ctx->contextID, inUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) {
|
||||||
/* Channels/Sample rate is per buffer, not a per source property */
|
/* Channels/Sample rate is per buffer, not a per source property */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1364,7 +1364,7 @@ cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) { return false; }
|
static cc_bool Audio_FastPlay(struct AudioContext* ctx, struct AudioData* data) { return false; }
|
||||||
|
|
||||||
cc_bool Audio_DescribeError(cc_result res, cc_string* dst) { return false; }
|
cc_bool Audio_DescribeError(cc_result res, cc_string* dst) { return false; }
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user