@@ -2,7 +2,7 @@ use super::{Open, Sink, SinkError, SinkResult};
22use crate :: config:: AudioFormat ;
33use crate :: convert:: Converter ;
44use crate :: decoder:: AudioPacket ;
5- use crate :: { NUM_CHANNELS , SAMPLE_RATE } ;
5+ use crate :: NUM_CHANNELS ;
66use portaudio_rs:: device:: { get_default_output_index, DeviceIndex , DeviceInfo } ;
77use portaudio_rs:: stream:: * ;
88use std:: process:: exit;
@@ -76,14 +76,14 @@ impl<'a> Open for PortAudioSink<'a> {
7676 } ;
7777
7878 macro_rules! open_sink {
79- ( $sink: expr, $type: ty) => { {
79+ ( $sink: expr, $type: ty, $samples : expr ) => { {
8080 let params = StreamParameters {
8181 device: device_idx,
8282 channel_count: NUM_CHANNELS as u32 ,
8383 suggested_latency: latency,
8484 data: 0.0 as $type,
8585 } ;
86- $sink( None , params, sample_rate)
86+ $sink( None , params, $ sample_rate)
8787 } } ;
8888 }
8989 match format {
@@ -141,9 +141,9 @@ impl<'a> Sink for PortAudioSink<'a> {
141141 } } ;
142142 }
143143 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) ,
147147 } ;
148148
149149 Ok ( ( ) )
@@ -161,15 +161,15 @@ impl<'a> Sink for PortAudioSink<'a> {
161161 . map_err ( |e| SinkError :: OnWrite ( e. to_string ( ) ) ) ?;
162162
163163 let result = match self {
164- Self :: F32 ( stream, _parameters) => {
164+ Self :: F32 ( stream, _parameters, _sample_rate ) => {
165165 let samples_f32: & [ f32 ] = & converter. f64_to_f32 ( samples) ;
166166 write_sink ! ( ref mut stream, samples_f32)
167167 }
168- Self :: S32 ( stream, _parameters) => {
168+ Self :: S32 ( stream, _parameters, _sample_rate ) => {
169169 let samples_s32: & [ i32 ] = & converter. f64_to_s32 ( samples) ;
170170 write_sink ! ( ref mut stream, samples_s32)
171171 }
172- Self :: S16 ( stream, _parameters) => {
172+ Self :: S16 ( stream, _parameters, _sample_rate ) => {
173173 let samples_s16: & [ i16 ] = & converter. f64_to_s16 ( samples) ;
174174 write_sink ! ( ref mut stream, samples_s16)
175175 }
0 commit comments