@@ -185,10 +185,10 @@ struct DeviceHandles {
185185impl DeviceHandles {
186186 /// Create `DeviceHandles` for `name` and try to open a handle for both
187187 /// directions. Returns `Ok` if either direction is opened successfully.
188- fn open ( name : & str ) -> Result < Self , alsa:: Error > {
188+ fn open ( pcm_id : & str ) -> Result < Self , alsa:: Error > {
189189 let mut handles = Self :: default ( ) ;
190- let playback_err = handles. try_open ( name , alsa:: Direction :: Playback ) . err ( ) ;
191- let capture_err = handles. try_open ( name , alsa:: Direction :: Capture ) . err ( ) ;
190+ let playback_err = handles. try_open ( pcm_id , alsa:: Direction :: Playback ) . err ( ) ;
191+ let capture_err = handles. try_open ( pcm_id , alsa:: Direction :: Capture ) . err ( ) ;
192192 if let Some ( err) = capture_err. and ( playback_err) {
193193 Err ( err)
194194 } else {
@@ -202,7 +202,7 @@ impl DeviceHandles {
202202 /// `Option` is guaranteed to be `Some(..)`.
203203 fn try_open (
204204 & mut self ,
205- name : & str ,
205+ pcm_id : & str ,
206206 stream_type : alsa:: Direction ,
207207 ) -> Result < & mut Option < alsa:: PCM > , alsa:: Error > {
208208 let handle = match stream_type {
@@ -211,7 +211,7 @@ impl DeviceHandles {
211211 } ;
212212
213213 if handle. is_none ( ) {
214- * handle = Some ( alsa:: pcm:: PCM :: new ( name , stream_type, true ) ?) ;
214+ * handle = Some ( alsa:: pcm:: PCM :: new ( pcm_id , stream_type, true ) ?) ;
215215 }
216216
217217 Ok ( handle)
@@ -221,10 +221,10 @@ impl DeviceHandles {
221221 /// If the handle is not yet opened, it will be opened and stored in `self`.
222222 fn get_mut (
223223 & mut self ,
224- name : & str ,
224+ pcm_id : & str ,
225225 stream_type : alsa:: Direction ,
226226 ) -> Result < & mut alsa:: PCM , alsa:: Error > {
227- Ok ( self . try_open ( name , stream_type) ?. as_mut ( ) . unwrap ( ) )
227+ Ok ( self . try_open ( pcm_id , stream_type) ?. as_mut ( ) . unwrap ( ) )
228228 }
229229
230230 /// Take ownership of the `alsa::PCM` handle for a specific `stream_type`.
@@ -237,6 +237,7 @@ impl DeviceHandles {
237237#[ derive( Clone ) ]
238238pub struct Device {
239239 name : String ,
240+ pcm_id : String ,
240241 handles : Arc < Mutex < DeviceHandles > > ,
241242}
242243
@@ -251,7 +252,7 @@ impl Device {
251252 . handles
252253 . lock ( )
253254 . unwrap ( )
254- . take ( & self . name , stream_type)
255+ . take ( & self . pcm_id , stream_type)
255256 . map_err ( |e| ( e, e. errno ( ) ) ) ;
256257
257258 let handle = match handle_result {
@@ -308,7 +309,7 @@ impl Device {
308309 ) -> Result < VecIntoIter < SupportedStreamConfigRange > , SupportedStreamConfigsError > {
309310 let mut guard = self . handles . lock ( ) . unwrap ( ) ;
310311 let handle_result = guard
311- . get_mut ( & self . name , stream_t)
312+ . get_mut ( & self . pcm_id , stream_t)
312313 . map_err ( |e| ( e, e. errno ( ) ) ) ;
313314
314315 let handle = match handle_result {
0 commit comments