Ticket #3598: mythtv_alsa_non_mmap_fallback.patch
File mythtv_alsa_non_mmap_fallback.patch, 3.1 KB (added by , 17 years ago) |
---|
-
audiooutputalsa.h
37 37 virtual inline int getBufferedOnSoundcard(void); 38 38 39 39 private: 40 inline int SetParameters(snd_pcm_t *handle, snd_pcm_access_t access,40 inline int SetParameters(snd_pcm_t *handle, 41 41 snd_pcm_format_t format, unsigned int channels, 42 42 unsigned int rate, unsigned int buffer_time, 43 43 unsigned int period_time); … … 59 59 float volume_range_multiplier; 60 60 long playback_vol_min; 61 61 long playback_vol_max; 62 snd_pcm_sframes_t (*pcm_write_func)(snd_pcm_t*, const void*, snd_pcm_uframes_t); 62 63 }; 63 64 64 65 #endif -
audiooutputalsa.cpp
113 113 return false; 114 114 } 115 115 116 err = SetParameters(pcm_handle, SND_PCM_ACCESS_MMAP_INTERLEAVED,116 err = SetParameters(pcm_handle, 117 117 format, audio_channels, audio_samplerate, buffer_time, 118 118 period_time); 119 119 if (err < 0) … … 164 164 165 165 while (frames > 0) 166 166 { 167 lw = snd_pcm_mmap_writei(pcm_handle, tmpbuf, frames);167 lw = pcm_write_func(pcm_handle, tmpbuf, frames); 168 168 169 169 if (lw >= 0) 170 170 { … … 221 221 } 222 222 else 223 223 { 224 VERBOSE(VB_IMPORTANT, QString(" snd_pcm_mmap_writei: %1 (%2)")224 VERBOSE(VB_IMPORTANT, QString("pcm_write_func: %1 (%2)") 225 225 .arg(snd_strerror(lw)).arg(lw)); 226 226 VERBOSE(VB_IMPORTANT, QString("WriteAudio: snd_pcm_state == %1") 227 227 .arg(snd_pcm_state(pcm_handle))); … … 292 292 } 293 293 294 294 295 int AudioOutputALSA::SetParameters(snd_pcm_t *handle, snd_pcm_access_t access,295 int AudioOutputALSA::SetParameters(snd_pcm_t *handle, 296 296 snd_pcm_format_t format, unsigned int channels, 297 297 unsigned int rate, unsigned int buffer_time, 298 298 unsigned int period_time) … … 324 324 return err; 325 325 } 326 326 327 /* set the interleaved read/write format */ 328 if ((err = snd_pcm_hw_params_set_access(handle, params, access)) < 0) 327 /* set the interleaved read/write format, use mmap if available */ 328 pcm_write_func = &snd_pcm_mmap_writei; 329 if ((err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) 329 330 { 330 Error(QString("Access type not available: %1") 331 .arg(snd_strerror(err))); 332 return err; 331 VERBOSE(VB_GENERAL, QString("ALSA mmap not available")); 332 pcm_write_func = &snd_pcm_writei; 333 if ((err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) 334 { 335 Error(QString("Access type not available: %1") 336 .arg(snd_strerror(err))); 337 return err; 338 } 333 339 } 334 340 335 341 /* set the sample format */