Unregister SystemTimeSource when the media_addon_server quit, better error checking and explicit initialization/deletion for some attributes
Signed-off-by: Jérôme Duval <[email protected]>
This commit is contained in:
committed by
Jérôme Duval
parent
5a1e452ba2
commit
49f0011c1e
@@ -121,6 +121,7 @@ private:
|
||||
thread_id fControlThread;
|
||||
bool fStartup;
|
||||
bool fStartupSound;
|
||||
SystemTimeSource* fSystemTimeSource;
|
||||
};
|
||||
|
||||
|
||||
@@ -203,8 +204,11 @@ MediaAddonServer::MonitorHandler::AddOnDisabled(const add_on_entry_info* info)
|
||||
MediaAddonServer::MediaAddonServer(const char* signature)
|
||||
:
|
||||
BApplication(signature),
|
||||
fMonitorHandler(NULL),
|
||||
fPulseRunner(NULL),
|
||||
fStartup(true),
|
||||
fStartupSound(true)
|
||||
fStartupSound(true),
|
||||
fSystemTimeSource(NULL)
|
||||
{
|
||||
CALLED();
|
||||
fMediaRoster = BMediaRoster::Roster();
|
||||
@@ -227,14 +231,15 @@ MediaAddonServer::~MediaAddonServer()
|
||||
for (; iterator != fFileMap.end(); iterator++)
|
||||
gDormantNodeManager->UnregisterAddOn(iterator->second);
|
||||
|
||||
// TODO: unregister system time source
|
||||
delete fMonitorHandler;
|
||||
delete fPulseRunner;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MediaAddonServer::ReadyToRun()
|
||||
{
|
||||
if (!be_roster->IsRunning("application/x-vnd.Be.media-server")) {
|
||||
if (!be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
|
||||
// the media server is not running, let's quit
|
||||
fprintf(stderr, "The media_server is not running!\n");
|
||||
Quit();
|
||||
@@ -249,17 +254,17 @@ MediaAddonServer::ReadyToRun()
|
||||
|
||||
// The very first thing to do is to create the system time source,
|
||||
// register it with the server, and make it the default SYSTEM_TIME_SOURCE
|
||||
BMediaNode *timeSource = new SystemTimeSource;
|
||||
status_t result = fMediaRoster->RegisterNode(timeSource);
|
||||
fSystemTimeSource = new SystemTimeSource();
|
||||
status_t result = fMediaRoster->RegisterNode(fSystemTimeSource);
|
||||
if (result != B_OK) {
|
||||
fprintf(stderr, "Can't register system time source : %s\n",
|
||||
strerror(result));
|
||||
debugger("Can't register system time source");
|
||||
}
|
||||
|
||||
if (timeSource->ID() != NODE_SYSTEM_TIMESOURCE_ID)
|
||||
if (fSystemTimeSource->ID() != NODE_SYSTEM_TIMESOURCE_ID)
|
||||
debugger("System time source got wrong node ID");
|
||||
media_node node = timeSource->Node();
|
||||
media_node node = fSystemTimeSource->Node();
|
||||
result = MediaRosterEx(fMediaRoster)->SetNode(SYSTEM_TIME_SOURCE, &node);
|
||||
if (result != B_OK)
|
||||
debugger("Can't setup system time source as default");
|
||||
@@ -277,6 +282,10 @@ MediaAddonServer::ReadyToRun()
|
||||
// the monitor handler needs a pulse to check if add-ons are ready
|
||||
fPulseRunner = new BMessageRunner(fMonitorHandler, &pulse, 1000000LL);
|
||||
|
||||
result = fPulseRunner->InitCheck();
|
||||
if (result != B_OK)
|
||||
ERROR("Can't create the pulse runner");
|
||||
|
||||
fMonitorHandler->AddAddOnDirectories("media");
|
||||
|
||||
#ifdef USER_ADDON_PATH
|
||||
@@ -313,6 +322,19 @@ MediaAddonServer::QuitRequested()
|
||||
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
|
||||
_DestroyInstantiatedFlavors(iterator->second);
|
||||
|
||||
// the System timesource should be removed before we quit the roster
|
||||
if (fSystemTimeSource != NULL &&
|
||||
be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
|
||||
status_t result = fMediaRoster->UnregisterNode(fSystemTimeSource);
|
||||
if (result != B_OK) {
|
||||
fprintf(stderr, "Error removing the system time source : %s\n",
|
||||
strerror(result));
|
||||
ERROR("Can't remove the system time source");
|
||||
}
|
||||
fSystemTimeSource->Release();
|
||||
fSystemTimeSource = NULL;
|
||||
}
|
||||
|
||||
BMediaRoster::CurrentRoster()->Lock();
|
||||
BMediaRoster::CurrentRoster()->Quit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user