diff options
Diffstat (limited to 'plugins/lastfm')
-rw-r--r-- | plugins/lastfm/lastfm.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/lastfm/lastfm.c b/plugins/lastfm/lastfm.c index 63724879..63dcca39 100644 --- a/plugins/lastfm/lastfm.c +++ b/plugins/lastfm/lastfm.c @@ -466,7 +466,7 @@ lastfm_songfinished (DB_event_track_t *ev, uintptr_t data) { // check submission rules // duration must be >= 30 sec if (deadbeef->pl_get_item_duration (ev->track) < 30) { - trace ("track duration is %f seconds. not eligible for submission\n", ev->song->duration); + trace ("track duration is %f seconds. not eligible for submission\n", deadbeef->pl_get_item_duration (ev->track)); return 0; } // must be played for >=240sec of half the total time @@ -552,7 +552,7 @@ lfm_send_submissions (void) { char *r = req; int len = sizeof (req); int res; - deadbeef->mutex_lock (lfm_mutex); +// deadbeef->mutex_lock (lfm_mutex); for (i = 0; i < LFM_SUBMISSION_QUEUE_SIZE; i++) { if (lfm_subm_queue[i]) { res = lfm_format_uri (idx, lfm_subm_queue[i], r, len); @@ -565,7 +565,7 @@ lfm_send_submissions (void) { idx++; } } - deadbeef->mutex_unlock (lfm_mutex); +// deadbeef->mutex_unlock (lfm_mutex); if (!idx) { return; } @@ -605,7 +605,7 @@ lfm_send_submissions (void) { lfm_subm_queue[i] = NULL; } } - deadbeef->mutex_unlock (lfm_mutex); +// deadbeef->mutex_unlock (lfm_mutex); } } curl_req_cleanup (); @@ -613,14 +613,14 @@ lfm_send_submissions (void) { } #else trace ("submission successful (NOSEND=1):\n"); - deadbeef->mutex_lock (lfm_mutex); +// deadbeef->mutex_lock (lfm_mutex); for (i = 0; i < LFM_SUBMISSION_QUEUE_SIZE; i++) { if (lfm_subm_queue[i]) { deadbeef->pl_item_free (lfm_subm_queue[i]); lfm_subm_queue[i] = NULL; } } - deadbeef->mutex_unlock (lfm_mutex); +// deadbeef->mutex_unlock (lfm_mutex); #endif } @@ -628,6 +628,7 @@ static void lfm_thread (void *ctx) { //trace ("lfm_thread started\n"); for (;;) { + trace ("lfm wating for cond...\n"); deadbeef->cond_wait (lfm_cond, lfm_mutex); trace ("cond signalled!\n"); if (lfm_stopthread) { @@ -636,14 +637,19 @@ lfm_thread (void *ctx) { trace ("lfm_thread end\n"); return; } - deadbeef->mutex_unlock (lfm_mutex); + trace ("lfm sending nowplaying...\n"); // try to send nowplaying if (lfm_nowplaying[0]) { lfm_send_nowplaying (); } +// if (lfm_stopthread) { +// trace ("lfm_stopthread after lfm_send_nowplaying\n"); +// return; +// } lfm_send_submissions (); + deadbeef->mutex_unlock (lfm_mutex); } } @@ -763,11 +769,18 @@ static int lastfm_stop (void) { trace ("lastfm_stop\n"); if (lfm_mutex) { + trace ("lfm_stop locking mutex\n"); lfm_abort = 1; + deadbeef->mutex_lock (lfm_mutex); + lfm_stopthread = 1; deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGSTARTED, DB_CALLBACK (lastfm_songstarted), 0); deadbeef->ev_unsubscribe (DB_PLUGIN (&plugin), DB_EV_SONGFINISHED, DB_CALLBACK (lastfm_songfinished), 0); - lfm_stopthread = 1; + trace ("lfm_stop unlocking mutex\n"); + deadbeef->mutex_unlock (lfm_mutex); + + trace ("lfm_stop signalling cond\n"); deadbeef->cond_signal (lfm_cond); + trace ("waiting for thread to finish\n"); deadbeef->thread_join (lfm_tid); lfm_tid = 0; deadbeef->cond_free (lfm_cond); |