@@ -17,33 +17,9 @@ pub struct OfflineAudioContext {
1717 /// the size of the buffer in sample-frames
1818 length : usize ,
1919 /// the rendering 'thread', fully controlled by the offline context
20- renderer : SingleUseRenderThread ,
20+ renderer : RenderThread ,
2121}
2222
23- mod private {
24- use super :: * ;
25-
26- pub ( crate ) struct SingleUseRenderThread ( RenderThread ) ;
27-
28- impl SingleUseRenderThread {
29- pub fn new ( rt : RenderThread ) -> Self {
30- Self ( rt)
31- }
32-
33- pub fn render_audiobuffer ( self , buffer_size : usize ) -> AudioBuffer {
34- self . 0 . render_audiobuffer_sync ( buffer_size)
35- }
36- }
37-
38- // SAFETY:
39- // The RenderThread is not Sync since it contains `AudioRenderQuantum`s (which use Rc) and `dyn
40- // AudioProcessor` which may not allow sharing between threads. However we mark the
41- // SingleUseRenderThread as Sync because it can only run once (and thus on a single thread)
42- // NB: the render thread should never hand out the contained `Rc` and `AudioProcessor`s
43- unsafe impl Sync for SingleUseRenderThread { }
44- }
45- use private:: SingleUseRenderThread ;
46-
4723impl BaseAudioContext for OfflineAudioContext {
4824 fn base ( & self ) -> & ConcreteBaseAudioContext {
4925 & self . base
@@ -98,7 +74,7 @@ impl OfflineAudioContext {
9874 Self {
9975 base,
10076 length,
101- renderer : SingleUseRenderThread :: new ( renderer ) ,
77+ renderer,
10278 }
10379 }
10480
@@ -107,7 +83,7 @@ impl OfflineAudioContext {
10783 /// This function will block the current thread and returns the rendered `AudioBuffer`
10884 /// synchronously. An async version is currently not implemented.
10985 pub fn start_rendering_sync ( self ) -> AudioBuffer {
110- self . renderer . render_audiobuffer ( self . length )
86+ self . renderer . render_audiobuffer_sync ( self . length )
11187 }
11288
11389 /// get the length of rendering audio buffer
0 commit comments