fix syntax

This commit is contained in:
2026-02-17 16:03:58 -06:00
parent b466fad95f
commit a1fa8020c5
3 changed files with 51 additions and 48 deletions

33
wav.c
View File

@@ -23,14 +23,15 @@ static int wav_calc_size(drwav *wav, drwav_uint64 frames, size_t *out_bytes)
static JSValue wav_make_info(JSContext *js, drwav *wav)
{
JSValue obj = JS_NewObject(js);
JS_SetPropertyStr(js, obj, "channels", JS_NewInt32(js, wav->channels));
JS_SetPropertyStr(js, obj, "sample_rate", JS_NewInt32(js, wav->sampleRate));
JS_SetPropertyStr(js, obj, "bits_per_sample", JS_NewInt32(js, wav->bitsPerSample));
JS_SetPropertyStr(js, obj, "format_tag", JS_NewInt32(js, wav->translatedFormatTag));
JS_SetPropertyStr(js, obj, "total_pcm_frames", JS_NewFloat64(js, (double)wav->totalPCMFrameCount));
JS_SetPropertyStr(js, obj, "bytes_per_frame", JS_NewInt32(js, (int)drwav_get_bytes_per_pcm_frame(wav)));
return obj;
JS_FRAME(js);
JS_ROOT(obj, JS_NewObject(js));
JS_SetPropertyStr(js, obj.val, "channels", JS_NewInt32(js, wav->channels));
JS_SetPropertyStr(js, obj.val, "sample_rate", JS_NewInt32(js, wav->sampleRate));
JS_SetPropertyStr(js, obj.val, "bits_per_sample", JS_NewInt32(js, wav->bitsPerSample));
JS_SetPropertyStr(js, obj.val, "format_tag", JS_NewInt32(js, wav->translatedFormatTag));
JS_SetPropertyStr(js, obj.val, "total_pcm_frames", JS_NewFloat64(js, (double)wav->totalPCMFrameCount));
JS_SetPropertyStr(js, obj.val, "bytes_per_frame", JS_NewInt32(js, (int)drwav_get_bytes_per_pcm_frame(wav)));
JS_RETURN(obj.val);
}
JSC_CCALL(wav_info,
@@ -91,21 +92,21 @@ JSC_CCALL(wav_decode,
bytes_read = (size_t)(frames_read * bytes_per_frame);
}
JSValue result = wav_make_info(js, &wav);
JS_FRAME(js);
JS_ROOT(result, wav_make_info(js, &wav));
// Update format info to reflect f32
JS_SetPropertyStr(js, result, "format", JS_NewString(js, "f32"));
JS_SetPropertyStr(js, result, "bytes_per_frame", JS_NewInt32(js, (int)bytes_per_frame));
JS_SetPropertyStr(js, result.val, "format", JS_NewString(js, "f32"));
JS_SetPropertyStr(js, result.val, "bytes_per_frame", JS_NewInt32(js, (int)bytes_per_frame));
if (pcm_bytes > 0) {
JSValue blob = js_new_blob_stoned_copy(js, pcm, bytes_read);
JS_SetPropertyStr(js, result, "pcm", blob);
JS_SetPropertyStr(js, result.val, "pcm", js_new_blob_stoned_copy(js, pcm, bytes_read));
free(pcm);
} else {
JS_SetPropertyStr(js, result, "pcm", js_new_blob_stoned_copy(js, NULL, 0));
JS_SetPropertyStr(js, result.val, "pcm", js_new_blob_stoned_copy(js, NULL, 0));
}
drwav_uninit(&wav);
return result;
JS_RETURN(result.val);
)
static const JSCFunctionListEntry js_wav_funcs[] = {