WMF: fix bufferStatus() and availablePlaybackRanges().
- Correctly initialize and clear PROPVARIANT structures - Return coherent data even when the information is not available Change-Id: I22b46f95f255cbb740a154c6296a5c3a91e64f67 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
@@ -1403,14 +1403,17 @@ int MFPlayerSession::bufferStatus()
|
|||||||
if (!m_netsourceStatistics)
|
if (!m_netsourceStatistics)
|
||||||
return 0;
|
return 0;
|
||||||
PROPVARIANT var;
|
PROPVARIANT var;
|
||||||
|
PropVariantInit(&var);
|
||||||
PROPERTYKEY key;
|
PROPERTYKEY key;
|
||||||
key.fmtid = MFNETSOURCE_STATISTICS;
|
key.fmtid = MFNETSOURCE_STATISTICS;
|
||||||
key.pid = MFNETSOURCE_BUFFERPROGRESS_ID;
|
key.pid = MFNETSOURCE_BUFFERPROGRESS_ID;
|
||||||
int progress = -1;
|
int progress = -1;
|
||||||
if (SUCCEEDED(m_netsourceStatistics->GetValue(key, &var))) {
|
// GetValue returns S_FALSE if the property is not available, which has
|
||||||
|
// a value > 0. We therefore can't use the SUCCEEDED macro here.
|
||||||
|
if (m_netsourceStatistics->GetValue(key, &var) == S_OK) {
|
||||||
progress = var.lVal;
|
progress = var.lVal;
|
||||||
|
PropVariantClear(&var);
|
||||||
}
|
}
|
||||||
PropVariantClear(&var);
|
|
||||||
|
|
||||||
#ifdef DEBUG_MEDIAFOUNDATION
|
#ifdef DEBUG_MEDIAFOUNDATION
|
||||||
qDebug() << "bufferStatus: progress = " << progress;
|
qDebug() << "bufferStatus: progress = " << progress;
|
||||||
@@ -1421,22 +1424,30 @@ int MFPlayerSession::bufferStatus()
|
|||||||
|
|
||||||
QMediaTimeRange MFPlayerSession::availablePlaybackRanges()
|
QMediaTimeRange MFPlayerSession::availablePlaybackRanges()
|
||||||
{
|
{
|
||||||
if (!m_netsourceStatistics)
|
// defaults to the whole media
|
||||||
return QMediaTimeRange();
|
qint64 start = 0;
|
||||||
|
qint64 end = qint64(m_duration / 10000);
|
||||||
|
|
||||||
qint64 start = 0, end = 0;
|
if (m_netsourceStatistics) {
|
||||||
PROPVARIANT var;
|
PROPVARIANT var;
|
||||||
PROPERTYKEY key;
|
PropVariantInit(&var);
|
||||||
key.fmtid = MFNETSOURCE_STATISTICS;
|
PROPERTYKEY key;
|
||||||
key.pid = MFNETSOURCE_SEEKRANGESTART_ID;
|
key.fmtid = MFNETSOURCE_STATISTICS;
|
||||||
if (SUCCEEDED(m_netsourceStatistics->GetValue(key, &var))) {
|
key.pid = MFNETSOURCE_SEEKRANGESTART_ID;
|
||||||
start = qint64(var.uhVal.QuadPart / 10000);
|
// GetValue returns S_FALSE if the property is not available, which has
|
||||||
key.pid = MFNETSOURCE_SEEKRANGEEND_ID;
|
// a value > 0. We therefore can't use the SUCCEEDED macro here.
|
||||||
if (SUCCEEDED(m_netsourceStatistics->GetValue(key, &var))) {
|
if (m_netsourceStatistics->GetValue(key, &var) == S_OK) {
|
||||||
end = qint64(var.uhVal.QuadPart / 10000);
|
start = qint64(var.uhVal.QuadPart / 10000);
|
||||||
|
PropVariantClear(&var);
|
||||||
|
PropVariantInit(&var);
|
||||||
|
key.pid = MFNETSOURCE_SEEKRANGEEND_ID;
|
||||||
|
if (m_netsourceStatistics->GetValue(key, &var) == S_OK) {
|
||||||
|
end = qint64(var.uhVal.QuadPart / 10000);
|
||||||
|
PropVariantClear(&var);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PropVariantClear(&var);
|
|
||||||
return QMediaTimeRange(start, end);
|
return QMediaTimeRange(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user