mirror of
https://github.com/ivabus/lonelyradio
synced 2024-11-22 08:05:10 +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]]
|
[[package]]
|
||||||
name = "lonelyradio"
|
name = "lonelyradio"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lonelyradio"
|
name = "lonelyradio"
|
||||||
description = "TCP radio for singles"
|
description = "TCP radio for singles"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = [ "Ivan Bushchik <ivabus@ivabus.dev>" ]
|
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();
|
.unwrap();
|
||||||
for sample in samples {
|
for sample in samples {
|
||||||
if s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await.is_err() {
|
let result = s.write(&((sample * 32768_f32) as i16).to_le_bytes()).await;
|
||||||
break 'track;
|
if result.is_err() {
|
||||||
|
// Socket error -> stop
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if result.unwrap() == 0 {
|
||||||
|
// If socket cannot accept data -> stop
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue