static void ready (void *hook_data, void *user_data) { cleanup_current_track(); Tuple *current_track = aud_playlist_entry_get_tuple(aud_playlist_get_playing(), aud_playlist_get_position(aud_playlist_get_playing()), FALSE); int duration_seconds = tuple_get_int(current_track, FIELD_LENGTH) / 1000; if (duration_seconds <= 30) { tuple_unref(current_track); return; } pthread_mutex_lock(&communication_mutex); now_playing_track = tuple_ref(current_track); now_playing_requested = TRUE; pthread_cond_signal(&communication_signal); pthread_mutex_unlock(&communication_mutex); time_until_scrobble = (((gint64)duration_seconds)*G_USEC_PER_SEC) / 2; if (time_until_scrobble > 4*60*G_USEC_PER_SEC) { time_until_scrobble = 4*60*G_USEC_PER_SEC; } timestamp = g_get_real_time() / G_USEC_PER_SEC; play_started_at = g_get_monotonic_time(); playing_track = current_track; queue_function_ID = g_timeout_add_seconds(time_until_scrobble / G_USEC_PER_SEC, (GSourceFunc) queue_track_to_scrobble, NULL); }
static int blackhole_space_execute_replace(struct space *space, struct txn *txn, struct request *request, struct tuple **result) { struct txn_stmt *stmt = txn_current_stmt(txn); stmt->new_tuple = tuple_new(space->format, request->tuple, request->tuple_end); if (stmt->new_tuple == NULL) return -1; tuple_ref(stmt->new_tuple); *result = stmt->new_tuple; return 0; }