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

void mpd_status_feed ( struct mpd_status status,
const struct mpd_pair pair 
)

Parses the pair, adding its information to the specified mpd_status object.

Definition at line 197 of file status.c.

References mpd_status::audio_format, mpd_status::consume, mpd_status::crossfade, mpd_status::elapsed_ms, mpd_status::elapsed_time, mpd_status::error, mpd_status::kbit_rate, mpd_status_feed(), mpd_pair::name, mpd_status::queue_length, mpd_status::queue_version, mpd_status::random, mpd_status::repeat, mpd_status::single, mpd_status::song_id, mpd_status::song_pos, mpd_status::state, mpd_status::total_time, mpd_status::update_id, mpd_pair::value, and mpd_status::volume.

Referenced by mpd_recv_status(), and mpd_status_feed().

{
      if (strcmp(pair->name, "volume") == 0)
            status->volume = atoi(pair->value);
      else if (strcmp(pair->name, "repeat") == 0)
            status->repeat = !!atoi(pair->value);
      else if (strcmp(pair->name, "random") == 0)
            status->random = !!atoi(pair->value);
      else if (strcmp(pair->name, "single") == 0)
            status->single = !!atoi(pair->value);
      else if (strcmp(pair->name, "consume") == 0)
            status->consume = !!atoi(pair->value);
      else if (strcmp(pair->name, "playlist") == 0)
            status->queue_version = strtol(pair->value, NULL, 10);
      else if (strcmp(pair->name, "playlistlength") == 0)
            status->queue_length = atoi(pair->value);
      else if (strcmp(pair->name, "bitrate") == 0)
            status->kbit_rate = atoi(pair->value);
      else if (strcmp(pair->name, "state") == 0)
            status->state = parse_mpd_state(pair->value);
      else if (strcmp(pair->name, "song") == 0)
            status->song_pos = atoi(pair->value);
      else if (strcmp(pair->name, "songid") == 0)
            status->song_id = atoi(pair->value);
      else if (strcmp(pair->name, "time") == 0) {
            char *endptr;

            status->elapsed_time = strtol(pair->value, &endptr, 10);
            if (*endptr == ':')
                  status->total_time = strtol(endptr + 1, NULL, 10);

            if (status->elapsed_ms == 0)
                  status->elapsed_ms = status->elapsed_time * 1000;
      } else if (strcmp(pair->name, "elapsed") == 0) {
            char *endptr;

            status->elapsed_ms = strtol(pair->value, &endptr, 10) * 1000;
            if (*endptr == '.')
                  status->elapsed_ms += parse_ms(endptr + 1);

            if (status->elapsed_time == 0)
                  status->elapsed_time = status->elapsed_ms / 1000;
      } else if (strcmp(pair->name, "error") == 0) {
            if (status->error != NULL)
                  free(status->error);

            status->error = strdup(pair->value);
      } else if (strcmp(pair->name, "xfade") == 0)
            status->crossfade = atoi(pair->value);
      else if (strcmp(pair->name, "updating_db") == 0)
            status->update_id = atoi(pair->value);
      else if (strcmp(pair->name, "audio") == 0)
            parse_audio_format(&status->audio_format, pair->value);
}


Generated by  Doxygen 1.6.0   Back to index