@@ -275,7 +275,15 @@ impl DeviceTrait for Device {
275
275
fn name ( & self ) -> Result < String , DeviceNameError > {
276
276
match & self . 0 {
277
277
None => Ok ( "default" . to_owned ( ) ) ,
278
- Some ( info) => Ok ( info. product_name . clone ( ) ) ,
278
+ Some ( info) => {
279
+ let device_type = device_type_to_str ( info. device_type ) ;
280
+ let name = if info. address . is_empty ( ) {
281
+ format ! ( "{}:{}" , info. product_name, device_type)
282
+ } else {
283
+ format ! ( "{}:{}:{}" , info. product_name, device_type, info. address)
284
+ } ;
285
+ Ok ( name)
286
+ }
279
287
}
280
288
}
281
289
@@ -497,3 +505,40 @@ impl StreamTrait for Stream {
497
505
}
498
506
}
499
507
}
508
+
509
+ fn device_type_to_str ( audio_device_type : oboe:: AudioDeviceType ) -> & ' static str {
510
+ match audio_device_type {
511
+ oboe:: AudioDeviceType :: Unknown => "Unknown" ,
512
+ oboe:: AudioDeviceType :: AuxLine => "AuxLine" ,
513
+ oboe:: AudioDeviceType :: BleBroadcast => "BleBroadcast" ,
514
+ oboe:: AudioDeviceType :: BleHeadset => "BleHeadset" ,
515
+ oboe:: AudioDeviceType :: BleSpeaker => "BleSpeaker" ,
516
+ oboe:: AudioDeviceType :: BluetoothA2DP => "BluetoothA2DP" ,
517
+ oboe:: AudioDeviceType :: BluetoothSCO => "BluetoothSCO" ,
518
+ oboe:: AudioDeviceType :: BuiltinEarpiece => "BuiltinEarpiece" ,
519
+ oboe:: AudioDeviceType :: BuiltinMic => "BuiltinMic" ,
520
+ oboe:: AudioDeviceType :: BuiltinSpeaker => "BuiltinSpeaker" ,
521
+ oboe:: AudioDeviceType :: BuiltinSpeakerSafe => "BuiltinSpeakerSafe" ,
522
+ oboe:: AudioDeviceType :: Bus => "Bus" ,
523
+ oboe:: AudioDeviceType :: Dock => "Dock" ,
524
+ oboe:: AudioDeviceType :: Fm => "Fm" ,
525
+ oboe:: AudioDeviceType :: FmTuner => "FmTuner" ,
526
+ oboe:: AudioDeviceType :: Hdmi => "Hdmi" ,
527
+ oboe:: AudioDeviceType :: HdmiArc => "HdmiArc" ,
528
+ oboe:: AudioDeviceType :: HdmiEarc => "HdmiEarc" ,
529
+ oboe:: AudioDeviceType :: HearingAid => "HearingAid" ,
530
+ oboe:: AudioDeviceType :: Ip => "Ip" ,
531
+ oboe:: AudioDeviceType :: LineAnalog => "LineAnalog" ,
532
+ oboe:: AudioDeviceType :: LineDigital => "LineDigital" ,
533
+ oboe:: AudioDeviceType :: RemoteSubmix => "RemoteSubmix" ,
534
+ oboe:: AudioDeviceType :: Telephony => "Telephony" ,
535
+ oboe:: AudioDeviceType :: TvTuner => "TvTuner" ,
536
+ oboe:: AudioDeviceType :: UsbAccessory => "UsbAccessory" ,
537
+ oboe:: AudioDeviceType :: UsbDevice => "UsbDevice" ,
538
+ oboe:: AudioDeviceType :: UsbHeadset => "UsbHeadset" ,
539
+ oboe:: AudioDeviceType :: WiredHeadphones => "WiredHeadphones" ,
540
+ oboe:: AudioDeviceType :: WiredHeadset => "WiredHeadset" ,
541
+ oboe:: AudioDeviceType :: Unsupported => "Unsupported" ,
542
+ _ => "NotSpecified" ,
543
+ }
544
+ }
0 commit comments