static unsigned int scrobbler_queue_fetch ( const char  key[32],
char **  poststr 
) [static]

Fetch as much tracks from the AudioScrobbler submission queue (at most 10), generate a HTTP/1.1 POST string for submission and return the amount of tracks described in the POST string.

Definition at line 213 of file scrobbler.c.

00214 {
00215         struct scrobbler_entry *ent;
00216         unsigned int len;
00217         GString *str;
00218 
00219         g_mutex_lock(scrobbler_lock);
00220         while ((ent = scrobbler_queue_first) == NULL)
00221                 g_cond_wait(scrobbler_avail, scrobbler_lock);
00222 
00223         str = g_string_new("s=");
00224         g_string_append_len(str, key, 32);
00225         
00226         /* We can submit 50 tracks at a time */
00227         for (len = 0; (len < 50) && (ent != NULL); len++) {
00228                 g_string_append_printf(str,
00229                     "&a[%u]=%s&t[%u]=%s&i[%u]=%u&o[%u]=P&r[%u]=&l[%u]=%u&b[%u]=%s&n[%u]=&m[%u]=",
00230                     len, ent->artist,
00231                     len, ent->title,
00232                     len, (unsigned int)ent->time,
00233                     len, /* No source */
00234                     len, /* No rating */
00235                     len, ent->length,
00236                     len, ent->album,
00237                     len, /* No track number */
00238                     len); /* No MusicBrainz ID */
00239 
00240                 /* Go on to the next item */
00241                 ent = scrobbler_queue_next(ent);
00242         }
00243 
00244         g_mutex_unlock(scrobbler_lock);
00245 
00246         *poststr = g_string_free(str, FALSE);
00247 
00248         /* Return the amount of entries in the poststring */
00249         g_assert(len >= 1);
00250         return (len);
00251 }

Here is the call graph for this function:

Here is the caller graph for this function:

 All Data Structures Files Functions Variables Defines
Generated on Mon Mar 15 04:45:46 2010 for herrie by  doxygen 1.6.3