event_pipe: renamed functions from main_notify_* to event_pipe_*
Continuing the previous patch.
This commit is contained in:
@@ -58,7 +58,7 @@ db_init(void)
|
|||||||
g_error("directory update failed");
|
g_error("directory update failed");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
wait_main_task();
|
event_pipe_wait();
|
||||||
reap_update_task();
|
reap_update_task();
|
||||||
} while (isUpdatingDB());
|
} while (isUpdatingDB());
|
||||||
|
|
||||||
|
@@ -26,13 +26,13 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int main_pipe[2];
|
|
||||||
GThread *main_task;
|
GThread *main_task;
|
||||||
|
static int event_pipe[2];
|
||||||
|
|
||||||
static void consume_pipe(void)
|
static void consume_pipe(void)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
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)
|
if (r < 0 && errno != EAGAIN && errno != EINTR)
|
||||||
FATAL("error reading from pipe: %s\n", strerror(errno));
|
FATAL("error reading from pipe: %s\n", strerror(errno));
|
||||||
@@ -48,38 +48,38 @@ main_notify_event(G_GNUC_UNUSED GIOChannel *source,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_main_notify(void)
|
void event_pipe_init(void)
|
||||||
{
|
{
|
||||||
GIOChannel *channel;
|
GIOChannel *channel;
|
||||||
|
|
||||||
main_task = g_thread_self();
|
main_task = g_thread_self();
|
||||||
|
|
||||||
if (pipe(main_pipe) < 0)
|
if (pipe(event_pipe) < 0)
|
||||||
g_error("Couldn't open pipe: %s", strerror(errno));
|
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));
|
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_add_watch(channel, G_IO_IN, main_notify_event, NULL);
|
||||||
g_io_channel_unref(channel);
|
g_io_channel_unref(channel);
|
||||||
|
|
||||||
main_task = g_thread_self();
|
main_task = g_thread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deinit_main_notify(void)
|
void event_pipe_deinit(void)
|
||||||
{
|
{
|
||||||
xclose(main_pipe[0]);
|
xclose(event_pipe[0]);
|
||||||
xclose(main_pipe[1]);
|
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)
|
if (w < 0 && errno != EAGAIN && errno != EINTR)
|
||||||
g_error("error writing to pipe: %s", strerror(errno));
|
g_error("error writing to pipe: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_main_task(void)
|
void event_pipe_wait(void)
|
||||||
{
|
{
|
||||||
consume_pipe();
|
consume_pipe();
|
||||||
}
|
}
|
||||||
|
@@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
extern GThread *main_task;
|
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
|
void
|
||||||
main_notify_triggered(void);
|
main_notify_triggered(void);
|
||||||
|
@@ -66,7 +66,7 @@ idle_add(unsigned flags)
|
|||||||
idle_flags |= flags;
|
idle_flags |= flags;
|
||||||
g_mutex_unlock(idle_mutex);
|
g_mutex_unlock(idle_mutex);
|
||||||
|
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
|
|||||||
decoder_plugin_init_all();
|
decoder_plugin_init_all();
|
||||||
update_global_init();
|
update_global_init();
|
||||||
|
|
||||||
init_main_notify();
|
event_pipe_init();
|
||||||
|
|
||||||
openDB(&options, argv[0]);
|
openDB(&options, argv[0]);
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
|
|||||||
g_debug("db_finish took %f seconds",
|
g_debug("db_finish took %f seconds",
|
||||||
((float)(clock()-start))/CLOCKS_PER_SEC);
|
((float)(clock()-start))/CLOCKS_PER_SEC);
|
||||||
|
|
||||||
deinit_main_notify();
|
event_pipe_deinit();
|
||||||
|
|
||||||
input_stream_global_finish();
|
input_stream_global_finish();
|
||||||
finishNormalization();
|
finishNormalization();
|
||||||
|
@@ -58,7 +58,7 @@ static void player_command(enum player_command cmd)
|
|||||||
pc.command = cmd;
|
pc.command = cmd;
|
||||||
while (pc.command != PLAYER_COMMAND_NONE) {
|
while (pc.command != PLAYER_COMMAND_NONE) {
|
||||||
notify_signal(&pc.notify);
|
notify_signal(&pc.notify);
|
||||||
wait_main_task();
|
event_pipe_wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,14 +83,14 @@ static void player_command_finished(void)
|
|||||||
assert(pc.command != PLAYER_COMMAND_NONE);
|
assert(pc.command != PLAYER_COMMAND_NONE);
|
||||||
|
|
||||||
pc.command = PLAYER_COMMAND_NONE;
|
pc.command = PLAYER_COMMAND_NONE;
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void player_stop_decoder(void)
|
static void player_stop_decoder(void)
|
||||||
{
|
{
|
||||||
dc_stop(&pc.notify);
|
dc_stop(&pc.notify);
|
||||||
pc.state = PLAYER_STATE_STOP;
|
pc.state = PLAYER_STATE_STOP;
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int player_wait_for_decoder(struct player *player)
|
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 */
|
request the next song from the playlist */
|
||||||
|
|
||||||
pc.next_song = NULL;
|
pc.next_song = NULL;
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decoder_is_idle() && player.queued) {
|
if (decoder_is_idle() && player.queued) {
|
||||||
@@ -476,7 +476,7 @@ static void do_play(void)
|
|||||||
if (player_wait_for_decoder(&player) < 0)
|
if (player_wait_for_decoder(&player) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
} else if (decoder_is_idle()) {
|
} else if (decoder_is_idle()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -98,7 +98,7 @@ delete_song(struct directory *dir, struct song *del)
|
|||||||
cond_enter(&delete_cond);
|
cond_enter(&delete_cond);
|
||||||
assert(!delete);
|
assert(!delete);
|
||||||
delete = del;
|
delete = del;
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
do { cond_wait(&delete_cond); } while (delete);
|
do { cond_wait(&delete_cond); } while (delete);
|
||||||
cond_leave(&delete_cond);
|
cond_leave(&delete_cond);
|
||||||
|
|
||||||
@@ -603,7 +603,7 @@ static void * update_task(void *_path)
|
|||||||
if (modified)
|
if (modified)
|
||||||
db_save();
|
db_save();
|
||||||
progress = UPDATE_PROGRESS_DONE;
|
progress = UPDATE_PROGRESS_DONE;
|
||||||
wakeup_main_task();
|
event_pipe_signal();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user