@@ -2,7 +2,7 @@ use super::{Open, Sink, SinkError, SinkResult};
2
2
use crate :: config:: AudioFormat ;
3
3
use crate :: convert:: Converter ;
4
4
use crate :: decoder:: AudioPacket ;
5
- use crate :: { NUM_CHANNELS , SAMPLE_RATE } ;
5
+ use crate :: NUM_CHANNELS ;
6
6
use portaudio_rs:: device:: { get_default_output_index, DeviceIndex , DeviceInfo } ;
7
7
use portaudio_rs:: stream:: * ;
8
8
use std:: process:: exit;
@@ -76,14 +76,14 @@ impl<'a> Open for PortAudioSink<'a> {
76
76
} ;
77
77
78
78
macro_rules! open_sink {
79
- ( $sink: expr, $type: ty) => { {
79
+ ( $sink: expr, $type: ty, $samples : expr ) => { {
80
80
let params = StreamParameters {
81
81
device: device_idx,
82
82
channel_count: NUM_CHANNELS as u32 ,
83
83
suggested_latency: latency,
84
84
data: 0.0 as $type,
85
85
} ;
86
- $sink( None , params, sample_rate)
86
+ $sink( None , params, $ sample_rate)
87
87
} } ;
88
88
}
89
89
match format {
@@ -141,9 +141,9 @@ impl<'a> Sink for PortAudioSink<'a> {
141
141
} } ;
142
142
}
143
143
match self {
144
- Self :: F32 ( stream, _) => stop_sink ! ( ref mut stream) ,
145
- Self :: S32 ( stream, _) => stop_sink ! ( ref mut stream) ,
146
- Self :: S16 ( stream, _) => stop_sink ! ( ref mut stream) ,
144
+ Self :: F32 ( stream, _, _ ) => stop_sink ! ( ref mut stream) ,
145
+ Self :: S32 ( stream, _, _ ) => stop_sink ! ( ref mut stream) ,
146
+ Self :: S16 ( stream, _, _ ) => stop_sink ! ( ref mut stream) ,
147
147
} ;
148
148
149
149
Ok ( ( ) )
@@ -161,15 +161,15 @@ impl<'a> Sink for PortAudioSink<'a> {
161
161
. map_err ( |e| SinkError :: OnWrite ( e. to_string ( ) ) ) ?;
162
162
163
163
let result = match self {
164
- Self :: F32 ( stream, _parameters) => {
164
+ Self :: F32 ( stream, _parameters, _sample_rate ) => {
165
165
let samples_f32: & [ f32 ] = & converter. f64_to_f32 ( samples) ;
166
166
write_sink ! ( ref mut stream, samples_f32)
167
167
}
168
- Self :: S32 ( stream, _parameters) => {
168
+ Self :: S32 ( stream, _parameters, _sample_rate ) => {
169
169
let samples_s32: & [ i32 ] = & converter. f64_to_s32 ( samples) ;
170
170
write_sink ! ( ref mut stream, samples_s32)
171
171
}
172
- Self :: S16 ( stream, _parameters) => {
172
+ Self :: S16 ( stream, _parameters, _sample_rate ) => {
173
173
let samples_s16: & [ i16 ] = & converter. f64_to_s16 ( samples) ;
174
174
write_sink ! ( ref mut stream, samples_s16)
175
175
}
0 commit comments