summaryrefslogtreecommitdiffstats
path: root/src/pulse
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse')
-rw-r--r--src/pulse/context.c4
-rw-r--r--src/pulse/internal.h2
-rw-r--r--src/pulse/stream.c20
3 files changed, 13 insertions, 13 deletions
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 28d17191..991a886f 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -364,10 +364,10 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
if ((s = pa_dynarray_get(c->record_streams, channel))) {
if (chunk->memblock) {
- pa_memblockq_seek(s->record_memblockq, offset, seek);
+ pa_memblockq_seek(s->record_memblockq, offset, seek, TRUE);
pa_memblockq_push_align(s->record_memblockq, chunk);
} else
- pa_memblockq_seek(s->record_memblockq, offset+chunk->length, seek);
+ pa_memblockq_seek(s->record_memblockq, offset+chunk->length, seek, TRUE);
if (s->read_callback) {
size_t l;
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index cf362d99..43d1877c 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -140,7 +140,7 @@ struct pa_stream {
uint32_t syncid;
uint32_t stream_index;
- uint32_t requested_bytes;
+ int64_t requested_bytes;
pa_buffer_attr buffer_attr;
uint32_t device_index;
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 16342cad..c4a54af6 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -729,7 +729,7 @@ void pa_command_request(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tag
s->requested_bytes += bytes;
if (s->requested_bytes > 0 && s->write_callback)
- s->write_callback(s, s->requested_bytes, s->write_userdata);
+ s->write_callback(s, (size_t) s->requested_bytes, s->write_userdata);
finish:
pa_context_unref(c);
@@ -826,7 +826,7 @@ static void create_stream_complete(pa_stream *s) {
pa_stream_set_state(s, PA_STREAM_READY);
if (s->requested_bytes > 0 && s->write_callback)
- s->write_callback(s, s->requested_bytes, s->write_userdata);
+ s->write_callback(s, (size_t) s->requested_bytes, s->write_userdata);
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
struct timeval tv;
@@ -874,6 +874,7 @@ static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_s
void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_stream *s = userdata;
+ uint32_t requested_bytes;
pa_assert(pd);
pa_assert(s);
@@ -893,11 +894,13 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag,
if (pa_tagstruct_getu32(t, &s->channel) < 0 ||
s->channel == PA_INVALID_INDEX ||
((s->direction != PA_STREAM_UPLOAD) && (pa_tagstruct_getu32(t, &s->stream_index) < 0 || s->stream_index == PA_INVALID_INDEX)) ||
- ((s->direction != PA_STREAM_RECORD) && pa_tagstruct_getu32(t, &s->requested_bytes) < 0)) {
+ ((s->direction != PA_STREAM_RECORD) && pa_tagstruct_getu32(t, &requested_bytes) < 0)) {
pa_context_fail(s->context, PA_ERR_PROTOCOL);
goto finish;
}
+ s->requested_bytes = (int64_t) requested_bytes;
+
if (s->context->version >= 9) {
if (s->direction == PA_STREAM_PLAYBACK) {
if (pa_tagstruct_getu32(t, &s->buffer_attr.maxlength) < 0 ||
@@ -1258,12 +1261,9 @@ int pa_stream_write(
if (free_cb && pa_pstream_get_shm(s->context->pstream))
free_cb((void*) data);
- if (length < s->requested_bytes)
- s->requested_bytes -= (uint32_t) length;
- else
- s->requested_bytes = 0;
-
- /* FIXME!!! ^^^ will break when offset is != 0 and mode is not RELATIVE*/
+ /* This is obviously wrong since we ignore the seeking index . But
+ * that's OK, the server side applies the same error */
+ s->requested_bytes -= (seek == PA_SEEK_RELATIVE ? offset : 0) + (int64_t) length;
if (s->direction == PA_STREAM_PLAYBACK) {
@@ -1359,7 +1359,7 @@ size_t pa_stream_writable_size(pa_stream *s) {
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1);
- return s->requested_bytes;
+ return s->requested_bytes > 0 ? (size_t) s->requested_bytes : 0;
}
size_t pa_stream_readable_size(pa_stream *s) {