int get_next_line(const int fd, char **line) { char *buf; int ret; static char *last = NULL; int i; i = 0; if (!line || fd < 0 || BUFF_SIZE <= 0 || BUFF_SIZE > 2147483647 || (-1 == (ret = check_last(line, &last, i)))) return (-1); if (ret == 1) return (1); buf = ft_strnew(BUFF_SIZE); if (check_ma(-2, &buf, line) == -1) return (-1); ret = read(fd, buf, BUFF_SIZE); if (check_ma(ret, &buf, line) == -1) return (-1); if (-1 == (ret = fill_line(&buf, fd, line, ret))) return (-1); if (ret == 1 || ret == 0) return (ret); return (create_last(&buf, &last, line) != 1 ? -1 : 1); }
void sr_session_pause(sr_session_t *s) { struct sr_session_priv *priv = s->priv; g_mutex_lock(priv->queue_mutex); check_last(s, time(NULL)); g_mutex_unlock(priv->queue_mutex); }
void sr_session_add_track(sr_session_t *s, sr_track_t *t) { struct sr_session_priv *priv = s->priv; if (priv->np_timer) g_source_remove(priv->np_timer); priv->np_timer = g_timeout_add_seconds(3, do_now_playing, s); g_mutex_lock(priv->queue_mutex); check_last(s, t->timestamp); priv->last_track = t; g_mutex_unlock(priv->queue_mutex); }