summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/ds9/iodevicereader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/phonon/ds9/iodevicereader.cpp')
-rw-r--r--src/3rdparty/phonon/ds9/iodevicereader.cpp91
1 files changed, 19 insertions, 72 deletions
diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp
index ec10278..e0c505c 100644
--- a/src/3rdparty/phonon/ds9/iodevicereader.cpp
+++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp
@@ -36,19 +36,10 @@ namespace Phonon
//these mediatypes define a stream, its type will be autodetected by DirectShow
static QVector<AM_MEDIA_TYPE> getMediaTypes()
{
- AM_MEDIA_TYPE mt;
- mt.majortype = MEDIATYPE_Stream;
- mt.bFixedSizeSamples = TRUE;
- mt.bTemporalCompression = FALSE;
- mt.lSampleSize = 1;
- mt.formattype = GUID_NULL;
- mt.pUnk = 0;
- mt.cbFormat = 0;
- mt.pbFormat = 0;
+ AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
QVector<AM_MEDIA_TYPE> ret;
//normal auto-detect stream
- mt.subtype = MEDIASUBTYPE_NULL;
ret << mt;
//AVI stream
mt.subtype = MEDIASUBTYPE_Avi;
@@ -72,7 +63,6 @@ namespace Phonon
//for Phonon::StreamInterface
void writeData(const QByteArray &data)
{
- QWriteLocker locker(&m_lock);
m_pos += data.size();
m_buffer += data;
}
@@ -83,54 +73,22 @@ namespace Phonon
void setStreamSize(qint64 newSize)
{
- QWriteLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
m_size = newSize;
}
- qint64 streamSize() const
- {
- QReadLocker locker(&m_lock);
- return m_size;
- }
-
void setStreamSeekable(bool s)
{
- QWriteLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
m_seekable = s;
}
- bool streamSeekable() const
- {
- QReadLocker locker(&m_lock);
- return m_seekable;
- }
-
- void setCurrentPos(qint64 pos)
- {
- QWriteLocker locker(&m_lock);
- m_pos = pos;
- seekStream(pos);
- m_buffer.clear();
- }
-
- qint64 currentPos() const
- {
- QReadLocker locker(&m_lock);
- return m_pos;
- }
-
- int currentBufferSize() const
- {
- QReadLocker locker(&m_lock);
- return m_buffer.size();
- }
-
//virtual pure members
//implementation from IAsyncReader
STDMETHODIMP Length(LONGLONG *total, LONGLONG *available)
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (total) {
*total = m_size;
}
@@ -145,44 +103,42 @@ namespace Phonon
HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual)
{
- QMutexLocker locker(&m_mutexRead);
-
+ Q_ASSERT(!m_mutex.tryLock());
if (m_mediaGraph->isStopping()) {
return VFW_E_WRONG_STATE;
}
- if(streamSize() != 1 && pos + length > streamSize()) {
+ if(m_size != 1 && pos + length > m_size) {
//it tries to read outside of the boundaries
return E_FAIL;
}
- if (currentPos() - currentBufferSize() != pos) {
- if (!streamSeekable()) {
+ if (m_pos - m_buffer.size() != pos) {
+ if (!m_seekable) {
return S_FALSE;
}
- setCurrentPos(pos);
+ m_pos = pos;
+ seekStream(pos);
+ m_buffer.clear();
}
- int oldSize = currentBufferSize();
- while (currentBufferSize() < int(length)) {
+ int oldSize = m_buffer.size();
+ while (m_buffer.size() < int(length)) {
needData();
if (m_mediaGraph->isStopping()) {
return VFW_E_WRONG_STATE;
}
- if (oldSize == currentBufferSize()) {
+ if (oldSize == m_buffer.size()) {
break; //we didn't get any data
}
- oldSize = currentBufferSize();
+ oldSize = m_buffer.size();
}
- DWORD bytesRead = qMin(currentBufferSize(), int(length));
- {
- QWriteLocker locker(&m_lock);
- qMemCopy(buffer, m_buffer.data(), bytesRead);
- //truncate the buffer
- m_buffer = m_buffer.mid(bytesRead);
- }
+ int bytesRead = qMin(m_buffer.size(), int(length));
+ qMemCopy(buffer, m_buffer.data(), bytesRead);
+ //truncate the buffer
+ m_buffer = m_buffer.mid(bytesRead);
if (actual) {
*actual = bytesRead; //initialization
@@ -198,7 +154,6 @@ namespace Phonon
qint64 m_pos;
qint64 m_size;
- QMutex m_mutexRead;
const MediaGraph *m_mediaGraph;
};
@@ -212,14 +167,6 @@ namespace Phonon
IODeviceReader::~IODeviceReader()
{
}
-
- STDMETHODIMP IODeviceReader::Stop()
- {
- HRESULT hr = QBaseFilter::Stop();
- m_streamReader->enoughData(); //this asks to cancel any blocked call to needData
- return hr;
- }
-
}
}