MediaClient: Polish destructors
* Make Release() the only public way to destroy a connection.
This commit is contained in:
@@ -23,6 +23,11 @@ class BMediaConnection;
|
||||
class BMediaInput;
|
||||
class BMediaOutput;
|
||||
|
||||
// Private stuff
|
||||
class InputReleaser;
|
||||
class OutputReleaser;
|
||||
|
||||
|
||||
// BMediaClient is a general purpose class allowing to create any kind
|
||||
// of media_node. It automatically manage the expected behavior under
|
||||
// different run modes, and allow to specify the different capabilities needed.
|
||||
@@ -171,8 +176,8 @@ private:
|
||||
|
||||
bigtime_t fCurrentTime;
|
||||
|
||||
BObjectList<BMediaInput> fInputs;
|
||||
BObjectList<BMediaOutput> fOutputs;
|
||||
BObjectList<InputReleaser> fInputs;
|
||||
BObjectList<OutputReleaser> fOutputs;
|
||||
|
||||
media_connection_id fLastID;
|
||||
|
||||
|
||||
@@ -27,8 +27,6 @@ class BMediaClientNode;
|
||||
// to the connection B SendBuffer method.
|
||||
class BMediaConnection {
|
||||
public:
|
||||
virtual ~BMediaConnection();
|
||||
|
||||
const media_connection& Connection() const;
|
||||
BMediaClient* Client() const;
|
||||
|
||||
@@ -67,6 +65,7 @@ public:
|
||||
protected:
|
||||
BMediaConnection(
|
||||
media_connection_kinds kinds);
|
||||
virtual ~BMediaConnection();
|
||||
|
||||
// Those callbacks are shared between BMediaInput and BMediaOutput
|
||||
virtual void Connected(const media_format& format);
|
||||
@@ -84,6 +83,7 @@ protected:
|
||||
bigtime_t* max) const;
|
||||
|
||||
private:
|
||||
|
||||
void _ConnectionRegistered(BMediaClient* owner,
|
||||
media_connection_id id);
|
||||
|
||||
@@ -135,6 +135,8 @@ public:
|
||||
BMediaInput();
|
||||
|
||||
protected:
|
||||
virtual ~BMediaInput();
|
||||
|
||||
// Callbacks
|
||||
virtual status_t FormatChanged(const media_format& format);
|
||||
|
||||
@@ -168,6 +170,8 @@ public:
|
||||
bool IsEnabled() const;
|
||||
|
||||
protected:
|
||||
virtual ~BMediaOutput();
|
||||
|
||||
// Callbacks
|
||||
virtual status_t PrepareToConnect(media_format* format);
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
protected:
|
||||
BSimpleMediaConnection(
|
||||
media_connection_kinds kinds);
|
||||
virtual ~BSimpleMediaConnection();
|
||||
|
||||
process_hook fProcessHook;
|
||||
notify_hook fNotifyHook;
|
||||
@@ -129,6 +130,8 @@ public:
|
||||
BSimpleMediaInput();
|
||||
|
||||
protected:
|
||||
virtual ~BSimpleMediaInput();
|
||||
|
||||
virtual void Connected(const media_format& format);
|
||||
virtual void Disconnected();
|
||||
|
||||
@@ -141,6 +144,8 @@ public:
|
||||
BSimpleMediaOutput();
|
||||
|
||||
protected:
|
||||
virtual ~BSimpleMediaOutput();
|
||||
|
||||
virtual void Connected(const media_format& format);
|
||||
virtual void Disconnected();
|
||||
|
||||
|
||||
@@ -15,6 +15,77 @@
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
namespace BPrivate { namespace media {
|
||||
|
||||
|
||||
class ConnReleaser {
|
||||
public:
|
||||
ConnReleaser(BMediaConnection* conn)
|
||||
:
|
||||
fConn(conn) {}
|
||||
|
||||
virtual ~ConnReleaser()
|
||||
{
|
||||
fConn->Release();
|
||||
}
|
||||
|
||||
bool operator== (const ConnReleaser &c1)
|
||||
{
|
||||
return c1.fConn == this->fConn;
|
||||
}
|
||||
|
||||
protected:
|
||||
BMediaConnection* Obj() const
|
||||
{
|
||||
return fConn;
|
||||
}
|
||||
|
||||
private:
|
||||
BMediaConnection* fConn;
|
||||
};
|
||||
|
||||
|
||||
class InputReleaser : public ConnReleaser {
|
||||
public:
|
||||
InputReleaser(BMediaInput* input)
|
||||
:
|
||||
ConnReleaser(input) {}
|
||||
|
||||
BMediaInput* Obj() const
|
||||
{
|
||||
return dynamic_cast<BMediaInput*>(ConnReleaser::Obj());
|
||||
}
|
||||
|
||||
operator BMediaInput* () const
|
||||
{
|
||||
return Obj();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class OutputReleaser : public ConnReleaser {
|
||||
public:
|
||||
OutputReleaser(BMediaOutput* output)
|
||||
:
|
||||
ConnReleaser(output) {}
|
||||
|
||||
BMediaOutput* Obj() const
|
||||
{
|
||||
return dynamic_cast<BMediaOutput*>(ConnReleaser::Obj());
|
||||
}
|
||||
|
||||
operator BMediaOutput* () const
|
||||
{
|
||||
return Obj();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BMediaClient::BMediaClient(const char* name,
|
||||
media_type type, media_client_kinds kinds)
|
||||
:
|
||||
@@ -210,7 +281,7 @@ BMediaClient::InputAt(int32 index) const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return fInputs.ItemAt(index);
|
||||
return fInputs.ItemAt(index)->Obj();
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +290,7 @@ BMediaClient::OutputAt(int32 index) const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return fOutputs.ItemAt(index);
|
||||
return fOutputs.ItemAt(index)->Obj();
|
||||
}
|
||||
|
||||
|
||||
@@ -412,6 +483,10 @@ BMediaClient::_Deinit()
|
||||
|
||||
Disconnect();
|
||||
|
||||
// This will release the connections too.
|
||||
fInputs.MakeEmpty(true);
|
||||
fOutputs.MakeEmpty(true);
|
||||
|
||||
fNode->Release();
|
||||
}
|
||||
|
||||
@@ -421,7 +496,7 @@ BMediaClient::_AddInput(BMediaInput* input)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
fInputs.AddItem(input);
|
||||
fInputs.AddItem(new InputReleaser(input));
|
||||
}
|
||||
|
||||
|
||||
@@ -430,7 +505,7 @@ BMediaClient::_AddOutput(BMediaOutput* output)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
fOutputs.AddItem(output);
|
||||
fOutputs.AddItem(new OutputReleaser(output));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -216,6 +216,12 @@ BMediaInput::BMediaInput()
|
||||
}
|
||||
|
||||
|
||||
BMediaInput::~BMediaInput()
|
||||
{
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaInput::FormatChanged(const media_format& format)
|
||||
{
|
||||
@@ -263,6 +269,12 @@ BMediaOutput::BMediaOutput()
|
||||
}
|
||||
|
||||
|
||||
BMediaOutput::~BMediaOutput()
|
||||
{
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BMediaOutput::IsEnabled() const
|
||||
{
|
||||
|
||||
@@ -123,6 +123,12 @@ BSimpleMediaConnection::BSimpleMediaConnection(media_connection_kinds kinds)
|
||||
}
|
||||
|
||||
|
||||
BSimpleMediaConnection::~BSimpleMediaConnection()
|
||||
{
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BSimpleMediaConnection::SetHooks(process_hook processHook,
|
||||
notify_hook notifyHook, void* cookie)
|
||||
@@ -153,6 +159,12 @@ BSimpleMediaInput::BSimpleMediaInput()
|
||||
}
|
||||
|
||||
|
||||
BSimpleMediaInput::~BSimpleMediaInput()
|
||||
{
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BSimpleMediaInput::Connected(const media_format& format)
|
||||
{
|
||||
@@ -192,6 +204,12 @@ BSimpleMediaOutput::BSimpleMediaOutput()
|
||||
}
|
||||
|
||||
|
||||
BSimpleMediaOutput::~BSimpleMediaOutput()
|
||||
{
|
||||
CALLED();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BSimpleMediaOutput::FormatProposal(media_format* format)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user