VirtualBox

Changeset 58582 in vbox for trunk


Ignore:
Timestamp:
Nov 5, 2015 2:43:41 PM (9 years ago)
Author:
vboxsync
Message:

Audio/PulseAudio: handle the case when the PulseAudio initialization fails asynchronously during init

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp

    r58378 r58582  
    5858static struct pa_threaded_mainloop *g_pMainLoop;
    5959static struct pa_context           *g_pContext;
     60static volatile bool                g_fAbortMainLoop;
    6061
    6162/**
     
    130131static void drvHostPulseAudioCbSuccess(pa_stream *pStream, int fSuccess, void *pvContext);
    131132
     133/**
     134 * Signal the main loop to abort. Just signalling isn't sufficient as the
     135 * mainloop might not have been entered yet.
     136 */
     137static void drvHostPulseAudioAbortMainLoop(void)
     138{
     139    g_fAbortMainLoop = true;
     140    pa_threaded_mainloop_signal(g_pMainLoop, 0);
     141}
     142
    132143static pa_sample_format_t drvHostPulseAudioFmtToPulse(PDMAUDIOFMT fmt)
    133144{
     
    228239 * Context status changed.
    229240 */
    230 static void drvHostPulseAudioCbCtxState(pa_context *pContext, void *pvContext)
     241static void drvHostPulseAudioCbCtxState(pa_context *pContext, void *pvUser)
    231242{
    232243    AssertPtrReturnVoid(pContext);
    233 
    234     PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pvContext;
    235     NOREF(pStrm);
     244    NOREF(pvUser);
    236245
    237246    switch (pa_context_get_state(pContext))
     
    239248        case PA_CONTEXT_READY:
    240249        case PA_CONTEXT_TERMINATED:
    241             pa_threaded_mainloop_signal(g_pMainLoop, 0);
     250            drvHostPulseAudioAbortMainLoop();
    242251            break;
    243252
    244253        case PA_CONTEXT_FAILED:
    245254            LogRel(("PulseAudio: Audio input/output stopped!\n"));
    246             pa_threaded_mainloop_signal(g_pMainLoop, 0);
     255            drvHostPulseAudioAbortMainLoop();
    247256            break;
    248257
     
    288297        case PA_STREAM_FAILED:
    289298        case PA_STREAM_TERMINATED:
    290             pa_threaded_mainloop_signal(g_pMainLoop, 0 /* fWait */);
     299            drvHostPulseAudioAbortMainLoop();
    291300            break;
    292301
     
    306315
    307316    if (fSuccess)
    308     {
    309         pa_threaded_mainloop_signal(g_pMainLoop, 0 /* fWait */);
    310     }
     317        drvHostPulseAudioAbortMainLoop();
    311318    else
    312319         drvHostPulseAudioError(pStrm->pDrv, "Failed to finish stream operation");
     
    396403        for (;;)
    397404        {
    398             pa_threaded_mainloop_wait(g_pMainLoop);
     405            if (!g_fAbortMainLoop)
     406                pa_threaded_mainloop_wait(g_pMainLoop);
    399407
    400408            sstate = pa_stream_get_state(pStream);
     
    487495        }
    488496
     497        g_fAbortMainLoop = false;
    489498        pa_context_set_state_callback(g_pContext, drvHostPulseAudioCbCtxState, NULL);
    490499        pa_threaded_mainloop_lock(g_pMainLoop);
     
    504513        {
    505514            pa_context_state_t cstate;
    506             pa_threaded_mainloop_wait(g_pMainLoop);
     515            if (!g_fAbortMainLoop)
     516                pa_threaded_mainloop_wait(g_pMainLoop);
    507517
    508518            cstate = pa_context_get_state(g_pContext);
     
    517527            }
    518528        }
    519 
     529    }
     530    while (0);
     531
     532    if (fLocked)
    520533        pa_threaded_mainloop_unlock(g_pMainLoop);
    521     }
    522     while (0);
    523534
    524535    if (RT_FAILURE(rc))
    525536    {
    526537        if (g_pMainLoop)
    527         {
    528             if (fLocked)
    529                 pa_threaded_mainloop_unlock(g_pMainLoop);
    530 
    531             if (g_pMainLoop)
    532                 pa_threaded_mainloop_stop(g_pMainLoop);
    533         }
     538            pa_threaded_mainloop_stop(g_pMainLoop);
    534539
    535540        if (g_pContext)
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