player_control: added player_control.thread
player_control.thread contains the handle of the player thread, or NULL if the player thread isn't running.
This commit is contained in:
parent
ac0e799965
commit
d628eb3e8b
@ -90,7 +90,11 @@ void playerWait(void)
|
|||||||
|
|
||||||
void playerKill(void)
|
void playerKill(void)
|
||||||
{
|
{
|
||||||
|
assert(pc.thread != NULL);
|
||||||
|
|
||||||
player_command(PLAYER_COMMAND_EXIT);
|
player_command(PLAYER_COMMAND_EXIT);
|
||||||
|
g_thread_join(pc.thread);
|
||||||
|
pc.thread = NULL;
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,10 @@ enum player_error {
|
|||||||
struct player_control {
|
struct player_control {
|
||||||
unsigned int buffered_before_play;
|
unsigned int buffered_before_play;
|
||||||
|
|
||||||
|
/** the handle of the player thread, or NULL if the player
|
||||||
|
thread isn't running */
|
||||||
|
GThread *thread;
|
||||||
|
|
||||||
struct notify notify;
|
struct notify notify;
|
||||||
volatile enum player_command command;
|
volatile enum player_command command;
|
||||||
volatile enum player_state state;
|
volatile enum player_state state;
|
||||||
|
@ -548,8 +548,10 @@ static gpointer player_task(G_GNUC_UNUSED gpointer arg)
|
|||||||
void player_create(void)
|
void player_create(void)
|
||||||
{
|
{
|
||||||
GError *e = NULL;
|
GError *e = NULL;
|
||||||
GThread *t;
|
|
||||||
|
|
||||||
if (!(t = g_thread_create(player_task, NULL, FALSE, &e)))
|
assert(pc.thread == NULL);
|
||||||
|
|
||||||
|
pc.thread = g_thread_create(player_task, NULL, true, &e);
|
||||||
|
if (pc.thread == NULL)
|
||||||
g_error("Failed to spawn player task: %s", e->message);
|
g_error("Failed to spawn player task: %s", e->message);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user