aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/output/openal_output_plugin.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/output/openal_output_plugin.c b/src/output/openal_output_plugin.c
index d8dc90ed5..ebd35ef12 100644
--- a/src/output/openal_output_plugin.c
+++ b/src/output/openal_output_plugin.c
@@ -20,7 +20,6 @@
#include "config.h"
#include "openal_output_plugin.h"
#include "output_api.h"
-#include "timer.h"
#include <glib.h>
@@ -44,7 +43,6 @@ struct openal_data {
const char *device_name;
ALCdevice *device;
ALCcontext *context;
- struct timer *timer;
ALuint buffers[NUM_BUFFERS];
unsigned filled;
ALuint source;
@@ -193,7 +191,6 @@ openal_open(struct audio_output *ao, struct audio_format *audio_format,
}
od->filled = 0;
- od->timer = timer_new(audio_format);
od->frequency = audio_format->sample_rate;
return true;
@@ -204,7 +201,6 @@ openal_close(struct audio_output *ao)
{
struct openal_data *od = (struct openal_data *)ao;
- timer_free(od->timer);
alcMakeContextCurrent(od->context);
alDeleteSources(1, &od->source);
alDeleteBuffers(NUM_BUFFERS, od->buffers);
@@ -212,6 +208,19 @@ openal_close(struct audio_output *ao)
alcCloseDevice(od->device);
}
+static unsigned
+openal_delay(struct audio_output *ao)
+{
+ struct openal_data *od = (struct openal_data *)ao;
+
+ return od->filled < NUM_BUFFERS || openal_has_processed(od)
+ ? 0
+ /* we don't know exactly how long we must wait for the
+ next buffer to finish, so this is a random
+ guess: */
+ : 50;
+}
+
static size_t
openal_play(struct audio_output *ao, const void *chunk, size_t size,
G_GNUC_UNUSED GError **error)
@@ -229,15 +238,8 @@ openal_play(struct audio_output *ao, const void *chunk, size_t size,
od->filled++;
} else {
/* wait for processed buffer */
- while (!openal_has_processed(od)) {
- if (!od->timer->started) {
- timer_start(od->timer);
- } else {
- timer_sync(od->timer);
- }
-
- timer_add(od->timer, size);
- }
+ while (!openal_has_processed(od))
+ g_usleep(10);
alSourceUnqueueBuffers(od->source, 1, &buffer);
}
@@ -271,6 +273,7 @@ const struct audio_output_plugin openal_output_plugin = {
.finish = openal_finish,
.open = openal_open,
.close = openal_close,
+ .delay = openal_delay,
.play = openal_play,
.cancel = openal_cancel,
};