Logo Search packages:      
Sourcecode: pulseaudio version File versions

pa_operation* pa_stream_update_sample_rate ( pa_stream s,
uint32_t  rate,
pa_stream_success_cb_t  cb,
void *  userdata 
)

Change the stream sampling rate during playback. You need to pass PA_STREAM_VARIABLE_RATE in the flags parameter of pa_stream_connect() if you plan to use this function. Only valid after the stream has been connected successfully and if the server is at least PulseAudio 0.9.8.

Since:
0.9.8

Definition at line 2192 of file stream.c.

References PA_ERR_BADSTATE, PA_ERR_INVALID, PA_ERR_NOTSUPPORTED, PA_RATE_MAX, PA_STREAM_READY, PA_STREAM_RECORD, PA_STREAM_UPLOAD, and PA_STREAM_VARIABLE_RATE.

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

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

    PA_CHECK_VALIDITY_RETURN_NULL(s->context, rate > 0 && rate <= PA_RATE_MAX, PA_ERR_INVALID);
    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->flags & PA_STREAM_VARIABLE_RATE, PA_ERR_BADSTATE);
    PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED);

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

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

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

    return o;
}


Generated by  Doxygen 1.6.0   Back to index