mirror of
https://github.com/ivabus/lonelyradio
synced 2024-11-21 15:45:09 +03:00
0.1.1: small tcp socket fixes
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
c2d3ad0389
commit
d32aceb82c
3 changed files with 11 additions and 4 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -320,7 +320,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
|||
|
||||
[[package]]
|
||||
name = "lonelyradio"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "lonelyradio"
|
||||
description = "TCP radio for singles"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
authors = [ "Ivan Bushchik <ivabus@ivabus.dev>" ]
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -106,8 +106,15 @@ async fn stream(mut s: TcpStream) {
|
|||
)
|
||||
.unwrap();
|
||||
for sample in samples {
|
||||
if s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await.is_err() {
|
||||
break 'track;
|
||||
let result = s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await;
|
||||
if result.is_err() {
|
||||
// Socket error -> stop
|
||||
return;
|
||||
} else {
|
||||
if result.unwrap() == 0 {
|
||||
// If socket cannot accept data -> stop
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue