@@ -33,7 +33,7 @@ pub use self::platform_impl::*;
33
33
/// SupportedOutputConfigs and all their necessary trait implementations.
34
34
///
35
35
macro_rules! impl_platform_host {
36
- ( $( $( #[ cfg( $feat: meta) ] ) ? $HostVariant: ident $host_mod : ident $host_name : literal ) ,* ) => {
36
+ ( $( $( #[ cfg( $feat: meta) ] ) ? $HostVariant: ident => $Host : ty ) ,* $ ( , ) ? ) => {
37
37
/// All hosts supported by CPAL on this platform.
38
38
pub const ALL_HOSTS : & ' static [ HostId ] = & [
39
39
$(
@@ -91,47 +91,47 @@ macro_rules! impl_platform_host {
91
91
pub enum DeviceInner {
92
92
$(
93
93
$( #[ cfg( $feat) ] ) ?
94
- $HostVariant( crate :: host :: $host_mod :: Device ) ,
94
+ $HostVariant( <$Host as crate :: traits :: HostTrait > :: Device ) ,
95
95
) *
96
96
}
97
97
98
98
/// Contains a platform specific [`Devices`] implementation.
99
99
pub enum DevicesInner {
100
100
$(
101
101
$( #[ cfg( $feat) ] ) ?
102
- $HostVariant( crate :: host :: $host_mod :: Devices ) ,
102
+ $HostVariant( <$Host as crate :: traits :: HostTrait > :: Devices ) ,
103
103
) *
104
104
}
105
105
106
106
/// Contains a platform specific [`Host`] implementation.
107
107
pub enum HostInner {
108
108
$(
109
109
$( #[ cfg( $feat) ] ) ?
110
- $HostVariant( crate :: host :: $host_mod :: Host ) ,
110
+ $HostVariant( $ Host) ,
111
111
) *
112
112
}
113
113
114
114
/// Contains a platform specific [`Stream`] implementation.
115
115
pub enum StreamInner {
116
116
$(
117
117
$( #[ cfg( $feat) ] ) ?
118
- $HostVariant( crate :: host :: $host_mod :: Stream ) ,
118
+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream ) ,
119
119
) *
120
120
}
121
121
122
122
#[ derive( Clone ) ]
123
123
enum SupportedInputConfigsInner {
124
124
$(
125
125
$( #[ cfg( $feat) ] ) ?
126
- $HostVariant( crate :: host :: $host_mod :: SupportedInputConfigs ) ,
126
+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: SupportedInputConfigs ) ,
127
127
) *
128
128
}
129
129
130
130
#[ derive( Clone ) ]
131
131
enum SupportedOutputConfigsInner {
132
132
$(
133
133
$( #[ cfg( $feat) ] ) ?
134
- $HostVariant( crate :: host :: $host_mod :: SupportedOutputConfigs ) ,
134
+ $HostVariant( <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: SupportedOutputConfigs ) ,
135
135
) *
136
136
}
137
137
@@ -140,7 +140,7 @@ macro_rules! impl_platform_host {
140
140
match self {
141
141
$(
142
142
$( #[ cfg( $feat) ] ) ?
143
- HostId :: $HostVariant => $host_name ,
143
+ HostId :: $HostVariant => stringify! ( $HostVariant ) ,
144
144
) *
145
145
}
146
146
}
@@ -442,7 +442,7 @@ macro_rules! impl_platform_host {
442
442
fn is_available( ) -> bool {
443
443
$(
444
444
$( #[ cfg( $feat) ] ) ?
445
- if crate :: host :: $host_mod :: Host :: is_available( ) { return true ; }
445
+ if <$ Host> :: is_available( ) { return true ; }
446
446
) *
447
447
false
448
448
}
@@ -531,29 +531,29 @@ macro_rules! impl_platform_host {
531
531
532
532
$(
533
533
$( #[ cfg( $feat) ] ) ?
534
- impl From <crate :: host :: $host_mod :: Device > for Device {
535
- fn from( h: crate :: host :: $host_mod :: Device ) -> Self {
534
+ impl From <<$Host as crate :: traits :: HostTrait > :: Device > for Device {
535
+ fn from( h: <$Host as crate :: traits :: HostTrait > :: Device ) -> Self {
536
536
DeviceInner :: $HostVariant( h) . into( )
537
537
}
538
538
}
539
539
540
540
$( #[ cfg( $feat) ] ) ?
541
- impl From <crate :: host :: $host_mod :: Devices > for Devices {
542
- fn from( h: crate :: host :: $host_mod :: Devices ) -> Self {
541
+ impl From <<$Host as crate :: traits :: HostTrait > :: Devices > for Devices {
542
+ fn from( h: <$Host as crate :: traits :: HostTrait > :: Devices ) -> Self {
543
543
DevicesInner :: $HostVariant( h) . into( )
544
544
}
545
545
}
546
546
547
547
$( #[ cfg( $feat) ] ) ?
548
- impl From <crate :: host :: $host_mod :: Host > for Host {
549
- fn from( h: crate :: host :: $host_mod :: Host ) -> Self {
548
+ impl From <$ Host> for Host {
549
+ fn from( h: $ Host) -> Self {
550
550
HostInner :: $HostVariant( h) . into( )
551
551
}
552
552
}
553
553
554
554
$( #[ cfg( $feat) ] ) ?
555
- impl From <crate :: host :: $host_mod :: Stream > for Stream {
556
- fn from( h: crate :: host :: $host_mod :: Stream ) -> Self {
555
+ impl From <<<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream > for Stream {
556
+ fn from( h: <<$Host as crate :: traits :: HostTrait > :: Device as crate :: traits :: DeviceTrait > :: Stream ) -> Self {
557
557
StreamInner :: $HostVariant( h) . into( )
558
558
}
559
559
}
@@ -564,7 +564,7 @@ macro_rules! impl_platform_host {
564
564
let mut host_ids = vec![ ] ;
565
565
$(
566
566
$( #[ cfg( $feat) ] ) ?
567
- if <crate :: host :: $host_mod :: Host as crate :: traits:: HostTrait >:: is_available( ) {
567
+ if <$ Host as crate :: traits:: HostTrait >:: is_available( ) {
568
568
host_ids. push( HostId :: $HostVariant) ;
569
569
}
570
570
) *
@@ -577,7 +577,7 @@ macro_rules! impl_platform_host {
577
577
$(
578
578
$( #[ cfg( $feat) ] ) ?
579
579
HostId :: $HostVariant => {
580
- crate :: host :: $host_mod :: Host :: new( )
580
+ <$ Host> :: new( )
581
581
. map( HostInner :: $HostVariant)
582
582
. map( Host :: from)
583
583
}
@@ -601,19 +601,14 @@ macro_rules! impl_platform_host {
601
601
target_os = "netbsd"
602
602
) ) ]
603
603
mod platform_impl {
604
- pub use crate :: host:: alsa:: {
605
- Device as AlsaDevice , Devices as AlsaDevices , Host as AlsaHost , Stream as AlsaStream ,
606
- SupportedInputConfigs as AlsaSupportedInputConfigs ,
607
- SupportedOutputConfigs as AlsaSupportedOutputConfigs ,
608
- } ;
604
+ pub use crate :: host:: alsa:: Host as AlsaHost ;
609
605
#[ cfg( feature = "jack" ) ]
610
- pub use crate :: host:: jack:: {
611
- Device as JackDevice , Devices as JackDevices , Host as JackHost , Stream as JackStream ,
612
- SupportedInputConfigs as JackSupportedInputConfigs ,
613
- SupportedOutputConfigs as JackSupportedOutputConfigs ,
614
- } ;
606
+ pub use crate :: host:: jack:: Host as JackHost ;
615
607
616
- impl_platform_host ! ( #[ cfg( feature = "jack" ) ] Jack jack "JACK" , Alsa alsa "ALSA" ) ;
608
+ impl_platform_host ! (
609
+ #[ cfg( feature = "jack" ) ] Jack => JackHost ,
610
+ Alsa => AlsaHost ,
611
+ ) ;
617
612
618
613
/// The default host for the current compilation target platform.
619
614
pub fn default_host ( ) -> Host {
@@ -625,13 +620,8 @@ mod platform_impl {
625
620
626
621
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
627
622
mod platform_impl {
628
- pub use crate :: host:: coreaudio:: {
629
- Device as CoreAudioDevice , Devices as CoreAudioDevices , Host as CoreAudioHost ,
630
- Stream as CoreAudioStream , SupportedInputConfigs as CoreAudioSupportedInputConfigs ,
631
- SupportedOutputConfigs as CoreAudioSupportedOutputConfigs ,
632
- } ;
633
-
634
- impl_platform_host ! ( CoreAudio coreaudio "CoreAudio" ) ;
623
+ pub use crate :: host:: coreaudio:: Host as CoreAudioHost ;
624
+ impl_platform_host ! ( CoreAudio => CoreAudioHost ) ;
635
625
636
626
/// The default host for the current compilation target platform.
637
627
pub fn default_host ( ) -> Host {
@@ -643,13 +633,8 @@ mod platform_impl {
643
633
644
634
#[ cfg( target_os = "emscripten" ) ]
645
635
mod platform_impl {
646
- pub use crate :: host:: emscripten:: {
647
- Device as EmscriptenDevice , Devices as EmscriptenDevices , Host as EmscriptenHost ,
648
- Stream as EmscriptenStream , SupportedInputConfigs as EmscriptenSupportedInputConfigs ,
649
- SupportedOutputConfigs as EmscriptenSupportedOutputConfigs ,
650
- } ;
651
-
652
- impl_platform_host ! ( Emscripten emscripten "Emscripten" ) ;
636
+ pub use crate :: host:: emscripten:: Host as EmscriptenHost ;
637
+ impl_platform_host ! ( Emscripten => EmscriptenHost ) ;
653
638
654
639
/// The default host for the current compilation target platform.
655
640
pub fn default_host ( ) -> Host {
@@ -661,13 +646,8 @@ mod platform_impl {
661
646
662
647
#[ cfg( all( target_arch = "wasm32" , feature = "wasm-bindgen" ) ) ]
663
648
mod platform_impl {
664
- pub use crate :: host:: webaudio:: {
665
- Device as WebAudioDevice , Devices as WebAudioDevices , Host as WebAudioHost ,
666
- Stream as WebAudioStream , SupportedInputConfigs as WebAudioSupportedInputConfigs ,
667
- SupportedOutputConfigs as WebAudioSupportedOutputConfigs ,
668
- } ;
669
-
670
- impl_platform_host ! ( WebAudio webaudio "WebAudio" ) ;
649
+ pub use crate :: host:: webaudio:: Host as WebAudioHost ;
650
+ impl_platform_host ! ( WebAudio => WebAudioHost ) ;
671
651
672
652
/// The default host for the current compilation target platform.
673
653
pub fn default_host ( ) -> Host {
@@ -680,18 +660,13 @@ mod platform_impl {
680
660
#[ cfg( windows) ]
681
661
mod platform_impl {
682
662
#[ cfg( feature = "asio" ) ]
683
- pub use crate :: host:: asio:: {
684
- Device as AsioDevice , Devices as AsioDevices , Host as AsioHost , Stream as AsioStream ,
685
- SupportedInputConfigs as AsioSupportedInputConfigs ,
686
- SupportedOutputConfigs as AsioSupportedOutputConfigs ,
687
- } ;
688
- pub use crate :: host:: wasapi:: {
689
- Device as WasapiDevice , Devices as WasapiDevices , Host as WasapiHost ,
690
- Stream as WasapiStream , SupportedInputConfigs as WasapiSupportedInputConfigs ,
691
- SupportedOutputConfigs as WasapiSupportedOutputConfigs ,
692
- } ;
663
+ pub use crate :: host:: asio:: Host as AsioHost ;
664
+ pub use crate :: host:: wasapi:: Host as WasapiHost ;
693
665
694
- impl_platform_host ! ( #[ cfg( feature = "asio" ) ] Asio asio "ASIO" , Wasapi wasapi "WASAPI" ) ;
666
+ impl_platform_host ! (
667
+ #[ cfg( feature = "asio" ) ] Asio => AsioHost ,
668
+ Wasapi => WasapiHost ,
669
+ ) ;
695
670
696
671
/// The default host for the current compilation target platform.
697
672
pub fn default_host ( ) -> Host {
@@ -703,13 +678,8 @@ mod platform_impl {
703
678
704
679
#[ cfg( target_os = "android" ) ]
705
680
mod platform_impl {
706
- pub use crate :: host:: aaudio:: {
707
- Device as AAudioDevice , Devices as AAudioDevices , Host as AAudioHost ,
708
- Stream as AAudioStream , SupportedInputConfigs as AAudioSupportedInputConfigs ,
709
- SupportedOutputConfigs as AAudioSupportedOutputConfigs ,
710
- } ;
711
-
712
- impl_platform_host ! ( AAudio aaudio "AAudio" ) ;
681
+ pub use crate :: host:: aaudio:: Host as AAudioHost ;
682
+ impl_platform_host ! ( AAudio => AAudioHost ) ;
713
683
714
684
/// The default host for the current compilation target platform.
715
685
pub fn default_host ( ) -> Host {
@@ -732,13 +702,9 @@ mod platform_impl {
732
702
all( target_arch = "wasm32" , feature = "wasm-bindgen" ) ,
733
703
) ) ) ]
734
704
mod platform_impl {
735
- pub use crate :: host:: null:: {
736
- Device as NullDevice , Devices as NullDevices , Host as NullHost ,
737
- SupportedInputConfigs as NullSupportedInputConfigs ,
738
- SupportedOutputConfigs as NullSupportedOutputConfigs ,
739
- } ;
705
+ pub use crate :: host:: null:: Host as NullHost ;
740
706
741
- impl_platform_host ! ( Null null "Null" ) ;
707
+ impl_platform_host ! ( Null => NullHost ) ;
742
708
743
709
/// The default host for the current compilation target platform.
744
710
pub fn default_host ( ) -> Host {
0 commit comments