Skip to content

Commit

Permalink
Bake fallibility into the Physics APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkleiny committed Apr 5, 2024
1 parent 607375c commit 2445449
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 495 deletions.
2 changes: 2 additions & 0 deletions common/src/collections/arena.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::unsafe_mutable_alias;

// TODO: implement a free list and next_free option on the arena

/// Represents a safe index into an [`Arena`].
///
/// This is a 64-bit integer that is split into two parts:
Expand Down
20 changes: 10 additions & 10 deletions modules/audio/src/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ impl AudioBackend for HeadlessAudioBackend {
Ok(SourceId(self.next_source_id.fetch_add(1, Ordering::Relaxed)))
}

fn source_is_playing(&self, source: SourceId) -> bool {
false
fn source_is_playing(&self, source: SourceId) -> Option<bool> {
None
}

fn source_get_volume(&self, source: SourceId) -> f32 {
1.
fn source_get_volume(&self, source: SourceId) -> Option<f32> {
None
}

fn source_set_volume(&self, source: SourceId, volume: f32) {
// no-op
fn source_set_volume(&self, source: SourceId, volume: f32) -> Result<(), SourceError> {
Ok(())
}

fn source_get_clip(&self, source: SourceId) -> Option<ClipId> {
None
}

fn source_set_clip(&self, source: SourceId, clip: ClipId) {
// no-op
fn source_set_clip(&self, source: SourceId, clip: ClipId) -> Result<(), SourceError> {
Ok(())
}

fn source_play(&self, source: SourceId) {
// no-op
fn source_play(&self, source: SourceId) -> Result<(), SourceError> {
Ok(())
}

fn source_delete(&self, source: SourceId) -> Result<(), SourceError> {
Expand Down
10 changes: 5 additions & 5 deletions modules/audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ pub trait AudioBackend {

// sources
fn source_create(&self) -> Result<SourceId, SourceError>;
fn source_is_playing(&self, source: SourceId) -> bool;
fn source_get_volume(&self, source: SourceId) -> f32;
fn source_set_volume(&self, source: SourceId, volume: f32);
fn source_is_playing(&self, source: SourceId) -> Option<bool>;
fn source_get_volume(&self, source: SourceId) -> Option<f32>;
fn source_set_volume(&self, source: SourceId, volume: f32) -> Result<(), SourceError>;
fn source_get_clip(&self, source: SourceId) -> Option<ClipId>;
fn source_set_clip(&self, source: SourceId, clip: ClipId);
fn source_play(&self, source: SourceId);
fn source_set_clip(&self, source: SourceId, clip: ClipId) -> Result<(), SourceError>;
fn source_play(&self, source: SourceId) -> Result<(), SourceError>;
fn source_delete(&self, source: SourceId) -> Result<(), SourceError>;
}
10 changes: 5 additions & 5 deletions modules/audio/src/openal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ impl AudioBackend for OpenALAudioBackend {
}

#[profiling]
fn source_is_playing(&self, source: SourceId) -> bool {
fn source_is_playing(&self, source: SourceId) -> Option<bool> {
todo!()
}

#[profiling]
fn source_get_volume(&self, source: SourceId) -> f32 {
fn source_get_volume(&self, source: SourceId) -> Option<f32> {
todo!()
}

#[profiling]
fn source_set_volume(&self, source: SourceId, volume: f32) {
fn source_set_volume(&self, source: SourceId, volume: f32) -> Result<(), SourceError> {
todo!()
}

Expand All @@ -63,12 +63,12 @@ impl AudioBackend for OpenALAudioBackend {
}

#[profiling]
fn source_set_clip(&self, source: SourceId, clip: ClipId) {
fn source_set_clip(&self, source: SourceId, clip: ClipId) -> Result<(), SourceError> {
todo!()
}

#[profiling]
fn source_play(&self, source: SourceId) {
fn source_play(&self, source: SourceId) -> Result<(), SourceError> {
todo!()
}

Expand Down
Loading

0 comments on commit 2445449

Please sign in to comment.