VirtualBox

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


Ignore:
Timestamp:
Nov 29, 2010 11:00:53 AM (14 years ago)
Author:
vboxsync
Message:

Devices/Audio/Alsa: incorporated upstream fix to properly resume a stream suspend which can be necessary after the host was suspended

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

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

    r28800 r34451  
    8080PROXY_STUB(snd_strerror, const char *, (int errnum), (errnum))
    8181PROXY_STUB(snd_pcm_drop, int, (snd_pcm_t *pcm), (pcm))
     82PROXY_STUB(snd_pcm_resume, int, (snd_pcm_t *pcm), (pcm))
    8283PROXY_STUB(snd_pcm_hw_params_get_buffer_size, int,
    8384           (const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val),
     
    137138    ELEMENT(snd_strerror),
    138139    ELEMENT(snd_pcm_drop),
     140    ELEMENT(snd_pcm_resume),
    139141    ELEMENT(snd_pcm_hw_params_get_buffer_size),
    140142    ELEMENT(snd_pcm_hw_params_set_rate_near),
  • trunk/src/VBox/Devices/Audio/alsaaudio.c

    r33595 r34451  
    664664}
    665665
     666static int alsa_resume (snd_pcm_t *handle)
     667{
     668    int err = snd_pcm_resume (handle);
     669    if (err < 0) {
     670#ifndef VBOX
     671        alsa_logerr (err, "Failed to resume handle %p\n", handle);
     672#endif
     673        return -1;
     674    }
     675    return 0;
     676}
     677
    666678static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle)
    667679{
     
    741753                    continue;
    742754
     755                case -ESTRPIPE:
     756                    /* stream is suspended and waiting for an
     757                       application recovery */
     758                    if (alsa_resume (alsa->handle)) {
     759#ifndef VBOX
     760                        alsa_logerr (written, "Failed to write %d frames\n", len);
     761#else
     762                        LogRel(("ALSA: Failed to resume output stream\n"));
     763#endif
     764                        goto exit;
     765                    }
     766                    if (conf.verbose) {
     767                        dolog ("Resuming suspended output stream\n");
     768                    }
     769                    continue;
     770
    743771                case -EAGAIN:
    744772                    goto exit;
     
    953981    }
    954982
    955     if (!avail && (snd_pcm_state (alsa->handle) == SND_PCM_STATE_PREPARED)) {
    956         avail = hw->samples;
     983    if (!avail) {
     984        snd_pcm_state_t state;
     985        state = snd_pcm_state (alsa->handle);
     986        switch (state) {
     987            case SND_PCM_STATE_PREPARED:
     988                avail = hw->samples;
     989                break;
     990            case SND_PCM_STATE_SUSPENDED:
     991                /* stream is suspended and waiting for an application recovery */
     992                if (alsa_resume (alsa->handle)) {
     993#ifndef VBOX
     994                    dolog ("Failed to resume suspended input stream\n");
     995#else
     996                    LogRel(("ALSA: Failed to resume input stream\n"));
     997#endif
     998                    return 0;
     999                }
     1000                if (conf.verbose) {
     1001                    dolog ("Resuming suspended input stream\n");
     1002                }
     1003                break;
     1004            default:
     1005                if (conf.verbose) {
     1006                    dolog ("No frames available and ALSA state is %d\n", state);
     1007                }
     1008                return 0;
     1009        }
    9571010    }
    9581011
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