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

pa_operation* pa_stream_flush ( pa_stream s,
pa_stream_success_cb_t  cb,
void *  userdata 
)

Flush the playback buffer of this stream. This discards any audio in the buffer. Most of the time you're better off using the parameter delta of pa_stream_write() instead of this function. Available on both playback and recording streams.

Definition at line 2114 of file stream.c.

References PA_ERR_BADSTATE, PA_ERR_FORKED, PA_STREAM_PLAYBACK, PA_STREAM_READY, PA_STREAM_UPLOAD, and pa_buffer_attr::prebuf.

                                                                                       {
    pa_operation *o;

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

    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);

    /* Ask for a timing update *before* the flush, so that the
     * transport usec is as up to date as possible when we get the
     * underflow message and update the smoother status*/
    request_auto_timing_update(s, TRUE);

    if (!(o = stream_send_simple_command(s, (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM), cb, userdata)))
        return NULL;

    if (s->direction == PA_STREAM_PLAYBACK) {

        if (s->write_index_corrections[s->current_write_index_correction].valid)
            s->write_index_corrections[s->current_write_index_correction].corrupt = TRUE;

        if (s->buffer_attr.prebuf > 0)
            check_smoother_status(s, FALSE, FALSE, TRUE);

        /* This will change the write index, but leave the
         * read index untouched. */
        invalidate_indexes(s, FALSE, TRUE);

    } else
        /* For record streams this has no influence on the write
         * index, but the read index might jump. */
        invalidate_indexes(s, TRUE, FALSE);

    /* Note that we do not update requested_bytes here. This is
     * because we cannot really know how data actually was dropped
     * from the write index due to this. This 'error' will be applied
     * by both client and server and hence we should be fine. */

    return o;
}

Generated by  Doxygen 1.6.0   Back to index