Media service restart is now using BNotification. Fixes 8171.
This commit is contained in:
committed by
Adrien Destugues
parent
c038f26da8
commit
aa47adf6e0
@@ -25,6 +25,7 @@
|
|||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
#include <MediaTheme.h>
|
#include <MediaTheme.h>
|
||||||
|
#include <Notification.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
@@ -161,7 +162,6 @@ MediaWindow::MediaWindow(BRect frame)
|
|||||||
fAudioOutputs(5, true),
|
fAudioOutputs(5, true),
|
||||||
fVideoInputs(5, true),
|
fVideoInputs(5, true),
|
||||||
fVideoOutputs(5, true),
|
fVideoOutputs(5, true),
|
||||||
fAlert(NULL),
|
|
||||||
fInitCheck(B_OK)
|
fInitCheck(B_OK)
|
||||||
{
|
{
|
||||||
_InitWindow();
|
_InitWindow();
|
||||||
@@ -314,17 +314,18 @@ MediaWindow::MessageReceived(BMessage* message)
|
|||||||
case B_SOME_APP_LAUNCHED:
|
case B_SOME_APP_LAUNCHED:
|
||||||
{
|
{
|
||||||
PRINT_OBJECT(*message);
|
PRINT_OBJECT(*message);
|
||||||
if (fAlert == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
BString mimeSig;
|
BString mimeSig;
|
||||||
if (message->FindString("be:signature", &mimeSig) == B_OK
|
if (message->FindString("be:signature", &mimeSig) == B_OK
|
||||||
&& (mimeSig == "application/x-vnd.Be.addon-host"
|
&& (mimeSig == "application/x-vnd.Be.addon-host"
|
||||||
|| mimeSig == "application/x-vnd.Be.media-server")) {
|
|| mimeSig == "application/x-vnd.Be.media-server")) {
|
||||||
fAlert->Lock();
|
BNotification notificationPopup(B_PROGRESS_NOTIFICATION);
|
||||||
fAlert->TextView()->SetText(
|
notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
|
||||||
|
notificationPopup.SetTitle(B_TRANSLATE("Media Service"));
|
||||||
|
notificationPopup.SetProgress(0.5);
|
||||||
|
notificationPopup.SetContent(
|
||||||
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
||||||
fAlert->Unlock();
|
notificationPopup.Send();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -418,10 +419,13 @@ MediaWindow::_InitMedia(bool first)
|
|||||||
if (alert->Go() == 0)
|
if (alert->Go() == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fAlert = new MediaAlert(BRect(0, 0, 300, 60), "restart_alert",
|
BNotification notificationPopup(B_PROGRESS_NOTIFICATION);
|
||||||
B_TRANSLATE("Restarting media services\nStarting media server"
|
notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
|
||||||
B_UTF8_ELLIPSIS "\n"));
|
notificationPopup.SetTitle(B_TRANSLATE("Media Service"));
|
||||||
fAlert->Show();
|
notificationPopup.SetProgress(0.5);
|
||||||
|
notificationPopup.SetContent(
|
||||||
|
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
||||||
|
notificationPopup.Send();
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
@@ -435,11 +439,14 @@ MediaWindow::_InitMedia(bool first)
|
|||||||
&& fListView->ItemAt(0)->IsSelected())
|
&& fListView->ItemAt(0)->IsSelected())
|
||||||
isVideoSelected = false;
|
isVideoSelected = false;
|
||||||
|
|
||||||
if ((!first || (first && err) ) && fAlert) {
|
if (!first || (first && err) ) {
|
||||||
BAutolock locker(fAlert);
|
BNotification notificationPopup(B_PROGRESS_NOTIFICATION);
|
||||||
if (locker.IsLocked())
|
notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
|
||||||
fAlert->TextView()->SetText(
|
notificationPopup.SetTitle(B_TRANSLATE("Media Service"));
|
||||||
B_TRANSLATE("Ready for use" B_UTF8_ELLIPSIS));
|
notificationPopup.SetProgress(1.0);
|
||||||
|
notificationPopup.SetContent(
|
||||||
|
B_TRANSLATE("Ready for use" B_UTF8_ELLIPSIS));
|
||||||
|
notificationPopup.Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fListView->CountItems() > 0)
|
while (fListView->CountItems() > 0)
|
||||||
@@ -517,12 +524,6 @@ MediaWindow::_InitMedia(bool first)
|
|||||||
else
|
else
|
||||||
fListView->Select(fListView->IndexOf(audio));
|
fListView->Select(fListView->IndexOf(audio));
|
||||||
|
|
||||||
if (fAlert != NULL) {
|
|
||||||
snooze(800000);
|
|
||||||
fAlert->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
|
||||||
fAlert = NULL;
|
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -648,23 +649,25 @@ status_t
|
|||||||
MediaWindow::_RestartMediaServices(void* data)
|
MediaWindow::_RestartMediaServices(void* data)
|
||||||
{
|
{
|
||||||
MediaWindow* window = (MediaWindow*)data;
|
MediaWindow* window = (MediaWindow*)data;
|
||||||
window->fAlert = new MediaAlert(BRect(0, 0, 300, 60),
|
|
||||||
"restart_alert", B_TRANSLATE(
|
BNotification notificationPopup(B_PROGRESS_NOTIFICATION);
|
||||||
"Restarting media services\nShutting down media server\n"));
|
notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
|
||||||
|
notificationPopup.SetTitle(B_TRANSLATE("Media Service"));
|
||||||
window->fAlert->Show();
|
notificationPopup.SetContent( B_TRANSLATE("Shutting down media server"));
|
||||||
|
|
||||||
shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::_UpdateProgress,
|
shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::_UpdateProgress,
|
||||||
window->fAlert);
|
NULL);
|
||||||
|
|
||||||
|
notificationPopup.SetContent(
|
||||||
|
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
||||||
|
notificationPopup.SetProgress(0.5);
|
||||||
|
notificationPopup.Send();
|
||||||
|
|
||||||
{
|
|
||||||
BAutolock locker(window->fAlert);
|
|
||||||
if (locker.IsLocked())
|
|
||||||
window->fAlert->TextView()->SetText(
|
|
||||||
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
|
||||||
}
|
|
||||||
launch_media_server();
|
launch_media_server();
|
||||||
|
|
||||||
|
notificationPopup.SetProgress(1);
|
||||||
|
notificationPopup.Send();
|
||||||
|
|
||||||
return window->PostMessage(ML_INIT_MEDIA);
|
return window->PostMessage(ML_INIT_MEDIA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,7 +675,10 @@ MediaWindow::_RestartMediaServices(void* data)
|
|||||||
bool
|
bool
|
||||||
MediaWindow::_UpdateProgress(int stage, const char* message, void* cookie)
|
MediaWindow::_UpdateProgress(int stage, const char* message, void* cookie)
|
||||||
{
|
{
|
||||||
MediaAlert* alert = static_cast<MediaAlert*>(cookie);
|
// parameters "message" and "cookie" are no longer used.
|
||||||
|
// They remain here because they're declared within BeOS API and
|
||||||
|
// thus could not be removed.
|
||||||
|
|
||||||
PRINT(("stage : %i\n", stage));
|
PRINT(("stage : %i\n", stage));
|
||||||
const char* string = "Unknown stage";
|
const char* string = "Unknown stage";
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
@@ -693,9 +699,13 @@ MediaWindow::_UpdateProgress(int stage, const char* message, void* cookie)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAutolock locker(alert);
|
BNotification info(B_PROGRESS_NOTIFICATION);
|
||||||
if (locker.IsLocked())
|
info.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
|
||||||
alert->TextView()->SetText(string);
|
info.SetProgress(stage/100.0);
|
||||||
|
info.SetTitle(B_TRANSLATE("Media Service"));
|
||||||
|
info.SetContent(string);
|
||||||
|
info.Send();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "MediaListItem.h"
|
#include "MediaListItem.h"
|
||||||
#include "MediaViews.h"
|
#include "MediaViews.h"
|
||||||
|
|
||||||
|
#define MEDIA_SERVICE_NOTIFICATION_ID "MediaServiceNotificationID"
|
||||||
#define SETTINGS_FILE "MediaPrefs Settings"
|
#define SETTINGS_FILE "MediaPrefs Settings"
|
||||||
|
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ private:
|
|||||||
NodeListItem* _FindNodeListItem(dormant_node_info* info);
|
NodeListItem* _FindNodeListItem(dormant_node_info* info);
|
||||||
|
|
||||||
static status_t _RestartMediaServices(void* data);
|
static status_t _RestartMediaServices(void* data);
|
||||||
static bool _UpdateProgress(int stage, const char * message,
|
static bool _UpdateProgress(int stage, const char* message,
|
||||||
void * cookie);
|
void* cookie);
|
||||||
|
|
||||||
void _ClearParamView();
|
void _ClearParamView();
|
||||||
void _MakeParamView();
|
void _MakeParamView();
|
||||||
@@ -111,7 +111,6 @@ private:
|
|||||||
NodeList fVideoInputs;
|
NodeList fVideoInputs;
|
||||||
NodeList fVideoOutputs;
|
NodeList fVideoOutputs;
|
||||||
|
|
||||||
MediaAlert* fAlert;
|
|
||||||
status_t fInitCheck;
|
status_t fInitCheck;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user