Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

pa_operation* pa_stream_set_buffer_attr ( pa_stream s,
const pa_buffer_attr attr,
pa_stream_success_cb_t  cb,
void *  userdata 
)

Change the buffer metrics of the stream during playback. The server might have chosen different buffer metrics then requested. The selected metrics may be queried with pa_stream_get_buffer_attr() as soon as the callback is called. Only valid after the stream has been connected successfully and if the server is at least PulseAudio 0.9.8. Please be aware of the slightly different semantics of the call depending whether PA_STREAM_ADJUST_LATENCY is set or not.

Since:
0.9.8

Definition at line 2436 of file stream.c.

References pa_buffer_attr::fragsize, pa_buffer_attr::maxlength, pa_buffer_attr::minreq, PA_ERR_BADSTATE, PA_ERR_FORKED, PA_ERR_NOTSUPPORTED, PA_STREAM_ADJUST_LATENCY, PA_STREAM_EARLY_REQUESTS, PA_STREAM_PLAYBACK, PA_STREAM_READY, PA_STREAM_RECORD, PA_STREAM_UPLOAD, pa_buffer_attr::prebuf, and pa_buffer_attr::tlength.

                                                                                                                             {
    pa_operation *o;
    pa_tagstruct *t;
    uint32_t tag;
    pa_buffer_attr copy;

    pa_assert(s);
    pa_assert(PA_REFCNT_VALUE(s) >= 1);
    pa_assert(attr);

    PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED);
    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->context->version >= 12, PA_ERR_NOTSUPPORTED);

    /* Ask for a timing update before we cork/uncork to get the best
     * accuracy for the transport latency suitable for the
     * check_smoother_status() call in the started callback */
    request_auto_timing_update(s, TRUE);

    o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);

    t = pa_tagstruct_command(
            s->context,
            (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR : PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR),
            &tag);
    pa_tagstruct_putu32(t, s->channel);

    copy = *attr;
    patch_buffer_attr(s, &copy, NULL);
    attr = ©

    pa_tagstruct_putu32(t, attr->maxlength);

    if (s->direction == PA_STREAM_PLAYBACK)
        pa_tagstruct_put(
                t,
                PA_TAG_U32, attr->tlength,
                PA_TAG_U32, attr->prebuf,
                PA_TAG_U32, attr->minreq,
                PA_TAG_INVALID);
    else
        pa_tagstruct_putu32(t, attr->fragsize);

    if (s->context->version >= 13)
        pa_tagstruct_put_boolean(t, !!(s->flags & PA_STREAM_ADJUST_LATENCY));

    if (s->context->version >= 14)
        pa_tagstruct_put_boolean(t, !!(s->flags & PA_STREAM_EARLY_REQUESTS));

    pa_pstream_send_tagstruct(s->context->pstream, t);
    pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_set_buffer_attr_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);

    /* This might cause changes in the read/write indexex, hence let's
     * request a timing update */
    request_auto_timing_update(s, TRUE);

    return o;
}


Generated by  Doxygen 1.6.0   Back to index