VirtualBox

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


Ignore:
Timestamp:
Jan 20, 2016 2:56:07 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105143
Message:

Audio/DrvHostDSound.cpp:

  • Only stop playing if were able to retrieve the stream's status before.
  • Use DSBCAPS_LOCSOFTWARE for our secondary Direct Sound buffer for treating it as a static buffer.
  • Extended (release) logging.
File:
1 edited

Legend:

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

    r59263 r59421  
    538538        DSBUFFERDESC bd;
    539539        RT_ZERO(bd);
    540         bd.dwSize = sizeof(bd);
     540        bd.dwSize      = sizeof(bd);
    541541        bd.lpwfxFormat = &wfx;
    542         bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
     542
     543        /*
     544         * As we reuse our (secondary) buffer for playing out data as it comes in,
     545         * we're using this buffer as a so-called static buffer.
     546         *
     547         * However, as we do not want to use memory on the sound device directly
     548         * (as most modern audio hardware on the host doesn't have this anyway),
     549         * we're *not* going to use DSBCAPS_STATIC for that.
     550         *
     551         * Instead we're specifying DSBCAPS_LOCSOFTWARE, as this fits the bill
     552         * of copying own buffer data (from AudioMixBuf) to our secondary's Direct Sound buffer.
     553         */
     554        bd.dwFlags     = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE;
    543555#ifdef VBOX_WITH_AUDIO_CALLBACKS
    544         bd.dwFlags      |= DSBCAPS_CTRLPOSITIONNOTIFY;
     556        bd.dwFlags    |= DSBCAPS_CTRLPOSITIONNOTIFY;
    545557#endif
    546558        bd.dwBufferBytes = pThis->cfg.cbBufferOut;
     
    584596        DSLOG(("DSound: Playback format:\n"
    585597               "  dwBufferBytes   = %RI32\n"
     598               "  dwFlags         = 0x%x\n"
    586599               "  wFormatTag      = %RI16\n"
    587600               "  nChannels       = %RI16\n"
     
    592605               "  cbSize          = %RI16\n",
    593606               bc.dwBufferBytes,
     607               bc.dwFlags,
    594608               wfx.wFormatTag,
    595609               wfx.nChannels,
     
    742756    {
    743757        /* This performs some restore, so call it anyway and ignore result. */
    744         directSoundPlayGetStatus(pDSoundStrmOut->pDSB, NULL /* Status */);
    745 
    746         DSLOG(("DSound: Stopping playback\n"));
    747 
    748         /** @todo Wait until all data in the buffer has been played. */
    749         hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB);
     758        hr = directSoundPlayGetStatus(pDSoundStrmOut->pDSB, NULL /* pdwStatus */);
    750759        if (SUCCEEDED(hr))
    751             dsoundPlayClearSamples(pDSoundStrmOut);
    752         else
    753             DSLOGREL(("DSound: Stopping playback failed with %Rhrc\n", hr));
     760        {
     761            DSLOG(("DSound: Stopping playback\n"));
     762
     763            /** @todo Wait until all data in the buffer has been played. */
     764            hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB);
     765            if (SUCCEEDED(hr))
     766                dsoundPlayClearSamples(pDSoundStrmOut);
     767        }
    754768    }
    755769    else
    756770        hr = E_UNEXPECTED;
     771
     772    if (FAILED(hr))
     773        DSLOGREL(("DSound: Stopping playback failed with %Rhrc\n", hr));
    757774
    758775    return hr;
     
    790807    else
    791808        hr = E_UNEXPECTED;
     809
     810    if (FAILED(hr))
     811        DSLOGREL(("DSound: Starting playback failed with %Rhrc\n", hr));
    792812
    793813    return hr;
     
    10071027        DSLOG(("DSound: Capture format:\n"
    10081028               "  dwBufferBytes   = %RI32\n"
     1029               "  dwFlags         = 0x%x\n"
    10091030               "  wFormatTag      = %RI16\n"
    10101031               "  nChannels       = %RI16\n"
     
    10151036               "  cbSize          = %RI16\n",
    10161037               bc.dwBufferBytes,
     1038               bc.dwFlags,
    10171039               wfx.wFormatTag,
    10181040               wfx.nChannels,
     
    13631385        DWORD cb1, cb2;
    13641386        HRESULT hr = directSoundPlayLock(pDSB, &pHstStrmOut->Props, pDSoundStrmOut->cbPlayWritePos, cbLive,
    1365                                  &pv1, &pv2, &cb1, &cb2, 0 /* dwFlags */);
     1387                                         &pv1, &pv2, &cb1, &cb2, 0 /* dwFlags */);
    13661388        if (FAILED(hr))
    13671389        {
Note: See TracChangeset for help on using the changeset viewer.

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