Create the port pool in MediaRosterUndertaker
Follow up to #15135, which created a regression, apps would crash if using the port pool before creating a BMediaRoster instance. Now the port pool is entirely managed by the MediaRosterUndertaker, which is less confusing. Fixes the media_addon_server crash on shutdown for me as well, but I don't remember why (I had studied the code and came to the conclusion that this should fix it, but I don't remember the reasoning). Fixes #15263, and regressions for apps using the port pool before they instanciate the BMediaRoster. Change-Id: I887dbc590d8ee9de391b6eae0206944bfe99325f Reviewed-on: https://review.haiku-os.org/c/haiku/+/1897 Reviewed-by: Axel Dörfler <[email protected]>
This commit is contained in:
committed by
Axel Dörfler
parent
9ecbb6ada1
commit
083314c2cb
@@ -115,8 +115,17 @@ static BLocker sInitLocker("BMediaRoster::Roster locker");
|
|||||||
static List<LocalNode> sRegisteredNodes;
|
static List<LocalNode> sRegisteredNodes;
|
||||||
|
|
||||||
|
|
||||||
|
// This class takes care of all static initialization and destruction of
|
||||||
|
// libmedia objects. It guarantees that things are created and destroyed in
|
||||||
|
// the correct order, as well as performing some "garbage collecting" by being
|
||||||
|
// destructed automatically on application exit.
|
||||||
class MediaRosterUndertaker {
|
class MediaRosterUndertaker {
|
||||||
public:
|
public:
|
||||||
|
MediaRosterUndertaker()
|
||||||
|
{
|
||||||
|
gPortPool = new PortPool();
|
||||||
|
}
|
||||||
|
|
||||||
~MediaRosterUndertaker()
|
~MediaRosterUndertaker()
|
||||||
{
|
{
|
||||||
BAutolock _(sInitLocker);
|
BAutolock _(sInitLocker);
|
||||||
@@ -169,9 +178,6 @@ BMediaRosterEx::BMediaRosterEx(status_t* _error)
|
|||||||
{
|
{
|
||||||
gDormantNodeManager = new DormantNodeManager();
|
gDormantNodeManager = new DormantNodeManager();
|
||||||
gTimeSourceObjectManager = new TimeSourceObjectManager();
|
gTimeSourceObjectManager = new TimeSourceObjectManager();
|
||||||
gPortPool = new PortPool();
|
|
||||||
// This is created here but deleted in the MediaRosterUndertaker because
|
|
||||||
// otherwise there are segfaults trying to send final quit messages.
|
|
||||||
|
|
||||||
*_error = BuildConnections();
|
*_error = BuildConnections();
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace media {
|
|||||||
|
|
||||||
|
|
||||||
PortPool* gPortPool;
|
PortPool* gPortPool;
|
||||||
// initialized by BMediaRosterEx, deleted by MediaRosterUndertaker.
|
// managed by MediaRosterUndertaker.
|
||||||
|
|
||||||
|
|
||||||
PortPool::PortPool()
|
PortPool::PortPool()
|
||||||
|
|||||||
Reference in New Issue
Block a user