summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-05-09 15:02:49 +0000
committerLennart Poettering <lennart@poettering.net>2006-05-09 15:02:49 +0000
commitc217175adeb0e0f20b7259fea2f414316a6abef6 (patch)
tree40f67b7f7cb144f998400c445fa6ebee42e050f7
parenteff37b9e21e47b8a16a5fc4477589b21508720e4 (diff)
always write full data block to polypaudio
git-svn-id: file:///home/lennart/svn/public/gst-pulse/trunk@16 bb39ca4e-bce3-0310-b5d4-eea78a553289
-rw-r--r--src/polypsink.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/polypsink.c b/src/polypsink.c
index d9e7b5f..8859edb 100644
--- a/src/polypsink.c
+++ b/src/polypsink.c
@@ -31,7 +31,6 @@
#include "polypsink.h"
-
GST_DEBUG_CATEGORY_EXTERN(polyp_debug);
#define GST_CAT_DEFAULT polyp_debug
@@ -408,7 +407,7 @@ static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *sp
buf_attr.prebuf = buf_attr.minreq = spec->segsize;
if (pa_stream_connect_playback(polypsink->stream, polypsink->device, &buf_attr, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_NOT_MONOTONOUS, NULL, NULL) < 0) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connext stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
goto unlock_and_fail;
}
@@ -416,7 +415,7 @@ static gboolean gst_polypsink_prepare(GstAudioSink *asink, GstRingBufferSpec *sp
pa_threaded_mainloop_wait(polypsink->mainloop);
if (pa_stream_get_state(polypsink->stream) != PA_STREAM_READY) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connext stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("Failed to connect stream: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
goto unlock_and_fail;
}
@@ -452,35 +451,45 @@ if (!(polypsink)->context || pa_context_get_state((polypsink)->context) != PA_CO
static guint gst_polypsink_write(GstAudioSink *asink, gpointer data, guint length) {
GstPolypSink *polypsink = GST_POLYPSINK(asink);
- size_t l;
-
+ size_t sum = 0;
+
pa_threaded_mainloop_lock(polypsink->mainloop);
- for (;;) {
- CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+ while (length > 0) {
+ size_t l;
+
+ for (;;) {
+ CHECK_DEAD_GOTO(polypsink, unlock_and_fail);
+
+ if ((l = pa_stream_writable_size(polypsink->stream)) == (size_t) -1) {
+ GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_writable_size() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ goto unlock_and_fail;
+ }
- if ((l = pa_stream_writable_size(polypsink->stream)))
- break;
-
- pa_threaded_mainloop_wait(polypsink->mainloop);
- }
+ if (l > 0)
+ break;
+
+ pa_threaded_mainloop_wait(polypsink->mainloop);
+ }
- if (l == (size_t) -1) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_writable_size() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
- goto unlock_and_fail;
- }
+ if (l > length)
+ l = length;
+
+ if (pa_stream_write(polypsink->stream, data, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
+ GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_write() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
+ goto unlock_and_fail;
+ }
- if (l > length)
- l = length;
+ data = (guint8*) data + l;
+ length -= l;
- if (pa_stream_write(polypsink->stream, data, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
- GST_ELEMENT_ERROR(polypsink, RESOURCE, FAILED, ("pa_stream_write() failed: %s", pa_strerror(pa_context_errno(polypsink->context))), (NULL));
- goto unlock_and_fail;
+ sum += l;
}
-
+
pa_threaded_mainloop_unlock(polypsink->mainloop);
- return l;
+ return sum;
+
unlock_and_fail:
pa_threaded_mainloop_unlock(polypsink->mainloop);