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