VirtualBox

Changeset 6218 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Dec 28, 2007 11:12:29 PM (17 years ago)
Author:
vboxsync
Message:

pulse: hopefully fixed initialization once and for all

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/pulseaudio.c

    r6140 r6218  
    255255
    256256    /* Wait until the stream is ready */
    257     pa_threaded_mainloop_wait(g_pMainLoop);
    258 
    259     if (pa_stream_get_state(pStream) != PA_STREAM_READY)
    260     {
    261         LogRel(("Pulse: Wrong stream state %d\n", pa_stream_get_state(pStream)));
    262         goto disconnect_unlock_and_fail;
     257    for (;;)
     258    {
     259        pa_stream_state_t sstate;
     260        pa_threaded_mainloop_wait(g_pMainLoop);
     261        sstate = pa_stream_get_state(pStream);
     262        if (sstate == PA_STREAM_READY)
     263            break;
     264        else if (sstate == PA_STREAM_FAILED || sstate == PA_STREAM_TERMINATED)
     265        {
     266            LogRel(("Pulse: Failed to initialize stream (state %d)\n", sstate));
     267            goto disconnect_unlock_and_fail;
     268        }
    263269    }
    264270
     
    604610        goto fail;
    605611    }
     612    if (pa_threaded_mainloop_start(g_pMainLoop) < 0)
     613    {
     614        LogRel(("Pulse: Failed to start threaded mainloop: %s\n",
     615                 pa_strerror(pa_context_errno(g_pContext))));
     616        goto fail;
     617    }
     618
    606619    pa_context_set_state_callback(g_pContext, context_state_callback, NULL);
     620    pa_threaded_mainloop_lock(g_pMainLoop);
     621
    607622    if (pa_context_connect(g_pContext, /*server=*/NULL, 0, NULL) < 0)
    608623    {
     
    612627    }
    613628
    614     if (pa_threaded_mainloop_start(g_pMainLoop) < 0)
    615     {
    616         LogRel(("Pulse: Failed to start threaded mainloop: %s\n",
    617                  pa_strerror(pa_context_errno(g_pContext))));
    618         goto fail;
    619     }
    620 
    621629    /* Wait until the g_pContext is ready */
    622     pa_threaded_mainloop_lock(g_pMainLoop);
    623     pa_threaded_mainloop_wait(g_pMainLoop);
    624     if (pa_context_get_state(g_pContext) != PA_CONTEXT_READY)
    625     {
    626         LogRel(("Pulse: Wrong context state %d\n", pa_context_get_state(g_pContext)));
    627         goto unlock_and_fail;
     630    for (;;)
     631    {
     632        pa_context_state_t cstate;
     633        pa_threaded_mainloop_wait(g_pMainLoop);
     634        cstate = pa_context_get_state(g_pContext);
     635        if (cstate == PA_CONTEXT_READY)
     636            break;
     637        else if (cstate == PA_CONTEXT_TERMINATED || cstate == PA_CONTEXT_FAILED)
     638        {
     639            LogRel(("Pulse: Failed to initialize context (state %d)\n", cstate));
     640            goto unlock_and_fail;
     641        }
    628642    }
    629643    pa_threaded_mainloop_unlock(g_pMainLoop);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette