1414
1515use rodio:: {
1616 source:: { Buffered , Source } ,
17- Decoder , OutputStream , OutputStreamHandle , Sink ,
17+ Decoder , OutputStream , OutputStreamBuilder , Sink ,
1818} ;
1919use std:: collections:: HashMap ;
2020use std:: io:: { Cursor , Read } ;
@@ -31,19 +31,18 @@ pub struct Audio {
3131 clips : HashMap < String , Buffered < Decoder < Cursor < Vec < u8 > > > > > ,
3232 channels : Vec < Sink > ,
3333 current_channel : usize ,
34- output : Option < ( OutputStream , OutputStreamHandle ) > ,
34+ output : Option < OutputStream > ,
3535}
3636
3737impl Audio {
3838 /// Create a new sound subsystem. You only need one of these -- you can use it to load and play
3939 /// any number of audio clips.
4040 pub fn new ( ) -> Self {
41- if let Ok ( output) = OutputStream :: try_default ( ) {
41+ if let Ok ( output) = OutputStreamBuilder :: open_default_stream ( ) {
4242 let clips = HashMap :: new ( ) ;
4343 let mut channels: Vec < Sink > = Vec :: new ( ) ;
44- for i in 0 ..4 {
45- let sink = Sink :: try_new ( & output. 1 )
46- . unwrap_or_else ( |_| panic ! ( "Failed to create sound channel {}" , i) ) ;
44+ for _ in 0 ..4 {
45+ let sink = Sink :: connect_new ( output. mixer ( ) ) ;
4746 channels. push ( sink) ;
4847 }
4948 Self {
0 commit comments