added shutdown_media_server and start_media_server into libmedia.so, based on an older implementation from svn history, but modified and bugfixed

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16367 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen
2006-02-12 18:56:00 +00:00
parent 9a7fabb66c
commit 3d6c711604
2 changed files with 99 additions and 24 deletions
-20
View File
@@ -35,23 +35,3 @@ const uint8 B_I_BEAM_CURSOR[] = {
0xf, 0xc0, 0x7, 0x80, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0,
0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x3, 0x0, 0x7, 0x80, 0xf, 0xc0,
};
// ToDo: find a better home for these (what's wrong with libmedia.so?)
// ToDo: implement shutdown|launch_media_server()
status_t
shutdown_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char * message, void * cookie),
void * cookie)
{
return B_OK;
}
status_t
launch_media_server(uint32 flags)
{
return B_ERROR;
}
+99 -4
View File
@@ -1026,12 +1026,107 @@ struct buffer_clone_info
*************************************************************/
// shutdown_media_server()
// is provided by libbe.so and thus not implemented here
// shutdown_media_server() and launch_media_server()
// are provided by libbe.so in BeOS R5
status_t
shutdown_media_server(bigtime_t timeout,
bool (*progress)(int stage, const char * message, void * cookie),
void * cookie)
{
BMessage msg(B_QUIT_REQUESTED);
BMessage reply;
status_t err;
if ((err = msg.AddBool("be:_user_request", true)) != B_OK)
return err;
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
BMessenger messenger(B_MEDIA_SERVER_SIGNATURE);
progress(10, "Telling media_server to quit.", cookie);
if ((err = messenger.SendMessage(&msg, &reply, 2000000, 2000000)) != B_OK)
return err;
int32 rv;
if ((err = reply.FindInt32("error", &rv)) == B_OK && rv != B_OK)
return rv;
}
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE);
progress(20, "Telling media_addon_server to quit.", cookie);
if ((err = messenger.SendMessage(&msg, &reply, 2000000, 2000000)) != B_OK)
return err;
int32 rv;
if ((err = reply.FindInt32("error", &rv)) == B_OK && rv != B_OK)
return rv;
}
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
progress(40, "Waiting for media_server to quit.", cookie);
snooze(200000);
}
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
progress(50, "Waiting for media_addon_server to quit.", cookie);
snooze(200000);
}
progress(70, "Cleaning Up.", cookie);
snooze(1000000);
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
}
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
}
progress(100, "Done Shutting Down.", cookie);
snooze(1000000);
return B_OK;
}
// launch_media_server()
// is provided by libbe.so and thus not implemented here
status_t
launch_media_server(uint32 flags)
{
status_t err;
if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE))
return B_ALREADY_RUNNING;
if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
snooze(1000000);
}
err = be_roster->Launch(B_MEDIA_SERVER_SIGNATURE);
if (err != B_OK)
return err;
err = B_MEDIA_SYSTEM_FAILURE;
for (int i = 0; i < 15; i++) {
snooze(2000000);
BMessage msg(1); // this is a hack
BMessage reply;
BMessenger messenger(B_MEDIA_ADDON_SERVER_SIGNATURE);
if (messenger.IsValid()) {
messenger.SendMessage(&msg, &reply, 2000000, 2000000);
err = B_OK;
break;
}
}
return err;
}
/*************************************************************