mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
sounds work.. one time
This commit is contained in:
parent
288fe4b2ce
commit
c37f2ee0d4
25
src/Audio.c
25
src/Audio.c
@ -726,19 +726,16 @@ extern int interop_InitAudio(void);
|
|||||||
extern int interop_AudioCreate(void);
|
extern int interop_AudioCreate(void);
|
||||||
extern void interop_AudioClose(int contextID);
|
extern void interop_AudioClose(int contextID);
|
||||||
extern int interop_AudioPlay(int contextID, const char* name);
|
extern int interop_AudioPlay(int contextID, const char* name);
|
||||||
|
extern int interop_AudioPoll(int contetID, int* inUse);
|
||||||
extern int interop_AudioDescribe(int res, char* buffer, int bufferLen);
|
extern int interop_AudioDescribe(int res, char* buffer, int bufferLen);
|
||||||
|
|
||||||
static cc_bool AudioBackend_Init(void) {
|
static cc_bool AudioBackend_Init(void) {
|
||||||
cc_result res = interop_InitAudio();
|
cc_result res = interop_InitAudio();
|
||||||
if (res) { AudioWarn(res, "initing WebAudio context"); return false; }
|
if (res) { AudioWarn(res, "initing WebAudio context"); return false; }
|
||||||
|
|
||||||
InitFakeSounds();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio_Init(struct AudioContext* ctx, int buffers) {
|
void Audio_Init(struct AudioContext* ctx, int buffers) { }
|
||||||
}
|
|
||||||
|
|
||||||
void Audio_Close(struct AudioContext* ctx) {
|
void Audio_Close(struct AudioContext* ctx) {
|
||||||
if (ctx->contextID) interop_AudioClose(ctx->contextID);
|
if (ctx->contextID) interop_AudioClose(ctx->contextID);
|
||||||
ctx->contextID = 0;
|
ctx->contextID = 0;
|
||||||
@ -747,17 +744,16 @@ void Audio_Close(struct AudioContext* ctx) {
|
|||||||
cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate) {
|
cc_result Audio_SetFormat(struct AudioContext* ctx, int channels, int sampleRate) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size) {
|
cc_result Audio_QueueData(struct AudioContext* ctx, void* data, cc_uint32 size) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
cc_result Audio_Play(struct AudioContext* ctx) { return ERR_NOT_SUPPORTED; }
|
||||||
cc_result Audio_Play(struct AudioContext* ctx) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
cc_result Audio_Poll(struct AudioContext* ctx, int* inUse) {
|
||||||
return ERR_NOT_SUPPORTED;
|
if (ctx->contextID)
|
||||||
|
return interop_AudioPoll(ctx->contextID, inUse);
|
||||||
|
|
||||||
|
*inUse = 0; return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Audio_FastPlay(struct AudioContext* ctx, int channels, int sampleRate) {
|
cc_bool Audio_FastPlay(struct AudioContext* ctx, int channels, int sampleRate) {
|
||||||
@ -1053,6 +1049,13 @@ static void Sounds_LoadFile(const cc_string* path, void* obj) {
|
|||||||
/* TODO this is a pretty terrible solution */
|
/* TODO this is a pretty terrible solution */
|
||||||
#ifdef CC_BUILD_WEBAUDIO
|
#ifdef CC_BUILD_WEBAUDIO
|
||||||
static void InitWebSounds(void) {
|
static void InitWebSounds(void) {
|
||||||
|
stepBoard.groups[SOUND_GRASS].sounds[0].data = "step_grass1";
|
||||||
|
stepBoard.groups[SOUND_GRASS].sounds[1].data = "step_grass2";
|
||||||
|
stepBoard.groups[SOUND_GRASS].count = 2;
|
||||||
|
|
||||||
|
digBoard.groups[SOUND_GRASS].sounds[0].data = "dig_grass1";
|
||||||
|
digBoard.groups[SOUND_GRASS].sounds[1].data = "dig_grass2";
|
||||||
|
digBoard.groups[SOUND_GRASS].count = 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -705,19 +705,28 @@ mergeInto(LibraryManager.library, {
|
|||||||
source.stop();
|
source.stop();
|
||||||
AUDIO.sources[ctxID - 1|0] = null;
|
AUDIO.sources[ctxID - 1|0] = null;
|
||||||
},
|
},
|
||||||
|
interop_AudioPoll: function(ctxID, inUse) {
|
||||||
|
var source = AUDIO.sources[ctxID - 1|0];
|
||||||
|
HEAP32[inUse >> 2] = 0;
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
interop_AudioPlay: function(ctxID, name) {
|
interop_AudioPlay: function(ctxID, name) {
|
||||||
var source = AUDIO.sources[ctxID - 1|0];
|
var source = AUDIO.sources[ctxID - 1|0];
|
||||||
var name_ = UTF8ToString(name);
|
var name_ = UTF8ToString(name);
|
||||||
|
|
||||||
// have we already downloaded or are downloading this file?
|
// do we need to download this file?
|
||||||
if (!AUDIO.seen.hasOwnProperty(name_)) {
|
if (!AUDIO.seen.hasOwnProperty(name_)) {
|
||||||
Audio.seen[name_] = true;
|
AUDIO.seen[name_] = true;
|
||||||
_interop_AudioDownload(name_);
|
_interop_AudioDownload(name_);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
source.buffer = AUDIO.buffers[name_];
|
// still downloading or failed to download this file
|
||||||
source.connect(audioCtx.destination);
|
var buffer = AUDIO.buffers[name_];
|
||||||
|
if (!buffer) return 0;
|
||||||
|
|
||||||
|
source.buffer = buffer;
|
||||||
|
source.connect(AUDIO.context.destination);
|
||||||
source.start();
|
source.start();
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user