summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/ds9/qpin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/phonon/ds9/qpin.cpp')
-rw-r--r--src/3rdparty/phonon/ds9/qpin.cpp69
1 files changed, 24 insertions, 45 deletions
diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp
index f652502..b4afd10 100644
--- a/src/3rdparty/phonon/ds9/qpin.cpp
+++ b/src/3rdparty/phonon/ds9/qpin.cpp
@@ -28,20 +28,7 @@ namespace Phonon
namespace DS9
{
- static const AM_MEDIA_TYPE defaultMediaType()
- {
- AM_MEDIA_TYPE ret;
- ret.majortype = MEDIATYPE_NULL;
- ret.subtype = MEDIASUBTYPE_NULL;
- ret.bFixedSizeSamples = TRUE;
- ret.bTemporalCompression = FALSE;
- ret.lSampleSize = 1;
- ret.formattype = GUID_NULL;
- ret.pUnk = 0;
- ret.cbFormat = 0;
- ret.pbFormat = 0;
- return ret;
- }
+ static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
class QEnumMediaTypes : public IEnumMediaTypes
{
@@ -104,8 +91,8 @@ namespace Phonon
return E_INVALIDARG;
}
- int nbFetched = 0;
- while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) {
+ uint nbFetched = 0;
+ while (nbFetched < count && m_index < m_pin->mediaTypes().count()) {
//the caller will deallocate the memory
*out = static_cast<AM_MEDIA_TYPE *>(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)));
const AM_MEDIA_TYPE original = m_pin->mediaTypes().at(m_index);
@@ -158,9 +145,9 @@ namespace Phonon
QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector<AM_MEDIA_TYPE> &mt) :
- m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0),
- m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType()),
- m_flushing(false)
+ m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0),
+ m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType),
+ m_memAlloc(0)
{
Q_ASSERT(m_parent);
m_parent->addPin(this);
@@ -273,7 +260,7 @@ namespace Phonon
if (FAILED(hr)) {
setConnected(0);
- setConnectedType(defaultMediaType());
+ setConnectedType(defaultMediaType);
} else {
ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
if (input) {
@@ -315,10 +302,8 @@ namespace Phonon
}
setConnected(0);
- setConnectedType(defaultMediaType());
- if (m_direction == PINDIR_INPUT) {
- setMemoryAllocator(0);
- }
+ setConnectedType(defaultMediaType);
+ setMemoryAllocator(0);
return S_OK;
}
@@ -338,7 +323,7 @@ namespace Phonon
STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type)
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (!type) {
return E_POINTER;
}
@@ -353,7 +338,6 @@ namespace Phonon
STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info)
{
- QReadLocker locker(&m_lock);
if (!info) {
return E_POINTER;
}
@@ -361,14 +345,12 @@ namespace Phonon
info->dir = m_direction;
info->pFilter = m_parent;
m_parent->AddRef();
- qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2);
-
+ info->achName[0] = 0;
return S_OK;
}
STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir)
{
- QReadLocker locker(&m_lock);
if (!dir) {
return E_POINTER;
}
@@ -379,20 +361,18 @@ namespace Phonon
STDMETHODIMP QPin::QueryId(LPWSTR *id)
{
- QReadLocker locker(&m_lock);
if (!id) {
return E_POINTER;
}
- int nbBytes = (m_name.length()+1)*2;
- *id = static_cast<LPWSTR>(::CoTaskMemAlloc(nbBytes));
- qMemCopy(*id, m_name.utf16(), nbBytes);
+ *id = static_cast<LPWSTR>(::CoTaskMemAlloc(2));
+ *id[0] = 0;
return S_OK;
}
STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type)
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (!type) {
return E_POINTER;
}
@@ -439,7 +419,7 @@ namespace Phonon
STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (m_direction == PINDIR_OUTPUT && m_connected) {
//we deliver this downstream
m_connected->NewSegment(start, stop, rate);
@@ -470,7 +450,7 @@ namespace Phonon
freeMediaType(type);
return S_OK;
} else {
- setConnectedType(defaultMediaType());
+ setConnectedType(defaultMediaType);
freeMediaType(type);
}
}
@@ -520,7 +500,7 @@ namespace Phonon
void QPin::setConnectedType(const AM_MEDIA_TYPE &type)
{
- QWriteLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
//1st we free memory
freeMediaType(m_connectedType);
@@ -530,13 +510,13 @@ namespace Phonon
const AM_MEDIA_TYPE &QPin::connectedType() const
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
return m_connectedType;
}
void QPin::setConnected(IPin *pin)
{
- QWriteLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (pin) {
pin->AddRef();
}
@@ -548,7 +528,7 @@ namespace Phonon
IPin *QPin::connected(bool addref) const
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (addref && m_connected) {
m_connected->AddRef();
}
@@ -557,13 +537,12 @@ namespace Phonon
bool QPin::isFlushing() const
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
return m_flushing;
}
FILTER_STATE QPin::filterState() const
{
- QReadLocker locker(&m_lock);
FILTER_STATE fstate = State_Stopped;
m_parent->GetState(0, &fstate);
return fstate;
@@ -571,7 +550,7 @@ namespace Phonon
QVector<AM_MEDIA_TYPE> QPin::mediaTypes() const
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
return m_mediaTypes;
}
@@ -607,7 +586,7 @@ namespace Phonon
void QPin::setMemoryAllocator(IMemAllocator *alloc)
{
- QWriteLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (alloc) {
alloc->AddRef();
}
@@ -619,7 +598,7 @@ namespace Phonon
IMemAllocator *QPin::memoryAllocator(bool addref) const
{
- QReadLocker locker(&m_lock);
+ QMutexLocker locker(&m_mutex);
if (addref && m_memAlloc) {
m_memAlloc->AddRef();
}