core: Fix some FIXMEs for the extended API

This adds some checks that I'd postponed and adds a
"should-be-good-enough" guess for tlength when using a compressed
format.
This commit is contained in:
Arun Raghavan 2011-03-02 12:54:02 +05:30
parent 658a9153f0
commit e11770b64f
2 changed files with 26 additions and 10 deletions

View file

@ -151,8 +151,16 @@ static pa_stream *pa_stream_new_with_proplist_internal(
s->buffer_attr.maxlength = (uint32_t) -1;
if (ss)
s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
else
/* XXX: How do we apply worst case conversion here? */
else {
/* FIXME: We assume a worst-case compressed format corresponding to
* 48000 Hz, 2 ch, S16 PCM, but this can very well be incorrect */
pa_sample_spec tmp_ss = {
.format = PA_SAMPLE_S16NE,
.rate = 48000,
.channels = 2,
};
s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, &tmp_ss); /* 250ms of buffering */
}
s->buffer_attr.minreq = (uint32_t) -1;
s->buffer_attr.prebuf = (uint32_t) -1;
s->buffer_attr.fragsize = (uint32_t) -1;
@ -224,8 +232,6 @@ pa_stream *pa_stream_new_extended(
PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 21, PA_ERR_NOTSUPPORTED);
/* XXX: For the single-format PCM case, pass ss/map instead of formats */
return pa_stream_new_with_proplist_internal(c, name, NULL, NULL, formats, p);
}
@ -1029,7 +1035,6 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag,
(!(s->flags & PA_STREAM_FIX_FORMAT) && ss.format != s->sample_spec.format) ||
(!(s->flags & PA_STREAM_FIX_RATE) && ss.rate != s->sample_spec.rate) ||
(!(s->flags & PA_STREAM_FIX_CHANNELS) && !pa_channel_map_equal(&cm, &s->channel_map))))) {
/* XXX: checks for the n_formats > 0 case? */
pa_context_fail(s->context, PA_ERR_PROTOCOL);
goto finish;
}
@ -1062,8 +1067,14 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag,
if (pa_format_info_valid(f))
s->format = f;
else
else {
pa_format_info_free(f);
if (s->n_formats > 0) {
/* We used the extended API, so we should have got back a proper format */
pa_context_fail(s->context, PA_ERR_PROTOCOL);
goto finish;
}
}
}
if (!pa_tagstruct_eof(t)) {

View file

@ -2008,10 +2008,15 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
}
}
CHECK_VALIDITY(c->pstream, n_formats > 0 || pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, n_formats > 0 || (map.channels == ss.channels && volume.channels == ss.channels), tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, n_formats > 0 || pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
/* XXX: add checks on formats. At least inverse checks of the 3 above */
if (n_formats == 0) {
CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, map.channels == ss.channels && volume.channels == ss.channels, tag, PA_ERR_INVALID);
CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
} else {
PA_IDXSET_FOREACH(format, formats, i) {
CHECK_VALIDITY(c->pstream, pa_format_info_valid(format), tag, PA_ERR_INVALID);
}
}
if (!pa_tagstruct_eof(t)) {
protocol_error(c);