feat(audio): add guest voice controls and reliable lifecycle delivery
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
This commit is contained in:
@@ -683,3 +683,34 @@ fn module_with_locals(code: Vec<u8>, syscalls: Vec<SyscallDecl>, local_slots: u1
|
||||
fn asm(source: &str) -> Vec<u8> {
|
||||
assemble(source).expect("assemble")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn audio_controls_quota_and_multiple_frames_are_device_independent() {
|
||||
let dir = temp_cart("audio-controls");
|
||||
let syscalls: Vec<_> = [("stop", 1), ("set_volume", 2), ("set_pan", 2), ("set_pitch", 2)]
|
||||
.into_iter()
|
||||
.map(|(name, arg_slots)| SyscallDecl {
|
||||
module: "audio".into(),
|
||||
name: name.into(),
|
||||
version: 1,
|
||||
arg_slots,
|
||||
ret_slots: 1,
|
||||
})
|
||||
.collect();
|
||||
let mut code = "PUSH_I32 0\nHOSTCALL 0\nPOP_N 1\n".repeat(1021);
|
||||
// Cross a physical tick while retaining the same logical-frame quota.
|
||||
code.push_str(&"NOP\n".repeat(250_001));
|
||||
code.push_str("PUSH_I32 0\nPUSH_I32 255\nHOSTCALL 1\nPOP_N 1\nPUSH_I32 0\nPUSH_I32 127\nHOSTCALL 2\nPOP_N 1\nPUSH_I32 0\nPUSH_I32 2\nHOSTCALL 3\nPOP_N 1\nPUSH_I32 0\nHOSTCALL 0\nFRAME_SYNC\nPOP_N 1\nJMP 0");
|
||||
let program = module(asm(&code), syscalls.clone());
|
||||
write_cartridge(&dir, 50, "Audio Controls", &program, &syscalls);
|
||||
let mut first = HeadlessHost::new();
|
||||
first.boot(&dir).unwrap();
|
||||
let mut second = HeadlessHost::new();
|
||||
second.boot(&dir).unwrap();
|
||||
for _ in 0..3 {
|
||||
completed(first.advance_frame().unwrap());
|
||||
completed(second.advance_frame().unwrap());
|
||||
assert_same_state(&first.get_state(), &second.get_state());
|
||||
assert_eq!(first.get_state().stack_top.last(), Some(&prometeu_bytecode::Value::Int64(7)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user