Giter Club home page Giter Club logo

Comments (2)

ctrlcctrlv avatar ctrlcctrlv commented on September 22, 2024

Hey, good news, figured out how to use this in 2021! Sound working on desktop Linux!!

Now it's not ideal since @kondrak doesn't seem to work on this anymore and it relies on a deprecated version of Rust-SDL2. But if you patch your Rust-SDL2 v0.25.0 (https://github.com/Rust-SDL2/rust-sdl2/tree/0.26.0 , for some reason no 0.25.0 tag on GitHub) like this:

diff --git a/audio.rs b/home/fred/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.25.0/src/sdl2/audio.rs
index c5982da..0eaeb00 100644
--- a/audio.rs
+++ b/home/fred/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.25.0/src/sdl2/audio.rs
@@ -558,6 +558,7 @@ pub struct AudioDevice<CB: AudioCallback> {
     userdata: Box<CB>
 }
 
+use std::mem::MaybeUninit;
 impl<CB: AudioCallback> AudioDevice<CB> {
     /// Opens a new audio device given the desired parameters and callback.
     pub fn open_playback<F>(a: &AudioSubsystem, device: Option<&str>, spec: &AudioSpecDesired, get_callback: F) -> Result<AudioDevice <CB>, String>
@@ -568,7 +569,7 @@ impl<CB: AudioCallback> AudioDevice<CB> {
         // callback without the obtained AudioSpec.
         // Create an uninitialized box that will be initialized after SDL_OpenAudioDevice.
         let userdata: *mut CB = unsafe {
-            let b: Box<CB> = Box::new(mem::uninitialized());
+            let b: Box<MaybeUninit<CB>> = Box::new(MaybeUninit::uninit());
             mem::transmute(b)
         };
         let desired = AudioSpecDesired::convert_to_ll(spec.freq, spec.channels, spec.samples, userdata);

Then prgs/playsound.prg works fine~ :-D

Check it out, running fine even compiled with Rust v1.58, debugger & all!

image

from rust64.

kondrak avatar kondrak commented on September 22, 2024

I totally forgot about your report :) Thanks for looking into the problem, bumping SDL2 to 0.35.0 was enough to fix the issue (it's now pushed to master).

from rust64.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.