aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/output_control.c4
-rw-r--r--src/output_init.c2
-rw-r--r--src/output_internal.h5
-rw-r--r--src/output_thread.c10
4 files changed, 9 insertions, 12 deletions
diff --git a/src/output_control.c b/src/output_control.c
index 4bf398d0a..c0e7d001a 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -77,7 +77,7 @@ audio_output_open(struct audio_output *audioOutput,
audio_output_close(audioOutput);
}
- if (audioOutput->thread == 0)
+ if (audioOutput->thread == NULL)
audio_output_thread_start(audioOutput);
if (!audioOutput->open)
@@ -135,7 +135,7 @@ void audio_output_close(struct audio_output *audioOutput)
void audio_output_finish(struct audio_output *audioOutput)
{
audio_output_close(audioOutput);
- if (audioOutput->thread != 0)
+ if (audioOutput->thread != NULL)
ao_command(audioOutput, AO_COMMAND_KILL);
if (audioOutput->plugin->finish)
audioOutput->plugin->finish(audioOutput->data);
diff --git a/src/output_init.c b/src/output_init.c
index bdd2b1eb6..8423e4bbb 100644
--- a/src/output_init.c
+++ b/src/output_init.c
@@ -102,7 +102,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
} else
audio_format_clear(&ao->reqAudioFormat);
- ao->thread = 0;
+ ao->thread = NULL;
notify_init(&ao->notify);
ao->command = AO_COMMAND_NONE;
diff --git a/src/output_internal.h b/src/output_internal.h
index b71508ff7..0cdbbdc2c 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -23,7 +23,6 @@
#include "pcm_utils.h"
#include "notify.h"
-#include <pthread.h>
#include <time.h>
struct audio_output {
@@ -84,10 +83,10 @@ struct audio_output {
size_t convBufferLen;
/**
- * The thread handle, or "0" if the output thread isn't
+ * The thread handle, or NULL if the output thread isn't
* running.
*/
- pthread_t thread;
+ GThread *thread;
/**
* Notify object for the thread.
diff --git a/src/output_thread.c b/src/output_thread.c
index c887828bb..316c4a719 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -106,7 +106,7 @@ static void ao_pause(struct audio_output *ao)
}
}
-static void *audio_output_task(void *arg)
+static gpointer audio_output_task(gpointer arg)
{
struct audio_output *ao = arg;
bool ret;
@@ -167,12 +167,10 @@ static void *audio_output_task(void *arg)
void audio_output_thread_start(struct audio_output *ao)
{
- pthread_attr_t attr;
+ GError *e;
assert(ao->command == AO_COMMAND_NONE);
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&ao->thread, &attr, audio_output_task, ao))
- g_error("Failed to spawn output task: %s\n", strerror(errno));
+ if (!(ao->thread = g_thread_create(audio_output_task, ao, FALSE, &e)))
+ g_error("Failed to spawn output task: %s\n", e->message);
}