output: migrate from pthread to glib threads
This commit is contained in:
parent
28128dc4e3
commit
36b8968e36
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user