summaryrefslogtreecommitdiff
path: root/streamer.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-08 19:32:37 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-08 19:32:37 +0200
commite3fb7fcd09e6e87390ff0dae2148f1975cac858b (patch)
tree42eddbc661683aa69a60ad8ebf8c89aac8fcc5a4 /streamer.c
parent30e0e82f695a5d04ee75b5caf09283fd0a6533ec (diff)
fixed streamer hang when opening bad radio streams
Diffstat (limited to 'streamer.c')
-rw-r--r--streamer.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/streamer.c b/streamer.c
index a6dc43bd..818e5fc9 100644
--- a/streamer.c
+++ b/streamer.c
@@ -112,6 +112,21 @@ src_unlock (void) {
mutex_unlock (srcmutex);
}
+static void
+streamer_abort_files (void) {
+ if (fileinfo && fileinfo->file) {
+ trace ("\033[0;31maborting current song: %s (fileinfo %p, file %p)\033[37;0m\n", streaming_track ? streaming_track->fname : NULL, fileinfo, fileinfo ? fileinfo->file : NULL);
+ deadbeef->fabort (fileinfo->file);
+ trace ("\033[0;31maborting current song done\033[37;0m\n");
+ }
+ mutex_lock (decodemutex);
+ if (streamer_file) {
+ trace ("\033[0;31maborting streamer_file\033[37;0m\n");
+ deadbeef->fabort (streamer_file);
+ }
+ mutex_unlock (decodemutex);
+}
+
void
streamer_start_playback (playItem_t *from, playItem_t *it) {
if (from) {
@@ -638,6 +653,12 @@ streamer_set_current (playItem_t *it) {
if (playlist_track == it) {
plug_trigger_event_trackinfochanged (to);
}
+ if (from) {
+ pl_item_unref (from);
+ }
+ if (to) {
+ pl_item_unref (to);
+ }
return -1;
}
// if (bytes_until_next_song == -1) {
@@ -679,17 +700,7 @@ streamer_get_apx_bitrate (void) {
void
streamer_set_nextsong (int song, int pstate) {
trace ("streamer_set_nextsong %d %d\n", song, pstate);
- if (fileinfo && fileinfo->file) {
- trace ("\033[0;31maborting current song: %s (fileinfo %p, file %p)\033[37;0m\n", streaming_track ? streaming_track->fname : NULL, fileinfo, fileinfo ? fileinfo->file : NULL);
- deadbeef->fabort (fileinfo->file);
- mutex_lock (decodemutex);
- if (streamer_file) {
- trace ("\033[0;31maborting streamer_file\033[37;0m\n");
- deadbeef->fabort (streamer_file);
- }
- mutex_unlock (decodemutex);
- trace ("\033[0;31maborting current song done\033[37;0m\n");
- }
+ streamer_abort_files ();
nextsong = song;
nextsong_pstate = pstate;
if (p_isstopped ()) {
@@ -1073,6 +1084,7 @@ streamer_init (void) {
void
streamer_free (void) {
+ streamer_abort_files ();
streaming_terminate = 1;
thread_join (streamer_tid);
mutex_free (decodemutex);