Logo Search packages:      
Sourcecode: libmpdclient version File versions  Download package

mpd_malloc struct mpd_song* mpd_recv_song ( struct mpd_connection connection  )  [read]

Receives the next song from the MPD server.

a mpd_song object, or NULL on error or if the song list is finished

Definition at line 389 of file song.c.

References mpd_connection::error, mpd_enqueue_pair(), MPD_ERROR_OOM, mpd_recv_pair(), mpd_recv_pair_named(), mpd_recv_song(), mpd_return_pair(), mpd_song_begin(), mpd_song_feed(), and mpd_song_free().

Referenced by mpd_recv_song(), mpd_run_current_song(), mpd_run_get_queue_song_id(), and mpd_run_get_queue_song_pos().

      struct mpd_pair *pair;
      struct mpd_song *song;

      pair = mpd_recv_pair_named(connection, "file");
      if (pair == NULL)
            return NULL;

      song = mpd_song_begin(pair);
      mpd_return_pair(connection, pair);
      if (song == NULL) {
            mpd_error_code(&connection->error, MPD_ERROR_OOM);
            return NULL;

      while ((pair = mpd_recv_pair(connection)) != NULL &&
             mpd_song_feed(song, pair))
            mpd_return_pair(connection, pair);

      if (mpd_error_is_defined(&connection->error)) {
            return NULL;

      /* unread this pair for the next mpd_recv_song() call */
      mpd_enqueue_pair(connection, pair);

      return song;

Generated by  Doxygen 1.6.0   Back to index