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.c50
3 files changed, 26 insertions, 30 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 14c8152e..344e6399 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..339a89e5 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -380,20 +380,13 @@ static void check_smoother_status(pa_stream *s, pa_bool_t aposteriori, pa_bool_t
x -= s->timing_info.transport_usec;
else
x += s->timing_info.transport_usec;
-
- if (s->direction == PA_STREAM_PLAYBACK)
- /* it takes a while until the pause/resume is actually
- * audible */
- x += s->timing_info.sink_usec;
- else
- /* Data froma while back will be dropped */
- x -= s->timing_info.source_usec;
}
if (s->suspended || s->corked || force_stop)
pa_smoother_pause(s->smoother, x);
else if (force_start || s->buffer_attr.prebuf == 0)
- pa_smoother_resume(s->smoother, x);
+ pa_smoother_resume(s->smoother, x, TRUE);
+
/* Please note that we have no idea if playback actually started
* if prebuf is non-zero! */
@@ -729,7 +722,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 +819,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 +867,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 +887,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 ||
@@ -1061,14 +1057,17 @@ static int create_stream(
if (flags & PA_STREAM_INTERPOLATE_TIMING) {
pa_usec_t x;
- if (s->smoother)
- pa_smoother_free(s->smoother);
-
- s->smoother = pa_smoother_new(SMOOTHER_ADJUST_TIME, SMOOTHER_HISTORY_TIME, !(flags & PA_STREAM_NOT_MONOTONIC), SMOOTHER_MIN_HISTORY);
-
x = pa_rtclock_usec();
- pa_smoother_set_time_offset(s->smoother, x);
- pa_smoother_pause(s->smoother, x);
+
+ pa_assert(!s->smoother);
+ s->smoother = pa_smoother_new(
+ SMOOTHER_ADJUST_TIME,
+ SMOOTHER_HISTORY_TIME,
+ !(flags & PA_STREAM_NOT_MONOTONIC),
+ TRUE,
+ SMOOTHER_MIN_HISTORY,
+ x,
+ TRUE);
}
if (!dev)
@@ -1258,12 +1257,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 +1355,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) {
@@ -1623,7 +1619,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
pa_smoother_put(o->stream->smoother, u, calc_time(o->stream, TRUE));
if (i->playing)
- pa_smoother_resume(o->stream->smoother, x);
+ pa_smoother_resume(o->stream->smoother, x, TRUE);
}
}