Changeset 9741adc7f in mythtv
- Timestamp:
- Nov 22, 2010, 4:36:37 AM (14 years ago)
- Branches:
- devel/2020-player, devel/ffmpeg-resync, devel/gpu-commflag, fixes/0.25, fixes/0.26, fixes/0.27, fixes/0.28, fixes/29, fixes/30, fixes/31, github-templates, master
- Children:
- 18fdd004ee
- Parents:
- ca3ea9c009
- Location:
- mythtv/libs/libmyth
- Files:
-
- 2 edited
-
audiooutputalsa.cpp (modified) (8 diffs)
-
audiooutputalsa.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mythtv/libs/libmyth/audiooutputalsa.cpp
rca3ea9c009 r9741adc7f 34 34 AudioOutputBase(settings), 35 35 pcm_handle(NULL), 36 numbadioctls(0),37 36 pbufsize(-1), 38 37 m_card(-1), 39 38 m_device(-1), 40 m_subdevice(-1) 39 m_subdevice(-1), 40 m_autopassthrough(false) 41 41 { 42 42 m_mixer.handle = NULL; … … 46 46 if (passthru_device == "auto") 47 47 { 48 m_autopassthrough = true; 48 49 passthru_device = main_device; 49 50 … … 99 100 } 100 101 102 int AudioOutputALSA::TryOpenDevice(int open_mode, int try_ac3) 103 { 104 QString real_device; 105 QByteArray dev_ba; 106 int err = -1; 107 108 if (try_ac3) 109 { 110 dev_ba = passthru_device.toAscii(); 111 err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 112 SND_PCM_STREAM_PLAYBACK, open_mode); 113 m_lastdevice = passthru_device; 114 if (!m_autopassthrough) 115 return err; 116 } 117 if (!try_ac3 || err < 0) 118 { 119 // passthru open failed, retry default device 120 dev_ba = main_device.toAscii(); 121 err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 122 SND_PCM_STREAM_PLAYBACK, open_mode); 123 m_lastdevice = main_device; 124 } 125 return err; 126 } 127 101 128 int AudioOutputALSA::GetPCMInfo(int &card, int &device, int &subdevice) 102 129 { … … 236 263 int err; 237 264 238 QString real_device = (passthru || enc) ? passthru_device : main_device;239 240 265 AudioOutputSettings *settings = new AudioOutputSettings(); 241 266 … … 245 270 pcm_handle = NULL; 246 271 } 247 QByteArray dev_ba = real_device.toAscii(); 248 if((err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 249 SND_PCM_STREAM_PLAYBACK, OPEN_FLAGS)) < 0) 250 { 251 AERROR(QString("snd_pcm_open(\"%1\")").arg(real_device)); 272 273 if((err = TryOpenDevice(OPEN_FLAGS, passthru || enc)) < 0) 274 { 275 AERROR(QString("snd_pcm_open(\"%1\")").arg(m_lastdevice)); 252 276 delete settings; 253 277 return NULL; … … 259 283 { 260 284 snd_pcm_close(pcm_handle); 261 if((err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 262 SND_PCM_STREAM_PLAYBACK, OPEN_FLAGS&FILTER_FLAGS 263 )) < 0) 264 { 265 AERROR(QString("snd_pcm_open(\"%1\")").arg(real_device)); 285 if((err = TryOpenDevice(OPEN_FLAGS&FILTER_FLAGS, passthru || enc)) < 0) 286 { 287 AERROR(QString("snd_pcm_open(\"%1\")").arg(m_lastdevice)); 266 288 delete settings; 267 289 return NULL; … … 309 331 while(1) 310 332 { 333 QString real_device = (((passthru || enc) && !m_autopassthrough) ? 334 passthru_device : main_device); 335 311 336 QString desc = alsadevs->value(real_device); 312 337 … … 346 371 uint buffer_time, period_time; 347 372 int err; 348 QString real_device;349 373 350 374 if (pcm_handle != NULL) 351 375 CloseDevice(); 352 376 353 numbadioctls = 0; 354 355 if (passthru || enc) 356 { 357 real_device = passthru_device; 358 } 359 else 360 { 361 real_device = main_device; 362 } 363 364 QByteArray dev_ba = real_device.toAscii(); 365 err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 366 SND_PCM_STREAM_PLAYBACK, 0); 367 if ((passthru || enc) && err < 0) 368 { 369 // passthru open failed, retry default device 370 dev_ba = main_device.toAscii(); 371 err = snd_pcm_open(&pcm_handle, dev_ba.constData(), 372 SND_PCM_STREAM_PLAYBACK, 0); 373 } 374 if (err < 0) 375 { 376 AERROR(QString("snd_pcm_open(%1)").arg(real_device)); 377 if ((err = TryOpenDevice(0, passthru || enc)) < 0) 378 { 379 AERROR(QString("snd_pcm_open2(\"%1\")").arg(m_lastdevice)); 377 380 if (pcm_handle) 378 381 CloseDevice(); -
mythtv/libs/libmyth/audiooutputalsa.h
rca3ea9c009 r9741adc7f 32 32 33 33 private: 34 int TryOpenDevice(int open_mode, int try_ac3); 34 35 int GetPCMInfo(int &card, int &device, int &subdevice); 35 36 bool SetPreallocBufferSize(int size); … … 43 44 private: 44 45 snd_pcm_t *pcm_handle; 45 int numbadioctls;46 46 int pbufsize; 47 47 int m_card, m_device, m_subdevice; … … 49 49 snd_pcm_sframes_t (*pcm_write_func)(snd_pcm_t*, const void*, 50 50 snd_pcm_uframes_t); 51 bool m_autopassthrough; 52 QString m_lastdevice; 53 51 54 struct { 52 55 QString device;
Note: See TracChangeset
for help on using the changeset viewer.
