Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
MoAlyousef committed Aug 31, 2023
1 parent 14faca6 commit b1242c9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Update submodule
run: git submodule update --init --recursive
- name: Build
run: cargo build --verbose
34 changes: 34 additions & 0 deletions soloud-sys/sys/examples/ca.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// g++ -I ../soloud/include example.cpp ../../../target/debug/build/soloud-sys-69e1b085f8a6624a/out/lib/libsoloud.a

#include <stdio.h>

#include "soloud.h"
#include "soloud_wav.h"
#include "soloud_thread.h"
#include <fstream>
#include <vector>

constexpr unsigned long BEEP_INTERVAL = 100000; //milliseconds
constexpr unsigned long POLL_INTERVAL = 1000;

int main() {
for (int i = 0; i < 5; i++) {
SoLoud::Soloud sl;
SoLoud::Wav wav;
sl.init();
std::ifstream in("../../../beep.mp3", ::std::ios::binary);
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(in), {});
auto ret = wav.loadMem(buffer.data(), buffer.size(), true, false);

sl.play(wav);

while (sl.getVoiceCount() > 0) {
SoLoud::Thread::sleep(POLL_INTERVAL);
}

sl.deinit();
SoLoud::Thread::sleep(BEEP_INTERVAL);
}

return 0;
}
26 changes: 26 additions & 0 deletions soloud/examples/ca_bug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use soloud::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
const BEEP_INTERVAL: u64 = 1000; //milliseconds
const POLL_INTERVAL: u64 = 100;
for _ in 0..5 {
std::thread::spawn(|| {
let mut sl = Soloud::default().unwrap();
sl.set_global_volume(3.0);

let mut wav = audio::Wav::default();

wav.load_mem(include_bytes!("../../beep.mp3")).unwrap();

sl.play(&wav);

while sl.voice_count() > 0 {
std::thread::sleep(std::time::Duration::from_millis(POLL_INTERVAL));
}
});

std::thread::sleep(std::time::Duration::from_millis(BEEP_INTERVAL));
}

Ok(())
}

0 comments on commit b1242c9

Please sign in to comment.