Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. diff --git a/mythtv/libs/libmyth/audio/audiooutputalsa.cpp b/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
  2. index 790f403..df99f52 100644
  3. --- a/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
  4. +++ b/mythtv/libs/libmyth/audio/audiooutputalsa.cpp
  5. @@ -265,13 +265,6 @@ bool AudioOutputALSA::IncPreallocBufferSize(int requested, int buffer_time)
  6. VBAUDIO(QString("Hardware audio buffer cur: %1 need: %2 max allowed: %3")
  7. .arg(cur).arg(size).arg(max));
  8.  
  9. - if (cur == max)
  10. - {
  11. - // It's already the maximum it can be, no point trying further
  12. - pfile.close();
  13. - mfile.close();
  14. - return false;
  15. - }
  16. if (size > max || !size)
  17. {
  18. size = max;
  19. @@ -430,8 +423,8 @@ bool AudioOutputALSA::OpenDevice()
  20. return false;
  21. }
  22.  
  23. - buffer_time = 500000; // buffer 0.5s worth of samples
  24. - period_time = 16; // aim for an interrupt every (1/16th of buffer_time)
  25. + period_time = 50000; // aim for an interrupt every 50ms
  26. + buffer_time = period_time << 2; // buffer 200ms worth of samples
  27.  
  28. err = SetParameters(pcm_handle, format, channels, samplerate,
  29. buffer_time, period_time);
  30. @@ -624,11 +617,11 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
  31. uint channels, uint rate, uint buffer_time,
  32. uint period_time)
  33. {
  34. - int err;
  35. - snd_pcm_hw_params_t *params;
  36. - snd_pcm_sw_params_t *swparams;
  37. - snd_pcm_uframes_t period_size, period_size_min, period_size_max;
  38. - snd_pcm_uframes_t buffer_size, buffer_size_min, buffer_size_max;
  39. + int err, dir;
  40. + snd_pcm_hw_params_t *params;
  41. + snd_pcm_sw_params_t *swparams;
  42. + snd_pcm_uframes_t buffer_size;
  43. + snd_pcm_uframes_t period_size;
  44.  
  45. VBAUDIO(QString("SetParameters(format=%1, channels=%2, rate=%3, "
  46. "buffer_time=%4, period_time=%5)")
  47. @@ -685,25 +678,14 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
  48. }
  49.  
  50. /* set the buffer time */
  51. - err = snd_pcm_hw_params_get_buffer_size_min(params, &buffer_size_min);
  52. - err = snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size_max);
  53. - err = snd_pcm_hw_params_get_period_size_min(params, &period_size_min, NULL);
  54. - err = snd_pcm_hw_params_get_period_size_max(params, &period_size_max, NULL);
  55. - VBAUDIO(QString("Buffer size range from %1 to %2")
  56. - .arg(buffer_size_min)
  57. - .arg(buffer_size_max));
  58. - VBAUDIO(QString("Period size range from %1 to %2")
  59. - .arg(period_size_min)
  60. - .arg(period_size_max));
  61. -
  62. - /* set the buffer time */
  63. + dir = 0;
  64. uint original_buffer_time = buffer_time;
  65. err = snd_pcm_hw_params_set_buffer_time_near(handle, params,
  66. - &buffer_time, NULL);
  67. + &buffer_time, &dir);
  68. CHECKERR(QString("Unable to set buffer time %1").arg(buffer_time));
  69.  
  70. /* See if we need to increase the prealloc'd buffer size
  71. - If buffer_time is too small we could underrun - make 10% difference ok */
  72. + If buffer_time is too small we could underrun - make 10% difference ok */
  73. if ((buffer_time * 1.10f < (float)original_buffer_time) && pbufsize < 0)
  74. {
  75. VBAUDIO(QString("Requested %1us got %2 buffer time")
  76. @@ -714,10 +696,11 @@ int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_format_t format,
  77. VBAUDIO(QString("Buffer time = %1 us").arg(buffer_time));
  78.  
  79. /* set the period time */
  80. - err = snd_pcm_hw_params_set_periods_near(handle, params,
  81. - &period_time, NULL);
  82. + dir = 1;
  83. + err = snd_pcm_hw_params_set_period_time_near(handle, params,
  84. + &period_time, &dir);
  85. CHECKERR(QString("Unable to set period time %1").arg(period_time));
  86. - VBAUDIO(QString("Period time = %1 periods").arg(period_time));
  87. + VBAUDIO(QString("Period time = %1 us").arg(period_time));
  88.  
  89. /* write the parameters to device */
  90. err = snd_pcm_hw_params(handle, params);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement