event_pipe: renamed functions from main_notify_* to event_pipe_*

Continuing the previous patch.
This commit is contained in:
Max Kellermann 2009-01-01 18:12:14 +01:00
parent 9f5934d95b
commit 22bb5a5856
8 changed files with 27 additions and 27 deletions

View File

@ -58,7 +58,7 @@ db_init(void)
g_error("directory update failed");
do {
wait_main_task();
event_pipe_wait();
reap_update_task();
} while (isUpdatingDB());

View File

@ -26,13 +26,13 @@
#include <glib.h>
#include <string.h>
static int main_pipe[2];
GThread *main_task;
static int event_pipe[2];
static void consume_pipe(void)
{
char buffer[256];
ssize_t r = read(main_pipe[0], buffer, sizeof(buffer));
ssize_t r = read(event_pipe[0], buffer, sizeof(buffer));
if (r < 0 && errno != EAGAIN && errno != EINTR)
FATAL("error reading from pipe: %s\n", strerror(errno));
@ -48,38 +48,38 @@ main_notify_event(G_GNUC_UNUSED GIOChannel *source,
return true;
}
void init_main_notify(void)
void event_pipe_init(void)
{
GIOChannel *channel;
main_task = g_thread_self();
if (pipe(main_pipe) < 0)
if (pipe(event_pipe) < 0)
g_error("Couldn't open pipe: %s", strerror(errno));
if (set_nonblocking(main_pipe[1]) < 0)
if (set_nonblocking(event_pipe[1]) < 0)
g_error("Couldn't set non-blocking I/O: %s", strerror(errno));
channel = g_io_channel_unix_new(main_pipe[0]);
channel = g_io_channel_unix_new(event_pipe[0]);
g_io_add_watch(channel, G_IO_IN, main_notify_event, NULL);
g_io_channel_unref(channel);
main_task = g_thread_self();
}
void deinit_main_notify(void)
void event_pipe_deinit(void)
{
xclose(main_pipe[0]);
xclose(main_pipe[1]);
xclose(event_pipe[0]);
xclose(event_pipe[1]);
}
void wakeup_main_task(void)
void event_pipe_signal(void)
{
ssize_t w = write(main_pipe[1], "", 1);
ssize_t w = write(event_pipe[1], "", 1);
if (w < 0 && errno != EAGAIN && errno != EINTR)
g_error("error writing to pipe: %s", strerror(errno));
}
void wait_main_task(void)
void event_pipe_wait(void)
{
consume_pipe();
}

View File

@ -25,13 +25,13 @@
extern GThread *main_task;
void init_main_notify(void);
void event_pipe_init(void);
void deinit_main_notify(void);
void event_pipe_deinit(void);
void wakeup_main_task(void);
void event_pipe_signal(void);
void wait_main_task(void);
void event_pipe_wait(void);
void
main_notify_triggered(void);

View File

@ -66,7 +66,7 @@ idle_add(unsigned flags)
idle_flags |= flags;
g_mutex_unlock(idle_mutex);
wakeup_main_task();
event_pipe_signal();
}
unsigned

View File

@ -253,7 +253,7 @@ int main(int argc, char *argv[])
decoder_plugin_init_all();
update_global_init();
init_main_notify();
event_pipe_init();
openDB(&options, argv[0]);
@ -308,7 +308,7 @@ int main(int argc, char *argv[])
g_debug("db_finish took %f seconds",
((float)(clock()-start))/CLOCKS_PER_SEC);
deinit_main_notify();
event_pipe_deinit();
input_stream_global_finish();
finishNormalization();

View File

@ -58,7 +58,7 @@ static void player_command(enum player_command cmd)
pc.command = cmd;
while (pc.command != PLAYER_COMMAND_NONE) {
notify_signal(&pc.notify);
wait_main_task();
event_pipe_wait();
}
}

View File

@ -83,14 +83,14 @@ static void player_command_finished(void)
assert(pc.command != PLAYER_COMMAND_NONE);
pc.command = PLAYER_COMMAND_NONE;
wakeup_main_task();
event_pipe_signal();
}
static void player_stop_decoder(void)
{
dc_stop(&pc.notify);
pc.state = PLAYER_STATE_STOP;
wakeup_main_task();
event_pipe_signal();
}
static int player_wait_for_decoder(struct player *player)
@ -369,7 +369,7 @@ static void do_play(void)
request the next song from the playlist */
pc.next_song = NULL;
wakeup_main_task();
event_pipe_signal();
}
if (decoder_is_idle() && player.queued) {
@ -476,7 +476,7 @@ static void do_play(void)
if (player_wait_for_decoder(&player) < 0)
return;
wakeup_main_task();
event_pipe_signal();
} else if (decoder_is_idle()) {
break;
} else {

View File

@ -98,7 +98,7 @@ delete_song(struct directory *dir, struct song *del)
cond_enter(&delete_cond);
assert(!delete);
delete = del;
wakeup_main_task();
event_pipe_signal();
do { cond_wait(&delete_cond); } while (delete);
cond_leave(&delete_cond);
@ -603,7 +603,7 @@ static void * update_task(void *_path)
if (modified)
db_save();
progress = UPDATE_PROGRESS_DONE;
wakeup_main_task();
event_pipe_signal();
return NULL;
}