BMediaRoster: Fix initialization and destruction
* Improve consistency by adding a BMediaRosterEx destructor and using it for the specular functionality of ctor instead to use the father's class destructor. * Avoid double initialization of MediaInitializer that becomes MediaRosterUndertaker. * Remove superfluos call to BMediaRoster::Quit() in media_addon_server.
This commit is contained in:
parent
6cd18b575c
commit
e57acc3a99
@ -35,6 +35,7 @@ class BMediaRosterEx : public BMediaRoster
|
||||
{
|
||||
public:
|
||||
BMediaRosterEx(status_t* out_error);
|
||||
virtual ~BMediaRosterEx();
|
||||
|
||||
status_t SaveNodeConfiguration(BMediaNode* node);
|
||||
status_t LoadNodeConfiguration(media_addon_id addonid,
|
||||
|
@ -75,14 +75,10 @@ namespace BPrivate {
|
||||
namespace media {
|
||||
|
||||
|
||||
class MediaInitializer {
|
||||
// This class is provided to ensure the BMediaRoster is quit.
|
||||
class MediaRosterUndertaker {
|
||||
public:
|
||||
MediaInitializer()
|
||||
{
|
||||
InitDataExchange();
|
||||
}
|
||||
|
||||
~MediaInitializer()
|
||||
~MediaRosterUndertaker()
|
||||
{
|
||||
if (BMediaRoster::CurrentRoster() != NULL) {
|
||||
BMediaRoster::CurrentRoster()->Lock();
|
||||
@ -98,7 +94,7 @@ public:
|
||||
using namespace BPrivate::media;
|
||||
|
||||
|
||||
static MediaInitializer sInitializer;
|
||||
static MediaRosterUndertaker sUndertaker;
|
||||
|
||||
|
||||
BMediaRosterEx::BMediaRosterEx(status_t* _error)
|
||||
@ -125,6 +121,24 @@ BMediaRosterEx::BMediaRosterEx(status_t* _error)
|
||||
}
|
||||
|
||||
|
||||
BMediaRosterEx::~BMediaRosterEx()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
delete gTimeSourceObjectManager;
|
||||
delete gDormantNodeManager;
|
||||
|
||||
// unregister this application with the media server
|
||||
server_unregister_app_request request;
|
||||
server_unregister_app_reply reply;
|
||||
request.team = BPrivate::current_team();
|
||||
QueryServer(SERVER_UNREGISTER_APP, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
|
||||
BPrivate::SharedBufferList::Invalidate();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaRosterEx::SaveNodeConfiguration(BMediaNode* node)
|
||||
{
|
||||
@ -3348,18 +3362,6 @@ BMediaRoster::~BMediaRoster()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
delete gTimeSourceObjectManager;
|
||||
delete gDormantNodeManager;
|
||||
|
||||
// unregister this application with the media server
|
||||
server_unregister_app_request request;
|
||||
server_unregister_app_reply reply;
|
||||
request.team = BPrivate::current_team();
|
||||
QueryServer(SERVER_UNREGISTER_APP, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
|
||||
BPrivate::SharedBufferList::Invalidate();
|
||||
|
||||
// Unset the global instance pointer, the destructor is also called
|
||||
// if a client app calls Lock(); and Quit(); directly.
|
||||
sDefaultInstance = NULL;
|
||||
|
@ -338,9 +338,6 @@ MediaAddonServer::QuitRequested()
|
||||
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
|
||||
_PutAddonIfPossible(iterator->second);
|
||||
|
||||
BMediaRoster::CurrentRoster()->Lock();
|
||||
BMediaRoster::CurrentRoster()->Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user