Commit a4512d3b authored by Max Kellermann's avatar Max Kellermann

osx: use GLib instead of utils.h/log.h

One my_usleep() invocation remains, until we find out if we can delete it.
parent b0f46c20
...@@ -18,10 +18,14 @@ ...@@ -18,10 +18,14 @@
#include "../output_api.h" #include "../output_api.h"
#include "../utils.h" #include "../utils.h"
#include "../log.h"
#include <glib.h>
#include <pthread.h>
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "osx"
typedef struct _OsxData { typedef struct _OsxData {
AudioUnit au; AudioUnit au;
pthread_mutex_t mutex; pthread_mutex_t mutex;
...@@ -35,7 +39,7 @@ typedef struct _OsxData { ...@@ -35,7 +39,7 @@ typedef struct _OsxData {
static OsxData *newOsxData(void) static OsxData *newOsxData(void)
{ {
OsxData *ret = xmalloc(sizeof(OsxData)); OsxData *ret = g_new(OsxData, 1);
pthread_mutex_init(&ret->mutex, NULL); pthread_mutex_init(&ret->mutex, NULL);
pthread_cond_init(&ret->condition, NULL); pthread_cond_init(&ret->condition, NULL);
...@@ -227,18 +231,18 @@ osx_openDevice(void *data, struct audio_format *audioFormat) ...@@ -227,18 +231,18 @@ osx_openDevice(void *data, struct audio_format *audioFormat)
comp = FindNextComponent(NULL, &desc); comp = FindNextComponent(NULL, &desc);
if (comp == 0) { if (comp == 0) {
ERROR("Error finding OS X component\n"); g_warning("Error finding OS X component\n");
return false; return false;
} }
if (OpenAComponent(comp, &od->au) != noErr) { if (OpenAComponent(comp, &od->au) != noErr) {
ERROR("Unable to open OS X component\n"); g_warning("Unable to open OS X component\n");
return false; return false;
} }
if (AudioUnitInitialize(od->au) != 0) { if (AudioUnitInitialize(od->au) != 0) {
CloseComponent(od->au); CloseComponent(od->au);
ERROR("Unable to initialize OS X audio unit\n"); g_warning("Unable to initialize OS X audio unit\n");
return false; return false;
} }
...@@ -250,7 +254,7 @@ osx_openDevice(void *data, struct audio_format *audioFormat) ...@@ -250,7 +254,7 @@ osx_openDevice(void *data, struct audio_format *audioFormat)
&callback, sizeof(callback)) != 0) { &callback, sizeof(callback)) != 0) {
AudioUnitUninitialize(od->au); AudioUnitUninitialize(od->au);
CloseComponent(od->au); CloseComponent(od->au);
ERROR("unable to set callback for OS X audio unit\n"); g_warning("unable to set callback for OS X audio unit\n");
return false; return false;
} }
...@@ -272,14 +276,14 @@ osx_openDevice(void *data, struct audio_format *audioFormat) ...@@ -272,14 +276,14 @@ osx_openDevice(void *data, struct audio_format *audioFormat)
&streamDesc, sizeof(streamDesc)) != 0) { &streamDesc, sizeof(streamDesc)) != 0) {
AudioUnitUninitialize(od->au); AudioUnitUninitialize(od->au);
CloseComponent(od->au); CloseComponent(od->au);
ERROR("Unable to set format on OS X device\n"); g_warning("Unable to set format on OS X device\n");
return false; return false;
} }
/* create a buffer of 1s */ /* create a buffer of 1s */
od->bufferSize = (audioFormat->sample_rate) * od->bufferSize = (audioFormat->sample_rate) *
audio_format_frame_size(audioFormat); audio_format_frame_size(audioFormat);
od->buffer = xrealloc(od->buffer, od->bufferSize); od->buffer = g_realloc(od->buffer, od->bufferSize);
od->pos = 0; od->pos = 0;
od->len = 0; od->len = 0;
...@@ -301,7 +305,7 @@ osx_play(void *data, const char *playChunk, size_t size) ...@@ -301,7 +305,7 @@ osx_play(void *data, const char *playChunk, size_t size)
od->started = 1; od->started = 1;
err = AudioOutputUnitStart(od->au); err = AudioOutputUnitStart(od->au);
if (err) { if (err) {
ERROR("unable to start audio output: %i\n", err); g_warning("unable to start audio output: %i\n", err);
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment