diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 300fe9f..5a7ee71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/soloud-sys/sys/examples/ca.cpp b/soloud-sys/sys/examples/ca.cpp new file mode 100644 index 0000000..5d64320 --- /dev/null +++ b/soloud-sys/sys/examples/ca.cpp @@ -0,0 +1,34 @@ +// g++ -I ../soloud/include example.cpp ../../../target/debug/build/soloud-sys-69e1b085f8a6624a/out/lib/libsoloud.a + +#include + +#include "soloud.h" +#include "soloud_wav.h" +#include "soloud_thread.h" +#include +#include + +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 buffer(std::istreambuf_iterator(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; +} diff --git a/soloud/examples/ca_bug.rs b/soloud/examples/ca_bug.rs new file mode 100644 index 0000000..1711e77 --- /dev/null +++ b/soloud/examples/ca_bug.rs @@ -0,0 +1,26 @@ +use soloud::*; + +fn main() -> Result<(), Box> { + 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(()) +}