@@ -2,14 +2,12 @@ use async_trait::async_trait;
2
2
use bytes:: Bytes ;
3
3
#[ cfg( not( any( target_os = "android" , target_os = "ios" ) ) ) ]
4
4
use clipboard_master:: { CallbackResult , ClipboardHandler } ;
5
- #[ cfg( not( target_os = "linux" ) ) ]
6
5
use cpal:: {
7
6
traits:: { DeviceTrait , HostTrait , StreamTrait } ,
8
7
Device , Host , StreamConfig ,
9
8
} ;
10
9
use crossbeam_queue:: ArrayQueue ;
11
10
use magnum_opus:: { Channels :: * , Decoder as AudioDecoder } ;
12
- #[ cfg( not( target_os = "linux" ) ) ]
13
11
use ringbuf:: { ring_buffer:: RbBase , Rb } ;
14
12
use serde:: { Deserialize , Serialize } ;
15
13
use sha2:: { Digest , Sha256 } ;
@@ -119,7 +117,6 @@ pub const SCRAP_OTHER_VERSION_OR_X11_REQUIRED: &str =
119
117
pub const SCRAP_X11_REQUIRED : & str = "x11 expected" ;
120
118
pub const SCRAP_X11_REF_URL : & str = "https://rustdesk.com/docs/en/manual/linux/#x11-required" ;
121
119
122
- #[ cfg( not( target_os = "linux" ) ) ]
123
120
pub const AUDIO_BUFFER_MS : usize = 3000 ;
124
121
125
122
#[ cfg( feature = "flutter" ) ]
@@ -142,7 +139,6 @@ struct TextClipboardState {
142
139
running : bool ,
143
140
}
144
141
145
- #[ cfg( not( target_os = "linux" ) ) ]
146
142
lazy_static:: lazy_static! {
147
143
static ref AUDIO_HOST : Host = cpal:: default_host( ) ;
148
144
}
@@ -865,28 +861,20 @@ impl ClipboardHandler for ClientClipboardHandler {
865
861
#[ derive( Default ) ]
866
862
pub struct AudioHandler {
867
863
audio_decoder : Option < ( AudioDecoder , Vec < f32 > ) > ,
868
- #[ cfg( target_os = "linux" ) ]
869
- simple : Option < psimple:: Simple > ,
870
- #[ cfg( not( target_os = "linux" ) ) ]
871
864
audio_buffer : AudioBuffer ,
872
865
sample_rate : ( u32 , u32 ) ,
873
- #[ cfg( not( target_os = "linux" ) ) ]
874
866
audio_stream : Option < Box < dyn StreamTrait > > ,
875
867
channels : u16 ,
876
- #[ cfg( not( target_os = "linux" ) ) ]
877
868
device_channel : u16 ,
878
- #[ cfg( not( target_os = "linux" ) ) ]
879
869
ready : Arc < std:: sync:: Mutex < bool > > ,
880
870
}
881
871
882
- #[ cfg( not( target_os = "linux" ) ) ]
883
872
struct AudioBuffer (
884
873
pub Arc < std:: sync:: Mutex < ringbuf:: HeapRb < f32 > > > ,
885
874
usize ,
886
875
[ usize ; 30 ] ,
887
876
) ;
888
877
889
- #[ cfg( not( target_os = "linux" ) ) ]
890
878
impl Default for AudioBuffer {
891
879
fn default ( ) -> Self {
892
880
Self (
@@ -899,7 +887,6 @@ impl Default for AudioBuffer {
899
887
}
900
888
}
901
889
902
- #[ cfg( not( target_os = "linux" ) ) ]
903
890
impl AudioBuffer {
904
891
pub fn resize ( & mut self , sample_rate : usize , channels : usize ) {
905
892
let capacity = sample_rate * channels * AUDIO_BUFFER_MS / 1000 ;
@@ -1002,37 +989,7 @@ impl AudioBuffer {
1002
989
}
1003
990
1004
991
impl AudioHandler {
1005
- #[ cfg( target_os = "linux" ) ]
1006
- fn start_audio ( & mut self , format0 : AudioFormat ) -> ResultType < ( ) > {
1007
- use psimple:: Simple ;
1008
- use pulse:: sample:: { Format , Spec } ;
1009
- use pulse:: stream:: Direction ;
1010
-
1011
- let spec = Spec {
1012
- format : Format :: F32le ,
1013
- channels : format0. channels as _ ,
1014
- rate : format0. sample_rate as _ ,
1015
- } ;
1016
- if !spec. is_valid ( ) {
1017
- bail ! ( "Invalid audio format" ) ;
1018
- }
1019
-
1020
- self . simple = Some ( Simple :: new (
1021
- None , // Use the default server
1022
- & crate :: get_app_name ( ) , // Our application’s name
1023
- Direction :: Playback , // We want a playback stream
1024
- None , // Use the default device
1025
- "playback" , // Description of our stream
1026
- & spec, // Our sample format
1027
- None , // Use default channel map
1028
- None , // Use default buffering attributes
1029
- ) ?) ;
1030
- self . sample_rate = ( format0. sample_rate , format0. sample_rate ) ;
1031
- Ok ( ( ) )
1032
- }
1033
-
1034
992
/// Start the audio playback.
1035
- #[ cfg( not( target_os = "linux" ) ) ]
1036
993
fn start_audio ( & mut self , format0 : AudioFormat ) -> ResultType < ( ) > {
1037
994
let device = AUDIO_HOST
1038
995
. default_output_device ( )
@@ -1100,20 +1057,13 @@ impl AudioHandler {
1100
1057
/// Handle audio frame and play it.
1101
1058
#[ inline]
1102
1059
pub fn handle_frame ( & mut self , frame : AudioFrame ) {
1103
- #[ cfg( not( target_os = "linux" ) ) ]
1104
1060
if self . audio_stream . is_none ( ) || !self . ready . lock ( ) . unwrap ( ) . clone ( ) {
1105
1061
return ;
1106
1062
}
1107
- #[ cfg( target_os = "linux" ) ]
1108
- if self . simple . is_none ( ) {
1109
- log:: debug!( "PulseAudio simple binding does not exists" ) ;
1110
- return ;
1111
- }
1112
1063
self . audio_decoder . as_mut ( ) . map ( |( d, buffer) | {
1113
1064
if let Ok ( n) = d. decode_float ( & frame. data , buffer, false ) {
1114
1065
let channels = self . channels ;
1115
1066
let n = n * ( channels as usize ) ;
1116
- #[ cfg( not( target_os = "linux" ) ) ]
1117
1067
{
1118
1068
let sample_rate0 = self . sample_rate . 0 ;
1119
1069
let sample_rate = self . sample_rate . 1 ;
@@ -1137,18 +1087,11 @@ impl AudioHandler {
1137
1087
}
1138
1088
self . audio_buffer . append_pcm ( & buffer) ;
1139
1089
}
1140
- #[ cfg( target_os = "linux" ) ]
1141
- {
1142
- let data_u8 =
1143
- unsafe { std:: slice:: from_raw_parts :: < u8 > ( buffer. as_ptr ( ) as _ , n * 4 ) } ;
1144
- self . simple . as_mut ( ) . map ( |x| x. write ( data_u8) ) ;
1145
- }
1146
1090
}
1147
1091
} ) ;
1148
1092
}
1149
1093
1150
1094
/// Build audio output stream for current device.
1151
- #[ cfg( not( target_os = "linux" ) ) ]
1152
1095
fn build_output_stream < T : cpal:: Sample + cpal:: SizedSample + cpal:: FromSample < f32 > > (
1153
1096
& mut self ,
1154
1097
config : & StreamConfig ,
0 commit comments