Ticket #8361: audioinputalsa.patch

File audioinputalsa.patch, 3.9 KB (added by Carlos Azevedo <geral@…>, 14 years ago)

Patch for ALSA snd-bt87x support

  • audioinputalsa.cpp

    diff -urp orig/audioinputalsa.cpp new/audioinputalsa.cpp
    old new bool AudioInputALSA::PrepHwParams(void) 
    191191    }
    192192    uint buffer_time = 64000; // 64 msec
    193193    uint period_time = buffer_time / 4;
    194     if (!AlsaBad(snd_pcm_hw_params_set_buffer_time_near(pcm_handle, hwparams,
    195                  &buffer_time, NULL), "initial buffer time setting failed"))
    196     {
    197         snd_pcm_uframes_t buffer_size;
    198         if (AlsaBad(snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size),
    199                     "failed to get buffer size"))
    200             return false;
    201         if (AlsaBad(snd_pcm_hw_params_get_buffer_time(hwparams, &buffer_time, NULL),
    202                     "failed to get buffer_time setting"))
    203             return false;
    204         if (AlsaBad(snd_pcm_hw_params_set_period_time_near(pcm_handle, hwparams,
    205                                                            &period_time, NULL),
    206                     "failed to set period time"))
    207             return false;
    208         if (AlsaBad(snd_pcm_hw_params_get_period_size(hwparams, &period_size,
    209                                                       NULL),
    210                     "failed to get period size"))
    211             return false;
    212     }
    213     else
    214     {
    215         VERBOSE(VB_AUDIO, LOC + "hwparams settings, Plan B");
    216         if (AlsaBad(snd_pcm_hw_params_set_period_time_near(pcm_handle, hwparams,
    217                     &period_time, NULL), "failed to set period time"))
    218             return false;
    219         if (AlsaBad(snd_pcm_hw_params_get_period_size(hwparams, &period_size,
    220                     NULL), "failed to get period size"))
    221             return false;
    222         snd_pcm_uframes_t buffer_size = period_size * 4;
    223         if (AlsaBad(snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams,
    224                     &buffer_size), "failed to set buffer size"))
    225             return false;
    226         if (AlsaBad(snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size),
    227                     "failed to get buffer size"))
    228             return false;
    229     }
     194    if (AlsaBad(snd_pcm_hw_params_set_period_time_near(pcm_handle, hwparams, &period_time, NULL),
     195                "failed to set period time"))
     196        return false;
     197    if (AlsaBad(snd_pcm_hw_params_set_buffer_time_near(pcm_handle, hwparams, &buffer_time, NULL),
     198                "failed to set buffer time"))
     199        return false;
     200    if (AlsaBad(snd_pcm_hw_params_get_period_size(hwparams, &period_size, NULL),
     201                "failed to get period size"))
     202        return false;
     203
    230204    if (AlsaBad(snd_pcm_hw_params (pcm_handle, hwparams),
    231205                "failed to set hwparams"))
    232206        return false;
    233     if (AlsaBad(snd_pcm_hw_params_get_periods(hwparams, &periods, NULL),
    234                 "failed to get periods"))
    235         return false;
    236207
    237208    myth_block_bytes = snd_pcm_frames_to_bytes(pcm_handle, period_size);
    238209    VERBOSE(VB_AUDIO, LOC_DEV
    239210            + QString("channels %1, sample rate %2, buffer_time %3 msec, period "
    240                       "size %4, periods %5").arg(m_audio_channels)
     211                      "size %4").arg(m_audio_channels)
    241212            .arg(m_audio_sample_rate).arg(buffer_time / 1000.0, -1, 'f', 1)
    242             .arg(period_size).arg(periods));
     213            .arg(period_size));
    243214    VERBOSE(VB_AUDIO+VB_EXTRA, LOC_DEV + QString("myth block size %1")
    244215            .arg(myth_block_bytes));
    245216    return true;
  • audioinputalsa.h

    diff -urp orig/audioinputalsa.h new/audioinputalsa.h
    old new class AudioInputALSA : public AudioInput 
    5757    QByteArray          alsa_device;
    5858    snd_pcm_t*          pcm_handle;
    5959    snd_pcm_uframes_t   period_size;
    60     uint                periods;
    6160    int                 myth_block_bytes;
    6261};
    6362#endif /* _AUDIOINPUTALSA_H_ */