diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/alsa/qalsaaudiooutput.cpp | 34 | ||||
-rw-r--r-- | src/plugins/avfoundation/camera/avfmediaassetwriter.mm | 8 |
2 files changed, 19 insertions, 23 deletions
diff --git a/src/plugins/alsa/qalsaaudiooutput.cpp b/src/plugins/alsa/qalsaaudiooutput.cpp index ddbe04de9..5c8ae171c 100644 --- a/src/plugins/alsa/qalsaaudiooutput.cpp +++ b/src/plugins/alsa/qalsaaudiooutput.cpp @@ -53,9 +53,11 @@ #include <QtMultimedia/private/qaudiohelpers_p.h> #include "qalsaaudiooutput.h" #include "qalsaaudiodeviceinfo.h" +#include <QLoggingCategory> QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcAlsaOutput, "qt.multimedia.alsa.output") //#define DEBUG_AUDIO 1 QAlsaAudioOutput::QAlsaAudioOutput(const QByteArray &device) @@ -403,28 +405,22 @@ bool QAlsaAudioOutput::open() fatal = true; errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); } else { - if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { -#ifdef DEBUG_AUDIO - qDebug()<<"defaults out of range"; - qDebug()<<"pmin="<<minPeriodTime<<", pmax="<<maxPeriodTime<<", bmin="<<minBufferTime<<", bmax="<<maxBufferTime; -#endif - period_time = minPeriodTime; - if (period_time*4 <= maxBufferTime) { - // Use 4 periods if possible - buffer_time = period_time*4; - chunks = 4; - } else if (period_time*2 <= maxBufferTime) { - // Use 2 periods if possible - buffer_time = period_time*2; - chunks = 2; + static unsigned user_buffer_time = qEnvironmentVariableIntValue("QT_ALSA_OUTPUT_BUFFER_TIME"); + static unsigned user_period_time = qEnvironmentVariableIntValue("QT_ALSA_OUTPUT_PERIOD_TIME"); + const bool outOfRange = maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time; + if (outOfRange || user_period_time || user_buffer_time) { + period_time = user_period_time ? user_period_time : minPeriodTime; + if (!user_buffer_time) { + chunks = maxBufferTime / period_time; + buffer_time = period_time * chunks; } else { - qWarning()<<"QAudioOutput: alsa only supports single period!"; - fatal = true; + buffer_time = user_buffer_time; + chunks = buffer_time / period_time; } -#ifdef DEBUG_AUDIO - qDebug()<<"used: buffer_time="<<buffer_time<<", period_time="<<period_time; -#endif } + qCDebug(lcAlsaOutput) << "buffer time: [" << minBufferTime << "-" << maxBufferTime << "] =" << buffer_time; + qCDebug(lcAlsaOutput) << "period time: [" << minPeriodTime << "-" << maxPeriodTime << "] =" << period_time; + qCDebug(lcAlsaOutput) << "chunks =" << chunks; } } if ( !fatal ) { diff --git a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm index 318d66117..9030adb2c 100644 --- a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm +++ b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm @@ -413,7 +413,7 @@ enum WriterState m_audioOutput.reset([[AVCaptureAudioDataOutput alloc] init]); - if (m_audioOutput && [captureSession canAddOutput:m_audioOutput]) { + if (m_audioOutput.data() && [captureSession canAddOutput:m_audioOutput]) { [captureSession addOutput:m_audioOutput]; } else { qDebugCamera() << Q_FUNC_INFO << "failed to add audio output"; @@ -431,7 +431,7 @@ enum WriterState { Q_ASSERT(m_service && m_service->videoOutput() && m_service->videoOutput()->videoDataOutput()); - Q_ASSERT(m_assetWriter); + Q_ASSERT(m_assetWriter.data()); m_cameraWriterInput.reset([[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:m_videoSettings @@ -451,7 +451,7 @@ enum WriterState m_cameraWriterInput.data().expectsMediaDataInRealTime = YES; - if (m_audioOutput) { + if (m_audioOutput.data()) { CMFormatDescriptionRef sourceFormat = m_audioCaptureDevice ? m_audioCaptureDevice.activeFormat.formatDescription : 0; m_audioWriterInput.reset([[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeAudio outputSettings:m_audioSettings @@ -479,7 +479,7 @@ enum WriterState [m_service->videoOutput()->videoDataOutput() setSampleBufferDelegate:self queue:m_videoQueue]; - if (m_audioOutput) { + if (m_audioOutput.data()) { Q_ASSERT(m_audioQueue); [m_audioOutput setSampleBufferDelegate:self queue:m_audioQueue]; } |