summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-11-01 18:13:40 +0100
committerYoann Lopes <yoann.lopes@theqtcompany.com>2016-01-06 15:20:59 +0000
commite3123185a58eca0339ed6a19a41f4af3549be49d (patch)
treefe91e8b22ee44a797e6dc5f15cc9a88a1e02c918
parent704ac34cc79e3711880bae8eba9c926080b97131 (diff)
downloadqtmultimedia-e3123185a58eca0339ed6a19a41f4af3549be49d.tar.gz
DirectShow: fix metadata signals when changing media.
The metaDataChanged() and metaDataAvailableChanged() signals should be emitted immediately when changing or clearing the current media. Change-Id: I3152e2c32420ba6f11cf6780013e02208a9d6599 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
-rw-r--r--src/plugins/directshow/player/directshowmetadatacontrol.cpp27
-rw-r--r--src/plugins/directshow/player/directshowmetadatacontrol.h7
-rw-r--r--src/plugins/directshow/player/directshowplayerservice.cpp7
3 files changed, 29 insertions, 12 deletions
diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp
index 3f58be249..5400ac8d4 100644
--- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp
+++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp
@@ -362,7 +362,18 @@ static QString convertBSTR(BSTR *string)
return value;
}
-void DirectShowMetaDataControl::updateGraph(IFilterGraph2 *graph, IBaseFilter *source, const QString &fileSrc)
+void DirectShowMetaDataControl::reset()
+{
+ bool hadMetadata = !m_metadata.isEmpty();
+ m_metadata.clear();
+
+ setMetadataAvailable(false);
+
+ if (hadMetadata)
+ emit metaDataChanged();
+}
+
+void DirectShowMetaDataControl::updateMetadata(IFilterGraph2 *graph, IBaseFilter *source, const QString &fileSrc)
{
m_metadata.clear();
@@ -568,13 +579,19 @@ void DirectShowMetaDataControl::customEvent(QEvent *event)
if (event->type() == QEvent::Type(MetaDataChanged)) {
event->accept();
- bool oldAvailable = m_available;
- m_available = !m_metadata.isEmpty();
- if (m_available != oldAvailable)
- emit metaDataAvailableChanged(m_available);
+ setMetadataAvailable(!m_metadata.isEmpty());
emit metaDataChanged();
} else {
QMetaDataReaderControl::customEvent(event);
}
}
+
+void DirectShowMetaDataControl::setMetadataAvailable(bool available)
+{
+ if (m_available == available)
+ return;
+
+ m_available = available;
+ emit metaDataAvailableChanged(m_available);
+}
diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h
index d32ae8508..55504ba4b 100644
--- a/src/plugins/directshow/player/directshowmetadatacontrol.h
+++ b/src/plugins/directshow/player/directshowmetadatacontrol.h
@@ -56,13 +56,16 @@ public:
QVariant metaData(const QString &key) const;
QStringList availableMetaData() const;
- void updateGraph(IFilterGraph2 *graph, IBaseFilter *source,
- const QString &fileSrc = QString());
+ void reset();
+ void updateMetadata(IFilterGraph2 *graph, IBaseFilter *source,
+ const QString &fileSrc = QString());
protected:
void customEvent(QEvent *event);
private:
+ void setMetadataAvailable(bool available);
+
enum Event
{
MetaDataChanged = QEvent::User
diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp
index eac37f538..8e9e50cbf 100644
--- a/src/plugins/directshow/player/directshowplayerservice.cpp
+++ b/src/plugins/directshow/player/directshowplayerservice.cpp
@@ -231,7 +231,7 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream
m_seekable = false;
m_atEnd = false;
m_dontCacheNextSeekResult = false;
- m_metaDataControl->updateGraph(0, 0);
+ m_metaDataControl->reset();
if (m_resources.isEmpty() && !stream) {
m_pendingTasks = 0;
@@ -570,9 +570,6 @@ void DirectShowPlayerService::doReleaseGraph(QMutexLocker *locker)
control->Release();
}
- //release m_headerInfo -> decrease ref counter of m_source
- m_metaDataControl->updateGraph(0, 0);
-
if (m_source) {
m_source->Release();
m_source = 0;
@@ -1138,7 +1135,7 @@ void DirectShowPlayerService::customEvent(QEvent *event)
QMutexLocker locker(&m_mutex);
m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable);
- m_metaDataControl->updateGraph(m_graph, m_source, m_url.toString());
+ m_metaDataControl->updateMetadata(m_graph, m_source, m_url.toString());
updateStatus();
} else if (event->type() == QEvent::Type(Error)) {