summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPekka Gehör <pekka.gehor@qt.io>2022-02-17 10:27:21 +0200
committerPekka Gehör <pekka.gehor@qt.io>2022-06-13 10:06:35 +0000
commit9dc7403f73508e340a89a0752db1dfe1047a442d (patch)
tree94610cea99760d5d1e2f8b2ec3496cbcbe71613c /src
parent8c5fb93ffa5e2220d061d608f5bf38f284719437 (diff)
Android: Fix error signals issues
Error Signal types changed to the same as on gstreamer side. After fix the tst_QAudioDecoderBackend test go passes. Task-number: QTBUG-100079 Change-Id: I845d744fb07aba084168fe8c7fe5b380b6ec6ebe Reviewed-by: Samuel Mira <samuel.mira@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit bed5590f87a19da562ddb91b9c0ba4d313613f1a) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp22
-rw-r--r--src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h1
2 files changed, 17 insertions, 6 deletions
diff --git a/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp b/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
index d84085800..c4896d733 100644
--- a/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
+++ b/src/multimedia/platform/android/audio/qandroidaudiodecoder.cpp
@@ -101,8 +101,7 @@ void Decoder::setSource(const QUrl &source)
const QString mime = path.isValid() ? path.toString() : "";
if (!mime.isEmpty() && !mime.contains("audio", Qt::CaseInsensitive)) {
- emit error(QAudioDecoder::FormatError,
- tr("Cannot set source, invalid mime type for the provided source."));
+ m_formatError = tr("Cannot set source, invalid mime type for the provided source.");
return;
}
@@ -122,9 +121,9 @@ void Decoder::setSource(const QUrl &source)
}
if (fd < 0) {
- emit error(QAudioDecoder::ResourceError, tr("Invalid fileDescriptor for source."));
- return;
- }
+ emit error(QAudioDecoder::ResourceError, tr("Invalid fileDescriptor for source."));
+ return;
+ }
const int size = QFile(source.toString()).size();
media_status_t status = AMediaExtractor_setDataSourceFd(m_extractor, fd, 0,
size > 0 ? size : LONG_MAX);
@@ -135,7 +134,7 @@ void Decoder::setSource(const QUrl &source)
AMediaExtractor_delete(m_extractor);
m_extractor = nullptr;
}
- emit error(QAudioDecoder::ResourceError, tr("Setting source for Audio Decoder failed."));
+ m_formatError = tr("Setting source for Audio Decoder failed.");
}
}
@@ -176,6 +175,11 @@ void Decoder::createDecoder()
void Decoder::doDecode()
{
+ if (!m_formatError.isEmpty()) {
+ emit error(QAudioDecoder::FormatError, m_formatError);
+ return;
+ }
+
if (!m_extractor) {
emit error(QAudioDecoder::ResourceError, tr("Cannot decode, source not set."));
return;
@@ -327,6 +331,12 @@ void QAndroidAudioDecoder::start()
m_position = -1;
+ if (m_device && (!m_device->isOpen() || !m_device->isReadable())) {
+ emit error(QAudioDecoder::ResourceError,
+ QString::fromUtf8("Unable to read from the specified device"));
+ return;
+ }
+
if (!m_threadDecoder) {
m_threadDecoder = new QThread(this);
m_decoder->moveToThread(m_threadDecoder);
diff --git a/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h b/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
index a1795e39b..3707f4c50 100644
--- a/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
+++ b/src/multimedia/platform/android/audio/qandroidaudiodecoder_p.h
@@ -90,6 +90,7 @@ private:
AMediaFormat *m_format = nullptr;
QAudioFormat m_outputFormat;
+ QString m_formatError;
bool m_inputEOS;
};