@@ -11,8 +11,8 @@ use std::{
1111
1212use log:: debug;
1313use pw:: {
14- context:: Context , core:: Core , properties:: properties, spa, sys:: PW_ID_CORE ,
15- thread_loop:: ThreadLoop ,
14+ context:: ContextRc , core:: CoreRc , properties:: properties, spa, sys:: PW_ID_CORE ,
15+ thread_loop:: ThreadLoopRc ,
1616} ;
1717use spa:: {
1818 param:: {
@@ -87,11 +87,11 @@ unsafe impl Sync for PwBackend {}
8787#[ allow( clippy:: non_send_fields_in_send_ty) ]
8888pub struct PwBackend {
8989 pub stream_params : Arc < RwLock < Vec < Stream > > > ,
90- thread_loop : ThreadLoop ,
91- pub core : Core ,
90+ thread_loop : ThreadLoopRc ,
91+ pub core : CoreRc ,
9292 #[ allow( dead_code) ]
93- context : Context ,
94- pub stream_hash : RwLock < HashMap < u32 , pw:: stream:: Stream > > ,
93+ context : ContextRc ,
94+ pub stream_hash : RwLock < HashMap < u32 , pw:: stream:: StreamRc > > ,
9595 pub stream_listener : RwLock < HashMap < u32 , pw:: stream:: StreamListener < i32 > > > ,
9696}
9797
@@ -101,13 +101,13 @@ impl PwBackend {
101101
102102 // SAFETY: safe as the thread loop cannot access objects associated
103103 // with the loop while the lock is held
104- let thread_loop = unsafe { ThreadLoop :: new ( Some ( "Pipewire thread loop" ) , None ) . unwrap ( ) } ;
104+ let thread_loop = unsafe { ThreadLoopRc :: new ( Some ( "Pipewire thread loop" ) , None ) . unwrap ( ) } ;
105105
106106 let lock_guard = thread_loop. lock ( ) ;
107107
108- let context = Context :: new ( & thread_loop) . map_err ( PwError :: CreateContext ) ?;
108+ let context = ContextRc :: new ( & thread_loop, None ) . map_err ( PwError :: CreateContext ) ?;
109109 thread_loop. start ( ) ;
110- let core = context. connect ( None ) . map_err ( PwError :: ConnectToCore ) ?;
110+ let core = context. connect_rc ( None ) . map_err ( PwError :: ConnectToCore ) ?;
111111
112112 // Create new reference for the variable so that it can be moved into the
113113 // closure.
@@ -356,7 +356,7 @@ impl AudioBackend for PwBackend {
356356 * pw:: keys:: MEDIA_CATEGORY => media_category,
357357 } ;
358358
359- let stream = pw:: stream:: Stream :: new ( & self . core , stream_name, props)
359+ let stream = pw:: stream:: StreamRc :: new ( self . core . clone ( ) , stream_name, props)
360360 . expect ( "could not create new stream" ) ;
361361
362362 let streams = self . stream_params . clone ( ) ;
0 commit comments