Skip to content

Commit f537f60

Browse files
committed
Remove librustrt, audio Task
Due to recent changes, librustrt and Task are now deprecated. Calling Rust from C should now "just work".
1 parent 5d4c090 commit f537f60

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

src/sdl2/audio.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::c_vec::CVec;
77
use libc;
88
use libc::{c_int, size_t, c_void};
99
use libc::{uint8_t};
10-
use rustrt::task::Task;
1110

1211
use get_error;
1312
use rwops::RWops;
@@ -246,39 +245,9 @@ pub trait AudioCallback<T> {
246245

247246
/// The userdata as seen by the SDL callback.
248247
struct AudioCallbackUserdata<CB> {
249-
task: AudioCallbackTask,
250248
callback: CB
251249
}
252250

253-
/// A Task is required to use libstd from SDL's audio callback.
254-
struct AudioCallbackTask {
255-
/// Set to None if there was an error running a previous task.
256-
task: Option<Box<Task>>
257-
}
258-
259-
impl Drop for AudioCallbackTask {
260-
/// Destroy the callback task.
261-
fn drop(&mut self) {
262-
use rustrt::local::Local;
263-
use std::mem::replace;
264-
265-
// Swap out the task with None in order to own it, since drop() only
266-
// provides a reference.
267-
match replace(&mut self.task, None) {
268-
Some(task) => {
269-
// pop current task
270-
let old_task = Local::take();
271-
272-
task.destroy();
273-
274-
// put task back
275-
Local::put(old_task);
276-
},
277-
None => ()
278-
};
279-
}
280-
}
281-
282251
/// A phantom type for retreiving the SDL_AudioFormat of a given generic type.
283252
/// All format types are returned as native-endian.
284253
///
@@ -329,25 +298,7 @@ extern "C" fn audio_callback_marshall<T: AudioFormatNum<T>, CB: AudioCallback<T>
329298
len: len as uint / size_of::<T>()
330299
});
331300

332-
// Perform a dance to move tasks around without compiler errors
333-
let new_task = match replace(&mut cb_userdata.task.task, None) {
334-
Some(task) => {
335-
let n = task.run(|| {
336-
cb_userdata.callback.callback(buf);
337-
});
338-
339-
if n.is_destroyed() { None }
340-
else { Some(n) }
341-
},
342-
None => {
343-
// Last callback had an error. Fill buffer with silence.
344-
for x in buf.iter_mut() { *x = AudioFormatNum::zero(); }
345-
346-
None
347-
}
348-
};
349-
350-
replace(&mut cb_userdata.task.task, new_task);
301+
cb_userdata.callback.callback(buf);
351302
}
352303
}
353304

@@ -377,11 +328,7 @@ impl<T: AudioFormatNum<T>, CB: AudioCallback<T>> AudioSpecDesired<T, CB> {
377328
}
378329

379330
fn callback_to_userdata(callback: CB) -> Box<AudioCallbackUserdata<CB>> {
380-
let mut task = box Task::new(None, None);
381-
task.name = Some("SDL audio callback".into_cow());
382-
383331
box AudioCallbackUserdata {
384-
task: AudioCallbackTask { task: Some(task) },
385332
callback: callback
386333
}
387334
}

src/sdl2/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
extern crate libc;
77
extern crate collections;
8-
extern crate rustrt;
98

109
pub use sdl::*;
1110

0 commit comments

Comments
 (0)