equal
deleted
inserted
replaced
119 if(err == -EPIPE) { |
119 if(err == -EPIPE) { |
120 errorState = QAudio::UnderrunError; |
120 errorState = QAudio::UnderrunError; |
121 err = snd_pcm_prepare(handle); |
121 err = snd_pcm_prepare(handle); |
122 if(err < 0) |
122 if(err < 0) |
123 reset = true; |
123 reset = true; |
|
124 else { |
|
125 bytesAvailable = bytesReady(); |
|
126 if (bytesAvailable <= 0) |
|
127 reset = true; |
|
128 } |
124 |
129 |
125 } else if((err == -ESTRPIPE)||(err == -EIO)) { |
130 } else if((err == -ESTRPIPE)||(err == -EIO)) { |
126 errorState = QAudio::IOError; |
131 errorState = QAudio::IOError; |
127 while((err = snd_pcm_resume(handle)) == -EAGAIN){ |
132 while((err = snd_pcm_resume(handle)) == -EAGAIN){ |
128 usleep(100); |
133 usleep(100); |
441 return period_size; |
446 return period_size; |
442 |
447 |
443 if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) |
448 if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) |
444 return 0; |
449 return 0; |
445 int frames = snd_pcm_avail_update(handle); |
450 int frames = snd_pcm_avail_update(handle); |
|
451 if (frames < 0) return frames; |
446 if((int)frames > (int)buffer_frames) |
452 if((int)frames > (int)buffer_frames) |
447 frames = buffer_frames; |
453 frames = buffer_frames; |
448 |
454 |
449 return snd_pcm_frames_to_bytes(handle, frames); |
455 return snd_pcm_frames_to_bytes(handle, frames); |
450 } |
456 } |
456 // Read in some audio data and write it to QIODevice, pull mode |
462 // Read in some audio data and write it to QIODevice, pull mode |
457 if ( !handle ) |
463 if ( !handle ) |
458 return 0; |
464 return 0; |
459 |
465 |
460 bytesAvailable = bytesReady(); |
466 bytesAvailable = bytesReady(); |
|
467 |
|
468 if (bytesAvailable < 0) { |
|
469 // bytesAvailable as negative is error code, try to recover from it. |
|
470 xrun_recovery(bytesAvailable); |
|
471 bytesAvailable = bytesReady(); |
|
472 if (bytesAvailable < 0) { |
|
473 // recovery failed must stop and set error. |
|
474 close(); |
|
475 errorState = QAudio::IOError; |
|
476 deviceState = QAudio::StoppedState; |
|
477 emit stateChanged(deviceState); |
|
478 return 0; |
|
479 } |
|
480 } |
461 |
481 |
462 int count=0, err = 0; |
482 int count=0, err = 0; |
463 while(count < 5) { |
483 while(count < 5) { |
464 int chunks = bytesAvailable/period_size; |
484 int chunks = bytesAvailable/period_size; |
465 int frames = chunks*period_frames; |
485 int frames = chunks*period_frames; |
586 return intervalTime; |
606 return intervalTime; |
587 } |
607 } |
588 |
608 |
589 qint64 QAudioInputPrivate::processedUSecs() const |
609 qint64 QAudioInputPrivate::processedUSecs() const |
590 { |
610 { |
591 return qint64(1000000) * totalTimeValue / settings.frequency(); |
611 qint64 result = qint64(1000000) * totalTimeValue / |
|
612 (settings.channels()*(settings.sampleSize()/8)) / |
|
613 settings.frequency(); |
|
614 |
|
615 return result; |
592 } |
616 } |
593 |
617 |
594 void QAudioInputPrivate::suspend() |
618 void QAudioInputPrivate::suspend() |
595 { |
619 { |
596 if(deviceState == QAudio::ActiveState||resuming) { |
620 if(deviceState == QAudio::ActiveState||resuming) { |