Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/mythtv/libs/libmyth/audio/audiooutputalsa.cpp b/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
- index 790f403..df99f52 100644
- --- a/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
- +++ b/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
- @@ -265,13 +265,6 @@ bool AudioOutputALSA::IncPreallocBufferSize(int requested, int buffer_time)
- VBAUDIO(QString("Hardware audio buffer cur: %1 need: %2 max allowed: %3")
- .arg(cur).arg(size).arg(max));
- - if (cur == max)
- - {
- - // It's already the maximum it can be, no point trying further
- - pfile.close();
- - mfile.close();
- - return false;
- - }
- if (size > max || !size)
- {
- size = max;
- @@ -430,8 +423,8 @@ bool AudioOutputALSA::OpenDevice()
- return false;
- }
- - buffer_time = 500000; // buffer 0.5s worth of samples
- - period_time = 16; // aim for an interrupt every (1/16th of buffer_time)
- + period_time = 50000; // aim for an interrupt every 50ms
- + buffer_time = period_time << 2; // buffer 200ms worth of samples
- err = SetParameters(pcm_handle, format, channels, samplerate,
- buffer_time, period_time);
- @@ -624,11 +617,11 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
- uint channels, uint rate, uint buffer_time,
- uint period_time)
- {
- - int err;
- - snd_pcm_hw_params_t *params;
- - snd_pcm_sw_params_t *swparams;
- - snd_pcm_uframes_t period_size, period_size_min, period_size_max;
- - snd_pcm_uframes_t buffer_size, buffer_size_min, buffer_size_max;
- + int err, dir;
- + snd_pcm_hw_params_t *params;
- + snd_pcm_sw_params_t *swparams;
- + snd_pcm_uframes_t buffer_size;
- + snd_pcm_uframes_t period_size;
- VBAUDIO(QString("SetParameters(format=%1, channels=%2, rate=%3, "
- "buffer_time=%4, period_time=%5)")
- @@ -685,25 +678,14 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
- }
- /* set the buffer time */
- - err = snd_pcm_hw_params_get_buffer_size_min(params, &buffer_size_min);
- - err = snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size_max);
- - err = snd_pcm_hw_params_get_period_size_min(params, &period_size_min, NULL);
- - err = snd_pcm_hw_params_get_period_size_max(params, &period_size_max, NULL);
- - VBAUDIO(QString("Buffer size range from %1 to %2")
- - .arg(buffer_size_min)
- - .arg(buffer_size_max));
- - VBAUDIO(QString("Period size range from %1 to %2")
- - .arg(period_size_min)
- - .arg(period_size_max));
- -
- - /* set the buffer time */
- + dir = 0;
- uint original_buffer_time = buffer_time;
- err = snd_pcm_hw_params_set_buffer_time_near(handle, params,
- - &buffer_time, NULL);
- + &buffer_time, &dir);
- CHECKERR(QString("Unable to set buffer time %1").arg(buffer_time));
- /* See if we need to increase the prealloc'd buffer size
- - If buffer_time is too small we could underrun - make 10% difference ok */
- + If buffer_time is too small we could underrun - make 10% difference ok */
- if ((buffer_time * 1.10f < (float)original_buffer_time) && pbufsize < 0)
- {
- VBAUDIO(QString("Requested %1us got %2 buffer time")
- @@ -714,10 +696,11 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
- VBAUDIO(QString("Buffer time = %1 us").arg(buffer_time));
- /* set the period time */
- - err = snd_pcm_hw_params_set_periods_near(handle, params,
- - &period_time, NULL);
- + dir = 1;
- + err = snd_pcm_hw_params_set_period_time_near(handle, params,
- + &period_time, &dir);
- CHECKERR(QString("Unable to set period time %1").arg(period_time));
- - VBAUDIO(QString("Period time = %1 periods").arg(period_time));
- + VBAUDIO(QString("Period time = %1 us").arg(period_time));
- /* write the parameters to device */
- err = snd_pcm_hw_params(handle, params);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement