示例#1
0
static void
WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o)
{
    /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
    if (mainloop && o) {
        SDL_bool okay = SDL_TRUE;
        while (okay && (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING)) {
            okay = (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) >= 0);
        }
        PULSEAUDIO_pa_operation_unref(o);
    }
}
static void
PULSEAUDIO_WaitDone(_THIS)
{
    if (this->enabled) {
        struct SDL_PrivateAudioData *h = this->hidden;
        pa_operation *o = PULSEAUDIO_pa_stream_drain(h->stream, stream_drain_complete, NULL);
        if (o) {
            while (PULSEAUDIO_pa_operation_get_state(o) != PA_OPERATION_DONE) {
                if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY ||
                    PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY ||
                    PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) {
                    PULSEAUDIO_pa_operation_cancel(o);
                    break;
                }
            }
            PULSEAUDIO_pa_operation_unref(o);
        }
    }
}