static void* playq_runner_thread ( void *  unused  )  [static]

Infinitely play music in the playlist, honouring the playq_flags.

Definition at line 158 of file playq.c.

00159 {
00160         struct vfsref           *nvr;
00161         struct audio_file       *cur;
00162         char                    *errmsg;
00163 
00164         gui_input_sigmask();
00165 
00166         do {
00167                 /* Wait until there's a song available */
00168                 playq_lock();
00169                 for (;;) {
00170                         /* Shut down when the user wants to */
00171                         if (playq_flags & PF_QUIT) {
00172                                 playq_unlock();
00173                                 goto done;
00174                         }
00175 
00176                         /* Try to start a new song when we're not stopped */
00177                         if (!(playq_flags & PF_STOP) &&
00178                             (nvr = funcs->give()) != NULL) {
00179                                 /* We've got work to do */
00180                                 break;
00181                         }
00182 
00183                         /* Wait for new events to occur */
00184                         playq_flags |= PF_STOP;
00185                         funcs->idle();
00186                         gui_playq_song_update(NULL, 0, 0);
00187                         g_cond_wait(playq_wakeup, playq_mtx);
00188                 }
00189                 playq_unlock();
00190 
00191                 cur = audio_file_open(nvr);
00192                 if (cur == NULL) {
00193                         /* Skip broken songs */
00194                         errmsg = g_strdup_printf(
00195                             _("Failed to open \"%s\" for playback."),
00196                             vfs_name(nvr));
00197                         gui_msgbar_warn(errmsg);
00198                         g_free(errmsg);
00199                         vfs_close(nvr);
00200                         /* Don't hog the CPU */
00201                         g_usleep(500000);
00202                         continue;
00203                 }
00204 
00205                 /* Trash it */
00206                 vfs_close(nvr);
00207                 gui_playq_song_update(cur, 0, 0);
00208 
00209                 playq_lock();
00210                 playq_flags &= ~(PF_PAUSE|PF_SKIP|PF_SEEK);
00211                 playq_unlock();
00212 
00213                 do  {
00214                         if (playq_flags & PF_PAUSE && !cur->stream) {
00215                                 gui_playq_song_update(cur, 1, 1);
00216 
00217                                 /* Wait to be waken up */
00218                                 playq_lock();
00219                                 g_cond_wait(playq_wakeup, playq_mtx);
00220                                 playq_unlock();
00221                         } else {
00222                                 gui_playq_song_update(cur, 0, 1);
00223 
00224                                 /* Play a part of the audio file */
00225                                 if (audio_output_play(cur) != 0)
00226                                         break;
00227                         }
00228 
00229                         if (playq_flags & PF_SEEK) {
00230                                 audio_file_seek(cur, playq_seek_time,
00231                                     playq_flags & PF_SEEK_REL);
00232                                 playq_lock();
00233                                 playq_flags &= ~PF_SEEK;
00234                                 playq_unlock();
00235                         }
00236                 } while (!(playq_flags & (PF_QUIT|PF_SKIP)));
00237 
00238                 audio_file_close(cur);
00239         } while (!(playq_flags & PF_QUIT));
00240 done:
00241         return (NULL);
00242 }

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:40 2010 for herrie by  doxygen 1.6.3