Beispiel #1
0
/* this runs as a thread while the Pulse target is initialized to catch hotplug events. */
static int SDLCALL
HotplugThread(void *data)
{
    pa_operation *o;
    SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
    PULSEAUDIO_pa_context_set_subscribe_callback(hotplug_context, HotplugCallback, NULL);
    o = PULSEAUDIO_pa_context_subscribe(hotplug_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL);
    PULSEAUDIO_pa_operation_unref(o);  /* don't wait for it, just do our thing. */
    PULSEAUDIO_pa_mainloop_run(hotplug_mainloop, NULL);
    return 0;
}
Beispiel #2
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);
        }
    }
}