tramhao / termusic

Music Player TUI written in Rust
GNU General Public License v3.0
968 stars 42 forks source link

rusty backend network download for radio open *2* duplicate streams #242

Closed hasezoey closed 3 months ago

hasezoey commented 3 months ago

Rusty backend currently opens 2 streams, one for the actual audio data and one for audio data + icy metadata, meaning there are 2 active streams doing the same thing, but just doing one audio data + icy metadata would mean filtering out the metadata as symphonia does not directly handle it.

stream 1, used for symphonia: https://github.com/tramhao/termusic/blob/04c6ff5040769247d24c9c06d2dde67355852472/stream/src/http.rs#L46-L50

streams 2, used for metadata: https://github.com/tramhao/termusic/blob/04c6ff5040769247d24c9c06d2dde67355852472/stream/src/http.rs#L72-L76

maybe related #238

hasezoey commented 3 months ago

@tramhao should i try fixing this (with current dev a84b0c59e414965aeab85824a3c7287ae1dd4f27), or do you want to try?

(i ask to not do duplicate work and interfere)

tramhao commented 3 months ago

Which problem you're referring to?

hasezoey commented 3 months ago

this issue #242 (but likely it would also include #238)

tramhao commented 3 months ago

I'm still trying to fix #238. For #242 I don't know if you have better ideas. Currently still two stream opened.

tramhao commented 3 months ago

I fixed #238. I'll merge it into master. Please start from master. Thanks so much!

hasezoey commented 3 months ago

i have made a initial implementation, some clean-up and extra tests pending (i only have the test in mod tests and tested only one station), also need to handle the case where there is no icy-metadata.

commit: https://github.com/hasezoey/termusic/commit/3378a50c834d22f4196368f50a1b822ddf207530

branch

if you want you can try it and report back any problems you have had (i will stop here for today)

tramhao commented 3 months ago

I merge the fixes. Meanwhile, I found the metadata parsing could have problem. For the stations I used, before I could get the music title, but now I cannot. The link is as below:

http://war.str3am.com:7780/WUISRIS-2
https://live.musopen.org:8085/streamvbr0
hasezoey commented 3 months ago

I merge the fixes. Meanwhile, I found the metadata parsing could have problem. For the stations I used, before I could get the music title, but now I cannot. The link is as below:

as a note, please dont merge branches or changes from my fork unless there is a PR. i had explicitly noted that i need to do more testing and do cleanup and would appreciate some testing if wanted (not having it merged yet).

hasezoey commented 3 months ago

For the stations I used, before I could get the music title, but now I cannot. The link is as below:

for http://war.str3am.com:7780/WUISRIS-2 i dont see any metadata being set, the interval is 1600, but the length is either 0 or has StreamTitle=''; and never any actual text. (i played it for about 20 minutes). (i also tested this stream with the same behavior on 684624439c3af90e5a1edf0ed709571c61aa1f2b(before the 1 stream change) and 04c6ff5040769247d24c9c06d2dde67355852472(before going to stream-download or any recent radio changes)

and https://live.musopen.org:8085/streamvbr0 just works, in my case it instantly (within 5 seconds) got StreamTitle='Glenn Gould, Leonard Bernstein, New York Philharmonic - Piano Concerto No. 2 in B Flat Major, Op. 19 - III. Rondo (Molto allegro)';

also i added a small fix that uses icy-description (if present) for the radio title until the title metadata can be found and will be set