PR003: implement audio status-first returns for play operations

This commit is contained in:
2026-03-24 13:40:50 +00:00
parent fe6931d420
commit 998252aa25
6 changed files with 117 additions and 36 deletions
@@ -7,6 +7,17 @@ pub enum LoopMode {
On,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(i32)]
pub enum AudioOpStatus {
Ok = 0,
VoiceInvalid = 1,
SampleNotFound = 2,
ArgRangeInvalid = 3,
AssetNotFound = 4,
NoEffect = 5,
}
pub trait AudioBridge {
#[allow(clippy::too_many_arguments)]
fn play(
@@ -19,7 +30,7 @@ pub trait AudioBridge {
pitch: f64,
priority: u8,
loop_mode: LoopMode,
);
) -> AudioOpStatus;
#[allow(clippy::too_many_arguments)]
fn play_sample(
&mut self,
@@ -30,7 +41,7 @@ pub trait AudioBridge {
pitch: f64,
priority: u8,
loop_mode: LoopMode,
);
) -> AudioOpStatus;
fn stop(&mut self, voice_id: usize);
fn set_volume(&mut self, voice_id: usize, volume: u8);
fn set_pan(&mut self, voice_id: usize, pan: u8);
+1 -1
View File
@@ -28,7 +28,7 @@ pub mod vm_fault;
pub mod window;
pub use asset_bridge::AssetBridge;
pub use audio_bridge::{AudioBridge, LoopMode};
pub use audio_bridge::{AudioBridge, AudioOpStatus, LoopMode};
pub use gfx_bridge::{BlendMode, GfxBridge};
pub use hardware_bridge::HardwareBridge;
pub use host_context::{HostContext, HostContextProvider};
@@ -8,7 +8,7 @@ pub(crate) const ENTRIES: &[SyscallRegistryEntry] = &[
"play_sample",
1,
5,
0,
1,
caps::AUDIO,
Determinism::Deterministic,
false,
@@ -20,7 +20,7 @@ pub(crate) const ENTRIES: &[SyscallRegistryEntry] = &[
"play",
1,
7,
0,
1,
caps::AUDIO,
Determinism::Deterministic,
false,