merge 'lennart' branch back into trunk.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-10-28 19:13:50 +00:00
parent 6687dd0131
commit a67c21f093
294 changed files with 79057 additions and 11614 deletions

View file

@ -26,7 +26,6 @@
#include <config.h>
#endif
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
@ -38,6 +37,7 @@
#include <pulsecore/pstream-util.h>
#include <pulsecore/log.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/macro.h>
#include "internal.h"
@ -47,13 +47,14 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
pa_stream *s;
int i;
assert(c);
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);
s = pa_xnew(pa_stream, 1);
s->ref = 1;
PA_REFCNT_INIT(s);
s->context = c;
s->mainloop = c->mainloop;
@ -91,6 +92,7 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
s->peek_memchunk.index = 0;
s->peek_memchunk.length = 0;
s->peek_memchunk.memblock = NULL;
s->peek_data = NULL;
s->record_memblockq = NULL;
@ -118,15 +120,20 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
}
static void stream_free(pa_stream *s) {
assert(s && !s->context && !s->channel_valid);
pa_assert(s);
pa_assert(!s->context);
pa_assert(!s->channel_valid);
if (s->auto_timing_update_event) {
assert(s->mainloop);
pa_assert(s->mainloop);
s->mainloop->time_free(s->auto_timing_update_event);
}
if (s->peek_memchunk.memblock)
if (s->peek_memchunk.memblock) {
if (s->peek_data)
pa_memblock_release(s->peek_memchunk.memblock);
pa_memblock_unref(s->peek_memchunk.memblock);
}
if (s->record_memblockq)
pa_memblockq_free(s->record_memblockq);
@ -136,38 +143,38 @@ static void stream_free(pa_stream *s) {
}
void pa_stream_unref(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
if (--(s->ref) == 0)
if (PA_REFCNT_DEC(s) <= 0)
stream_free(s);
}
pa_stream* pa_stream_ref(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->ref++;
PA_REFCNT_INC(s);
return s;
}
pa_stream_state_t pa_stream_get_state(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return s->state;
}
pa_context* pa_stream_get_context(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return s->context;
}
uint32_t pa_stream_get_index(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX);
@ -175,8 +182,8 @@ uint32_t pa_stream_get_index(pa_stream *s) {
}
void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
if (s->state == st)
return;
@ -214,6 +221,13 @@ void pa_stream_set_state(pa_stream *s, pa_stream_state_t st) {
s->channel_valid = 0;
s->context = NULL;
s->read_callback = NULL;
s->write_callback = NULL;
s->state_callback = NULL;
s->overflow_callback = NULL;
s->underflow_callback = NULL;
s->latency_update_callback = NULL;
}
pa_stream_unref(s);
@ -224,10 +238,11 @@ void pa_command_stream_killed(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
pa_stream *s;
uint32_t channel;
assert(pd);
assert(command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED);
assert(t);
assert(c);
pa_assert(pd);
pa_assert(command == PA_COMMAND_PLAYBACK_STREAM_KILLED || command == PA_COMMAND_RECORD_STREAM_KILLED);
pa_assert(t);
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
pa_context_ref(c);
@ -252,10 +267,11 @@ void pa_command_request(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32
pa_context *c = userdata;
uint32_t bytes, channel;
assert(pd);
assert(command == PA_COMMAND_REQUEST);
assert(t);
assert(c);
pa_assert(pd);
pa_assert(command == PA_COMMAND_REQUEST);
pa_assert(t);
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
pa_context_ref(c);
@ -285,10 +301,11 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, PA_GCC
pa_context *c = userdata;
uint32_t channel;
assert(pd);
assert(command == PA_COMMAND_OVERFLOW || command == PA_COMMAND_UNDERFLOW);
assert(t);
assert(c);
pa_assert(pd);
pa_assert(command == PA_COMMAND_OVERFLOW || command == PA_COMMAND_UNDERFLOW);
pa_assert(t);
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);
pa_context_ref(c);
@ -317,8 +334,8 @@ void pa_command_overflow_or_underflow(pa_pdispatch *pd, uint32_t command, PA_GCC
}
static void request_auto_timing_update(pa_stream *s, int force) {
struct timeval next;
assert(s);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
if (!(s->flags & PA_STREAM_AUTO_TIMING_UPDATE))
return;
@ -335,13 +352,17 @@ static void request_auto_timing_update(pa_stream *s, int force) {
}
}
pa_gettimeofday(&next);
pa_timeval_add(&next, LATENCY_IPOL_INTERVAL_USEC);
s->mainloop->time_restart(s->auto_timing_update_event, &next);
if (s->auto_timing_update_event) {
struct timeval next;
pa_gettimeofday(&next);
pa_timeval_add(&next, LATENCY_IPOL_INTERVAL_USEC);
s->mainloop->time_restart(s->auto_timing_update_event, &next);
}
}
static void invalidate_indexes(pa_stream *s, int r, int w) {
assert(s);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
/* pa_log("invalidate r:%u w:%u tag:%u", r, w, s->context->ctag); */
@ -376,6 +397,9 @@ static void invalidate_indexes(pa_stream *s, int r, int w) {
static void auto_timing_update_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC_UNUSED pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
pa_stream *s = userdata;
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
/* pa_log("time event"); */
pa_stream_ref(s);
@ -383,12 +407,32 @@ static void auto_timing_update_callback(PA_GCC_UNUSED pa_mainloop_api *m, PA_GCC
pa_stream_unref(s);
}
static void create_stream_complete(pa_stream *s) {
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(s->state == PA_STREAM_CREATING);
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);
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
struct timeval tv;
pa_gettimeofday(&tv);
tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
pa_assert(!s->auto_timing_update_event);
s->auto_timing_update_event = s->mainloop->time_new(s->mainloop, &tv, &auto_timing_update_callback, s);
}
}
void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_stream *s = userdata;
assert(pd);
assert(s);
assert(s->state == PA_STREAM_CREATING);
pa_assert(pd);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(s->state == PA_STREAM_CREATING);
pa_stream_ref(s);
@ -431,7 +475,7 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
}
if (s->direction == PA_STREAM_RECORD) {
assert(!s->record_memblockq);
pa_assert(!s->record_memblockq);
s->record_memblockq = pa_memblockq_new(
0,
@ -446,23 +490,16 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
s->channel_valid = 1;
pa_dynarray_put((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, s->channel, s);
pa_stream_set_state(s, PA_STREAM_READY);
if (s->direction != PA_STREAM_UPLOAD &&
s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
struct timeval tv;
pa_gettimeofday(&tv);
tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
assert(!s->auto_timing_update_event);
s->auto_timing_update_event = s->mainloop->time_new(s->mainloop, &tv, &auto_timing_update_callback, s);
if (s->direction != PA_STREAM_UPLOAD && s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
/* If automatic timing updates are active, we wait for the
* first timing update before going to PA_STREAM_READY
* state */
s->state = PA_STREAM_READY;
request_auto_timing_update(s, 1);
}
s->state = PA_STREAM_CREATING;
if (s->requested_bytes > 0 && s->ref > 1 && s->write_callback)
s->write_callback(s, s->requested_bytes, s->write_userdata);
} else
create_stream_complete(s);
finish:
pa_stream_unref(s);
@ -480,8 +517,8 @@ static int create_stream(
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, !(flags & ~((direction != PA_STREAM_UPLOAD ?
@ -503,12 +540,12 @@ static int create_stream(
if (attr)
s->buffer_attr = *attr;
else {
/* half a second */
/* half a second, with minimum request of 10 ms */
s->buffer_attr.tlength = pa_bytes_per_second(&s->sample_spec)/2;
s->buffer_attr.maxlength = (s->buffer_attr.tlength*3)/2;
s->buffer_attr.minreq = s->buffer_attr.tlength/100;
s->buffer_attr.minreq = s->buffer_attr.tlength/50;
s->buffer_attr.prebuf = s->buffer_attr.tlength - s->buffer_attr.minreq;
s->buffer_attr.fragsize = s->buffer_attr.tlength/100;
s->buffer_attr.fragsize = s->buffer_attr.tlength/50;
}
if (!dev)
@ -565,8 +602,8 @@ int pa_stream_connect_playback(
pa_cvolume *volume,
pa_stream *sync_stream) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return create_stream(PA_STREAM_PLAYBACK, s, dev, attr, flags, volume, sync_stream);
}
@ -577,8 +614,8 @@ int pa_stream_connect_record(
const pa_buffer_attr *attr,
pa_stream_flags_t flags) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return create_stream(PA_STREAM_RECORD, s, dev, attr, flags, NULL, NULL);
}
@ -593,9 +630,9 @@ int pa_stream_write(
pa_memchunk chunk;
assert(s);
assert(s->ref >= 1);
assert(data);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(data);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_PLAYBACK || s->direction == PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -608,8 +645,11 @@ int pa_stream_write(
if (free_cb)
chunk.memblock = pa_memblock_new_user(s->context->mempool, (void*) data, length, free_cb, 1);
else {
void *tdata;
chunk.memblock = pa_memblock_new(s->context->mempool, length);
memcpy(chunk.memblock->data, data, length);
tdata = pa_memblock_acquire(chunk.memblock);
memcpy(tdata, data, length);
pa_memblock_release(chunk.memblock);
}
chunk.index = 0;
@ -660,10 +700,10 @@ int pa_stream_write(
}
int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
assert(s);
assert(s->ref >= 1);
assert(data);
assert(length);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(data);
pa_assert(length);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
@ -675,27 +715,32 @@ int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
*length = 0;
return 0;
}
s->peek_data = pa_memblock_acquire(s->peek_memchunk.memblock);
}
*data = (const char*) s->peek_memchunk.memblock->data + s->peek_memchunk.index;
pa_assert(s->peek_data);
*data = (uint8_t*) s->peek_data + s->peek_memchunk.index;
*length = s->peek_memchunk.length;
return 0;
}
int pa_stream_drop(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->peek_memchunk.memblock, PA_ERR_BADSTATE);
pa_memblockq_drop(s->record_memblockq, &s->peek_memchunk, s->peek_memchunk.length);
pa_memblockq_drop(s->record_memblockq, s->peek_memchunk.length);
/* Fix the simulated local read index */
if (s->timing_info_valid && !s->timing_info.read_index_corrupt)
s->timing_info.read_index += s->peek_memchunk.length;
pa_assert(s->peek_data);
pa_memblock_release(s->peek_memchunk.memblock);
pa_memblock_unref(s->peek_memchunk.memblock);
s->peek_memchunk.length = 0;
s->peek_memchunk.index = 0;
@ -705,8 +750,8 @@ int pa_stream_drop(pa_stream *s) {
}
size_t pa_stream_writable_size(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
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);
@ -715,8 +760,8 @@ size_t pa_stream_writable_size(pa_stream *s) {
}
size_t pa_stream_readable_size(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
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);
@ -729,8 +774,8 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
@ -750,8 +795,9 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
struct timeval local, remote, now;
pa_timing_info *i;
assert(pd);
assert(o);
pa_assert(pd);
pa_assert(o);
pa_assert(PA_REFCNT_VALUE(o) >= 1);
if (!o->context || !o->stream)
goto finish;
@ -874,6 +920,10 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
}
}
/* First, let's complete the initialization, if necessary. */
if (o->stream->state == PA_STREAM_CREATING)
create_stream_complete(o->stream);
if (o->stream->latency_update_callback)
o->stream->latency_update_callback(o->stream, o->stream->latency_update_userdata);
@ -895,8 +945,8 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
struct timeval now;
int cidx = 0;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -938,9 +988,9 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
void pa_stream_disconnect_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_stream *s = userdata;
assert(pd);
assert(s);
assert(s->ref >= 1);
pa_assert(pd);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_stream_ref(s);
@ -965,8 +1015,8 @@ int pa_stream_disconnect(pa_stream *s) {
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
@ -987,48 +1037,48 @@ int pa_stream_disconnect(pa_stream *s) {
}
void pa_stream_set_read_callback(pa_stream *s, pa_stream_request_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->read_callback = cb;
s->read_userdata = userdata;
}
void pa_stream_set_write_callback(pa_stream *s, pa_stream_request_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->write_callback = cb;
s->write_userdata = userdata;
}
void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->state_callback = cb;
s->state_userdata = userdata;
}
void pa_stream_set_overflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->overflow_callback = cb;
s->overflow_userdata = userdata;
}
void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->underflow_callback = cb;
s->underflow_userdata = userdata;
}
void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
s->latency_update_callback = cb;
s->latency_update_userdata = userdata;
@ -1038,9 +1088,9 @@ void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UN
pa_operation *o = userdata;
int success = 1;
assert(pd);
assert(o);
assert(o->ref >= 1);
pa_assert(pd);
pa_assert(o);
pa_assert(PA_REFCNT_VALUE(o) >= 1);
if (!o->context)
goto finish;
@ -1070,8 +1120,8 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -1100,8 +1150,8 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
pa_operation *o;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
@ -1118,6 +1168,9 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command,
pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
pa_operation *o;
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
if ((o = stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata))) {
@ -1143,6 +1196,9 @@ pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *use
pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
pa_operation *o;
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
@ -1155,6 +1211,9 @@ pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *us
pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata) {
pa_operation *o;
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
@ -1169,9 +1228,9 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
pa_tagstruct *t;
uint32_t tag;
assert(s);
assert(s->ref >= 1);
assert(name);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(name);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -1193,8 +1252,8 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
pa_usec_t usec = 0;
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -1277,8 +1336,8 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) {
}
static pa_usec_t time_counter_diff(pa_stream *s, pa_usec_t a, pa_usec_t b, int *negative) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
if (negative)
*negative = 0;
@ -1299,9 +1358,9 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
int r;
int64_t cindex;
assert(s);
assert(s->ref >= 1);
assert(r_usec);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
pa_assert(r_usec);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -1331,8 +1390,8 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
}
const pa_timing_info* pa_stream_get_timing_info(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
@ -1342,22 +1401,22 @@ const pa_timing_info* pa_stream_get_timing_info(pa_stream *s) {
}
const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return &s->sample_spec;
}
const pa_channel_map* pa_stream_get_channel_map(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
return &s->channel_map;
}
const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s) {
assert(s);
assert(s->ref >= 1);
pa_assert(s);
pa_assert(PA_REFCNT_VALUE(s) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);