summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-24 13:53:58 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-24 14:41:41 +0200
commit5253fce55b1c09051635969661e5576f1bdb2b5b (patch)
tree1bf52abe3a66c9836e46fbb1f17f43a964076028
parent262cc0fa04b4e666551fe2051ef83a4913129d10 (diff)
Phonon/ds9: refactor to prepare some improvements in the usage of mutex
-rw-r--r--src/3rdparty/phonon/ds9/qmeminputpin.cpp100
-rw-r--r--src/3rdparty/phonon/ds9/qmeminputpin.h9
-rw-r--r--src/3rdparty/phonon/ds9/qpin.cpp3
-rw-r--r--src/3rdparty/phonon/ds9/qpin.h2
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_soft.cpp2
-rw-r--r--src/3rdparty/phonon/ds9/volumeeffect.cpp5
6 files changed, 35 insertions, 86 deletions
diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
index 630cfb447..a21fbe71d 100644
--- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp
+++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
@@ -28,8 +28,8 @@ namespace Phonon
namespace DS9
{
- QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform) :
- QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform)
+ QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform, QPin *output) :
+ QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform), m_output(output)
{
}
@@ -66,11 +66,9 @@ namespace Phonon
{
//this allows to serialize with Receive calls
QMutexLocker locker(&m_mutexReceive);
- for(int i = 0; i < m_outputs.count(); ++i) {
- IPin *conn = m_outputs.at(i)->connected();
- if (conn) {
- conn->EndOfStream();
- }
+ IPin *conn = m_output ? m_output->connected() : 0;
+ if (conn) {
+ conn->EndOfStream();
}
return S_OK;
}
@@ -78,11 +76,9 @@ namespace Phonon
STDMETHODIMP QMemInputPin::BeginFlush()
{
//pass downstream
- for(int i = 0; i < m_outputs.count(); ++i) {
- IPin *conn = m_outputs.at(i)->connected();
- if (conn) {
- conn->BeginFlush();
- }
+ IPin *conn = m_output ? m_output->connected() : 0;
+ if (conn) {
+ conn->BeginFlush();
}
QMutexLocker locker(&m_mutex);
m_flushing = true;
@@ -92,11 +88,9 @@ namespace Phonon
STDMETHODIMP QMemInputPin::EndFlush()
{
//pass downstream
- for(int i = 0; i < m_outputs.count(); ++i) {
- IPin *conn = m_outputs.at(i)->connected();
- if (conn) {
- conn->EndFlush();
- }
+ IPin *conn = m_output ? m_output->connected() : 0;
+ if (conn) {
+ conn->EndFlush();
}
QMutexLocker locker(&m_mutex);
m_flushing = false;
@@ -105,9 +99,8 @@ namespace Phonon
STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
{
- for(int i = 0; i < m_outputs.count(); ++i) {
- m_outputs.at(i)->NewSegment(start, stop, rate);
- }
+ if (m_output)
+ m_output->NewSegment(start, stop, rate);
return S_OK;
}
@@ -119,14 +112,9 @@ namespace Phonon
if (hr == S_OK &&
mt->majortype != MEDIATYPE_NULL &&
mt->subtype != MEDIASUBTYPE_NULL &&
- mt->formattype != GUID_NULL) {
- //we tell the output pins that they should connect with this type
- for(int i = 0; i < m_outputs.count(); ++i) {
- hr = m_outputs.at(i)->setAcceptedMediaType(connectedType());
- if (FAILED(hr)) {
- break;
- }
- }
+ mt->formattype != GUID_NULL && m_output) {
+ //we tell the output pin that it should connect with this type
+ hr = m_output->setAcceptedMediaType(connectedType());
}
return hr;
}
@@ -158,12 +146,9 @@ namespace Phonon
setMemoryAllocator(alloc);
- for(int i = 0; i < m_outputs.count(); ++i) {
- IPin *pin = m_outputs.at(i)->connected();
- if (pin) {
- ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
- input->NotifyAllocator(alloc, m_shouldDuplicateSamples);
- }
+ if (m_output) {
+ ComPointer<IMemInputPin> input(m_output, IID_IMemInputPin);
+ input->NotifyAllocator(alloc, m_shouldDuplicateSamples);
}
return S_OK;
@@ -202,22 +187,18 @@ namespace Phonon
}
}
- for (int i = 0; i < m_outputs.count(); ++i) {
- QPin *current = m_outputs.at(i);
+ if (m_output) {
IMediaSample *outSample = m_shouldDuplicateSamples ?
- duplicateSampleForOutput(sample, current->memoryAllocator())
+ duplicateSampleForOutput(sample, m_output->memoryAllocator())
: sample;
if (m_shouldDuplicateSamples) {
m_parent->processSample(outSample);
}
- IPin *pin = current->connected();
- if (pin) {
- ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
- if (input) {
- input->Receive(outSample);
- }
+ ComPointer<IMemInputPin> input(m_output->connected(), IID_IMemInputPin);
+ if (input) {
+ input->Receive(outSample);
}
if (m_shouldDuplicateSamples) {
@@ -248,39 +229,16 @@ namespace Phonon
STDMETHODIMP QMemInputPin::ReceiveCanBlock()
{
- //we test the output to see if they can block
- for(int i = 0; i < m_outputs.count(); ++i) {
- IPin *input = m_outputs.at(i)->connected();
- if (input) {
- ComPointer<IMemInputPin> meminput(input, IID_IMemInputPin);
- if (meminput && meminput->ReceiveCanBlock() != S_FALSE) {
- return S_OK;
- }
+ //we test the output to see if it can block
+ if (m_output) {
+ ComPointer<IMemInputPin> meminput(m_output->connected(), IID_IMemInputPin);
+ if (meminput && meminput->ReceiveCanBlock() != S_FALSE) {
+ return S_OK;
}
}
return S_FALSE;
}
- //addition
- //this should be used by the filter to tell its input pins to which output they should route the samples
-
- void QMemInputPin::addOutput(QPin *output)
- {
- QMutexLocker locker(&m_mutex);
- m_outputs += output;
- }
-
- void QMemInputPin::removeOutput(QPin *output)
- {
- QMutexLocker locker(&m_mutex);
- m_outputs.removeOne(output);
- }
-
- QList<QPin*> QMemInputPin::outputs() const
- {
- QMutexLocker locker(&m_mutex);
- return m_outputs;
- }
ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const
{
diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.h b/src/3rdparty/phonon/ds9/qmeminputpin.h
index c44972198..d74c451ed 100644
--- a/src/3rdparty/phonon/ds9/qmeminputpin.h
+++ b/src/3rdparty/phonon/ds9/qmeminputpin.h
@@ -37,7 +37,7 @@ namespace Phonon
class QMemInputPin : public QPin, public IMemInputPin
{
public:
- QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform);
+ QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform, QPin *output);
~QMemInputPin();
//reimplementation from IUnknown
@@ -60,18 +60,13 @@ namespace Phonon
STDMETHODIMP ReceiveMultiple(IMediaSample **,long,long *);
STDMETHODIMP ReceiveCanBlock();
- //addition
- void addOutput(QPin *output);
- void removeOutput(QPin *output);
- QList<QPin*> outputs() const;
-
private:
IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *);
ALLOCATOR_PROPERTIES getDefaultAllocatorProperties() const;
bool m_shouldDuplicateSamples;
const bool m_transform; //defines if the pin is transforming the samples
- QList<QPin*> m_outputs;
+ QPin* const m_output;
QMutex m_mutexReceive;
};
}
diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp
index 55c952c30..8653db977 100644
--- a/src/3rdparty/phonon/ds9/qpin.cpp
+++ b/src/3rdparty/phonon/ds9/qpin.cpp
@@ -338,7 +338,6 @@ namespace Phonon
STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info)
{
- QMutexLocker locker(&m_mutex);
if (!info) {
return E_POINTER;
}
@@ -352,7 +351,6 @@ namespace Phonon
STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir)
{
- QMutexLocker locker(&m_mutex);
if (!dir) {
return E_POINTER;
}
@@ -363,7 +361,6 @@ namespace Phonon
STDMETHODIMP QPin::QueryId(LPWSTR *id)
{
- QMutexLocker locker(&m_mutex);
if (!id) {
return E_POINTER;
}
diff --git a/src/3rdparty/phonon/ds9/qpin.h b/src/3rdparty/phonon/ds9/qpin.h
index 9af6077ae..280ad619c 100644
--- a/src/3rdparty/phonon/ds9/qpin.h
+++ b/src/3rdparty/phonon/ds9/qpin.h
@@ -86,7 +86,7 @@ namespace Phonon
protected:
//this can be used by sub-classes
mutable QMutex m_mutex;
- QBaseFilter *m_parent;
+ QBaseFilter * const m_parent;
bool m_flushing;
private:
diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
index cf5ce9611..82d62359a 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
+++ b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
@@ -365,7 +365,7 @@ namespace Phonon
{
public:
VideoRendererSoftPin(VideoRendererSoftFilter *parent) :
- QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/),
+ QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0),
m_renderer(parent)
{
}
diff --git a/src/3rdparty/phonon/ds9/volumeeffect.cpp b/src/3rdparty/phonon/ds9/volumeeffect.cpp
index b9a5fcea5..a93b07430 100644
--- a/src/3rdparty/phonon/ds9/volumeeffect.cpp
+++ b/src/3rdparty/phonon/ds9/volumeeffect.cpp
@@ -76,7 +76,7 @@ namespace Phonon
class VolumeMemInputPin : public QMemInputPin
{
public:
- VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt) : QMemInputPin(parent, mt, true /*transform*/)
+ VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output)
{
}
@@ -139,8 +139,7 @@ namespace Phonon
//then creating the input
mt << audioMediaType();
- m_input = new VolumeMemInputPin(this, mt);
- m_input->addOutput(m_output); //make the connection here
+ m_input = new VolumeMemInputPin(this, mt, m_output);
}
void VolumeEffectFilter::treatOneSamplePerChannel(BYTE **buffer, int sampleSize, int channelCount, int frequency)