All pastes #937168 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-10 21:57 UTC
rendered paste body
Index: libs/libmyth/audiooutputalsa.cpp
===================================================================
--- libs/libmyth/audiooutputalsa.cpp    (revision 16437)
+++ libs/libmyth/audiooutputalsa.cpp    (working copy)
@@ -129,7 +131,8 @@
 
     // make us think that soundcard buffer is 4 fragments smaller than
     // it really is
-    audio_buffer_unused = soundcard_buffer_size - (fragment_size * 4);
+    //audio_buffer_unused = soundcard_buffer_size - (fragment_size * 4);
+    audio_buffer_unused = (fragment_size * 4);
 
     if (internal_vol)
         OpenMixer(set_initial_vol);


The only real use of audio_buffer_unused seems to be in
AudioOutputALSA::getSpaceOnSoundcard().

It looks odd without the above change, the space returned will always be too small?

inline int AudioOutputALSA::getSpaceOnSoundcard(void)
{
    if (pcm_handle == NULL)
    {
        VERBOSE(VB_IMPORTANT, QString("getSpaceOnSoundcard() called with pcm_handle == NULL!"));
        return 0;
    }

    snd_pcm_sframes_t avail, delay;

    snd_pcm_state_t state = snd_pcm_state(pcm_handle);
    if (state == SND_PCM_STATE_RUNNING || 
        state == SND_PCM_STATE_DRAINING)
    {
        snd_pcm_delay(pcm_handle, &delay);
    }

    avail = snd_pcm_avail_update(pcm_handle);
    if (avail < 0 ||
        (snd_pcm_uframes_t)avail > (snd_pcm_uframes_t)soundcard_buffer_size)
        avail = soundcard_buffer_size;

    int space = (avail * audio_bytes_per_sample) - audio_buffer_unused;

    if (space < 0)
        space = 0;

    return space;
}