@@ -185,10 +185,10 @@ struct DeviceHandles {
185
185
impl DeviceHandles {
186
186
/// Create `DeviceHandles` for `name` and try to open a handle for both
187
187
/// 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 > {
189
189
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 ( ) ;
192
192
if let Some ( err) = capture_err. and ( playback_err) {
193
193
Err ( err)
194
194
} else {
@@ -202,7 +202,7 @@ impl DeviceHandles {
202
202
/// `Option` is guaranteed to be `Some(..)`.
203
203
fn try_open (
204
204
& mut self ,
205
- name : & str ,
205
+ pcm_id : & str ,
206
206
stream_type : alsa:: Direction ,
207
207
) -> Result < & mut Option < alsa:: PCM > , alsa:: Error > {
208
208
let handle = match stream_type {
@@ -211,7 +211,7 @@ impl DeviceHandles {
211
211
} ;
212
212
213
213
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 ) ?) ;
215
215
}
216
216
217
217
Ok ( handle)
@@ -221,10 +221,10 @@ impl DeviceHandles {
221
221
/// If the handle is not yet opened, it will be opened and stored in `self`.
222
222
fn get_mut (
223
223
& mut self ,
224
- name : & str ,
224
+ pcm_id : & str ,
225
225
stream_type : alsa:: Direction ,
226
226
) -> 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 ( ) )
228
228
}
229
229
230
230
/// Take ownership of the `alsa::PCM` handle for a specific `stream_type`.
@@ -237,6 +237,7 @@ impl DeviceHandles {
237
237
#[ derive( Clone ) ]
238
238
pub struct Device {
239
239
name : String ,
240
+ pcm_id : String ,
240
241
handles : Arc < Mutex < DeviceHandles > > ,
241
242
}
242
243
@@ -251,7 +252,7 @@ impl Device {
251
252
. handles
252
253
. lock ( )
253
254
. unwrap ( )
254
- . take ( & self . name , stream_type)
255
+ . take ( & self . pcm_id , stream_type)
255
256
. map_err ( |e| ( e, e. errno ( ) ) ) ;
256
257
257
258
let handle = match handle_result {
@@ -308,7 +309,7 @@ impl Device {
308
309
) -> Result < VecIntoIter < SupportedStreamConfigRange > , SupportedStreamConfigsError > {
309
310
let mut guard = self . handles . lock ( ) . unwrap ( ) ;
310
311
let handle_result = guard
311
- . get_mut ( & self . name , stream_t)
312
+ . get_mut ( & self . pcm_id , stream_t)
312
313
. map_err ( |e| ( e, e. errno ( ) ) ) ;
313
314
314
315
let handle = match handle_result {
0 commit comments