summaryrefslogtreecommitdiffstats
path: root/src/polyp
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-05-25 23:20:28 +0000
committerLennart Poettering <lennart@poettering.net>2006-05-25 23:20:28 +0000
commit7d975345a555fc20e5019307c7dc01545552e42d (patch)
tree738c6340193a144b5b6d96915210fa355b851d1f /src/polyp
parentb754d5095e8c1bbf41e7c0147dfb2328145a2c83 (diff)
* add new API function pa_stream_get_buffer_attr().
* modify pacat.c to make use of that new API * extend protocol to allow transfer of the necessary information * update protocol version accordingly git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@976 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polyp')
-rw-r--r--src/polyp/internal.h1
-rw-r--r--src/polyp/stream.c47
-rw-r--r--src/polyp/stream.h5
3 files changed, 51 insertions, 2 deletions
diff --git a/src/polyp/internal.h b/src/polyp/internal.h
index 80c28616..d88a1e5b 100644
--- a/src/polyp/internal.h
+++ b/src/polyp/internal.h
@@ -100,6 +100,7 @@ struct pa_stream {
char *name;
pa_buffer_attr buffer_attr;
+ int buffer_attr_from_server;
pa_sample_spec sample_spec;
pa_channel_map channel_map;
pa_stream_flags_t flags;
diff --git a/src/polyp/stream.c b/src/polyp/stream.c
index e41c588e..17884ed3 100644
--- a/src/polyp/stream.c
+++ b/src/polyp/stream.c
@@ -84,6 +84,7 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *
s->requested_bytes = 0;
s->state = PA_STREAM_UNCONNECTED;
memset(&s->buffer_attr, 0, sizeof(s->buffer_attr));
+ s->buffer_attr_from_server = 0;
s->peek_memchunk.index = 0;
s->peek_memchunk.length = 0;
@@ -401,12 +402,43 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
if (pa_tagstruct_getu32(t, &s->channel) < 0 ||
((s->direction != PA_STREAM_UPLOAD) && pa_tagstruct_getu32(t, &s->device_index) < 0) ||
- ((s->direction != PA_STREAM_RECORD) && pa_tagstruct_getu32(t, &s->requested_bytes) < 0) ||
- !pa_tagstruct_eof(t)) {
+ ((s->direction != PA_STREAM_RECORD) && pa_tagstruct_getu32(t, &s->requested_bytes) < 0)) {
pa_context_fail(s->context, PA_ERR_PROTOCOL);
goto finish;
}
+ if (!pa_tagstruct_eof(t)) {
+
+ if (s->direction == PA_STREAM_PLAYBACK) {
+
+ /* This is a server 0.9.0 or later */
+ if (pa_tagstruct_getu32(t, &s->buffer_attr.maxlength) < 0 ||
+ pa_tagstruct_getu32(t, &s->buffer_attr.tlength) < 0 ||
+ pa_tagstruct_getu32(t, &s->buffer_attr.prebuf) < 0 ||
+ pa_tagstruct_getu32(t, &s->buffer_attr.minreq) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ pa_context_fail(s->context, PA_ERR_PROTOCOL);
+ goto finish;
+ }
+
+ s->buffer_attr_from_server = 1;
+ } else if (s->direction == PA_STREAM_RECORD) {
+
+ /* This is a server 0.9.0 or later */
+ if (pa_tagstruct_getu32(t, &s->buffer_attr.maxlength) < 0 ||
+ pa_tagstruct_getu32(t, &s->buffer_attr.fragsize) < 0 ||
+ !pa_tagstruct_eof(t)) {
+ pa_context_fail(s->context, PA_ERR_PROTOCOL);
+ goto finish;
+ }
+
+ s->buffer_attr_from_server = 1;
+ } else {
+ pa_context_fail(s->context, PA_ERR_PROTOCOL);
+ goto finish;
+ }
+ }
+
if (s->direction == PA_STREAM_RECORD) {
assert(!s->record_memblockq);
@@ -1336,3 +1368,14 @@ const pa_channel_map* pa_stream_get_channel_map(pa_stream *s) {
return &s->channel_map;
}
+
+const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s) {
+ assert(s);
+ assert(s->ref >= 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);
+ PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr_from_server, PA_ERR_NODATA);
+
+ return &s->buffer_attr;
+}
diff --git a/src/polyp/stream.h b/src/polyp/stream.h
index ad77d938..d1f558ae 100644
--- a/src/polyp/stream.h
+++ b/src/polyp/stream.h
@@ -439,6 +439,11 @@ const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s);
/** Return a pointer to the stream's channel map. \since 0.8 */
const pa_channel_map* pa_stream_get_channel_map(pa_stream *s);
+/** Return the buffer metrics of the stream. Only valid after the
+ * stream has been connected successfuly and if the server is at least
+ * Polypaudio 0.9. \since 0.9.0 */
+const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s);
+
PA_C_DECL_END
#endif