MediaConnection: Implement auto release
This commit is contained in:
@@ -167,6 +167,9 @@ private:
|
|||||||
status_t _ConnectOutput(BMediaInput* input,
|
status_t _ConnectOutput(BMediaInput* input,
|
||||||
const media_connection& output);
|
const media_connection& output);
|
||||||
|
|
||||||
|
status_t _DisconnectConnection(BMediaConnection* conn);
|
||||||
|
status_t _ReleaseConnection(BMediaConnection* conn);
|
||||||
|
|
||||||
status_t fInitErr;
|
status_t fInitErr;
|
||||||
|
|
||||||
media_client fClient;
|
media_client fClient;
|
||||||
|
|||||||
@@ -72,13 +72,14 @@ private:
|
|||||||
const media_source& _Source() const;
|
const media_source& _Source() const;
|
||||||
const media_destination& _Destination() const;
|
const media_destination& _Destination() const;
|
||||||
|
|
||||||
|
media_node _Node() const;
|
||||||
media_node _RemoteNode() const;
|
media_node _RemoteNode() const;
|
||||||
|
|
||||||
media_connection_id id;
|
media_connection_id id;
|
||||||
|
|
||||||
media_client client;
|
media_client client;
|
||||||
// TODO really needed?
|
|
||||||
media_client remote_client;
|
media_node remote_node;
|
||||||
|
|
||||||
media_source source;
|
media_source source;
|
||||||
media_destination destination;
|
media_destination destination;
|
||||||
|
|||||||
@@ -576,6 +576,47 @@ BMediaClient::_ConnectOutput(BMediaInput* input,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMediaClient::_DisconnectConnection(BMediaConnection* conn)
|
||||||
|
{
|
||||||
|
if (conn->Client() != this)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
const media_connection& handle = conn->Connection();
|
||||||
|
if (handle.IsInput()) {
|
||||||
|
return BMediaRoster::CurrentRoster()->Disconnect(
|
||||||
|
handle._RemoteNode().node, handle._Source(),
|
||||||
|
handle._Node().node, handle._Destination());
|
||||||
|
} else {
|
||||||
|
return BMediaRoster::CurrentRoster()->Disconnect(
|
||||||
|
handle._Node().node, handle._Source(),
|
||||||
|
handle._RemoteNode().node, handle._Destination());
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BMediaClient::_ReleaseConnection(BMediaConnection* conn)
|
||||||
|
{
|
||||||
|
if (conn->Client() != this)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
if (conn->Connection().IsInput()) {
|
||||||
|
InputReleaser obj = InputReleaser(dynamic_cast<BMediaInput*>(conn));
|
||||||
|
fInputs.RemoveItem(&obj);
|
||||||
|
return B_OK;
|
||||||
|
} else {
|
||||||
|
OutputReleaser obj = OutputReleaser(dynamic_cast<BMediaOutput*>(conn));
|
||||||
|
fOutputs.RemoveItem(&obj);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BMediaClient::_ReservedMediaClient0() {}
|
void BMediaClient::_ReservedMediaClient0() {}
|
||||||
void BMediaClient::_ReservedMediaClient1() {}
|
void BMediaClient::_ReservedMediaClient1() {}
|
||||||
void BMediaClient::_ReservedMediaClient2() {}
|
void BMediaClient::_ReservedMediaClient2() {}
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ media_client::Kinds() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const media_client&
|
||||||
|
media_connection::Client() const
|
||||||
|
{
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
media_connection_id
|
media_connection_id
|
||||||
media_connection::Id() const
|
media_connection::Id() const
|
||||||
{
|
{
|
||||||
@@ -92,5 +99,12 @@ media_connection::_Destination() const
|
|||||||
media_node
|
media_node
|
||||||
media_connection::_RemoteNode() const
|
media_connection::_RemoteNode() const
|
||||||
{
|
{
|
||||||
return remote_client.node;
|
return remote_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
media_node
|
||||||
|
media_connection::_Node() const
|
||||||
|
{
|
||||||
|
return client.node;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ BMediaConnection::Connection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMediaClient*
|
||||||
|
BMediaConnection::Client() const
|
||||||
|
{
|
||||||
|
return fOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMediaConnection::HasBinding() const
|
BMediaConnection::HasBinding() const
|
||||||
{
|
{
|
||||||
@@ -90,10 +97,14 @@ BMediaConnection::Disconnect()
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
status_t ret = fOwner->_DisconnectConnection(this);
|
||||||
|
if (ret != B_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
delete fBufferGroup;
|
delete fBufferGroup;
|
||||||
fBufferGroup = NULL;
|
fBufferGroup = NULL;
|
||||||
|
|
||||||
return B_OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +113,12 @@ BMediaConnection::Release()
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
return B_OK;
|
status_t ret = fOwner->_ReleaseConnection(this);
|
||||||
|
if (ret != B_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user