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

int pa_simple_write ( pa_simple s,
const void *  data,
size_t  bytes,
int *  error 
)

Write some data to the server

Definition at line 253 of file simple.c.

References pa_simple::direction, pa_simple::mainloop, PA_ERR_BADSTATE, PA_ERR_INVALID, PA_SEEK_RELATIVE, PA_STREAM_PLAYBACK, pa_stream_write(), and pa_simple::stream.

                                                                               {
    pa_assert(p);

    CHECK_VALIDITY_RETURN_ANY(rerror, p->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE, -1);
    CHECK_VALIDITY_RETURN_ANY(rerror, data && length, PA_ERR_INVALID, -1);

    pa_threaded_mainloop_lock(p->mainloop);

    CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);

    while (length > 0) {
        size_t l;
        int r;

        while (!(l = pa_stream_writable_size(p->stream))) {
            pa_threaded_mainloop_wait(p->mainloop);
            CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
        }

        CHECK_SUCCESS_GOTO(p, rerror, l != (size_t) -1, unlock_and_fail);

        if (l > length)
            l = length;

        r = pa_stream_write(p->stream, data, l, NULL, 0, PA_SEEK_RELATIVE);
        CHECK_SUCCESS_GOTO(p, rerror, r >= 0, unlock_and_fail);

        data = (const uint8_t*) data + l;
        length -= l;
    }

    pa_threaded_mainloop_unlock(p->mainloop);
    return 0;

unlock_and_fail:
    pa_threaded_mainloop_unlock(p->mainloop);
    return -1;
}


Generated by  Doxygen 1.6.0   Back to index