Fix the problem of songs not advancing without client activity

The select() in the main event loop blocks now (saving us many
unnecessary wakeups).  This interacted badly with the threads
that were trying to wakeup the main task via
pthread_cond_signal() since the main task was not blocked
on a condition variable, but on select().

So now if we detect a need to wakeup the player, we write
to a pipe which select() is watching instead of blindly
calling pthread_cond_signal().

git-svn-id: https://svn.musicpd.org/mpd/trunk@7347 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong
2008-04-12 09:46:11 +00:00
parent 804088f590
commit baf9b94ecf
8 changed files with 173 additions and 20 deletions

View File

@@ -43,6 +43,7 @@
#include "utils.h"
#include "normalize.h"
#include "zeroconf.h"
#include "main_notify.h"
#include "os_compat.h"
#define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf"
@@ -56,8 +57,6 @@ typedef struct _Options {
int verbose;
} Options;
static Notify main_notify;
/*
* from git-1.3.0, needed for solaris
*/
@@ -380,16 +379,6 @@ static void killFromPidFile(char *cmd, int killOption)
exit(EXIT_SUCCESS);
}
void wakeup_main_task(void)
{
notifySignal(&main_notify);
}
void wait_main_task(void)
{
notifySignal(&main_notify);
}
int main(int argc, char *argv[])
{
Options options;
@@ -432,10 +421,9 @@ int main(int argc, char *argv[])
initNormalization();
initInputStream();
notifyInit(&main_notify);
daemonize(&options);
init_main_notify();
setup_log_output(options.stdOutput);
initSigHandlers();
@@ -447,8 +435,6 @@ int main(int argc, char *argv[])
playerInit(&getPlayerData()->playerControl);
read_state_file();
notifyEnter(&main_notify);
while (COMMAND_RETURN_KILL != doIOForInterfaces() &&
COMMAND_RETURN_KILL != handlePendingSignals()) {
syncPlayerAndPlaylist();