fix no audio issue with sample rate >= 48000 and strange crash issue
(there is some overflow in unsafe code, will test again)
This commit is contained in:
parent
5b2c1eea75
commit
7630713534
@ -105,6 +105,9 @@ pub fn get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
|
||||
bm_mask.bmHeight / 2
|
||||
};
|
||||
let cbits_size = width * height * 4;
|
||||
if cbits_size < 16 {
|
||||
bail!("Invalid icon: too small"); // solve some crash
|
||||
}
|
||||
let mut cbits: Vec<u8> = Vec::new();
|
||||
cbits.resize(cbits_size as _, 0);
|
||||
let mut mbits: Vec<u8> = Vec::new();
|
||||
|
@ -198,6 +198,7 @@ mod cpal_impl {
|
||||
log::error!("an error occurred on stream: {}", err);
|
||||
};
|
||||
// Sample rate must be one of 8000, 12000, 16000, 24000, or 48000.
|
||||
// Note: somehow 48000 not work
|
||||
let sample_rate_0 = config.sample_rate().0;
|
||||
let sample_rate = if sample_rate_0 < 12000 {
|
||||
8000
|
||||
@ -205,10 +206,8 @@ mod cpal_impl {
|
||||
12000
|
||||
} else if sample_rate_0 < 24000 {
|
||||
16000
|
||||
} else if sample_rate_0 < 48000 {
|
||||
24000
|
||||
} else {
|
||||
48000
|
||||
24000
|
||||
};
|
||||
let mut encoder = Encoder::new(
|
||||
sample_rate,
|
||||
|
Loading…
x
Reference in New Issue
Block a user