From ed1dc88e3c8bd9ef84b4d99f3fcacf37a34184a1 Mon Sep 17 00:00:00 2001
From: Laurent Chea <contact@laurentchea.com>
Date: Fri, 12 Dec 2014 22:45:09 +0100
Subject: [PATCH] Media service restart is now using BNotification. Fixes 8171.
---
src/preferences/media/MediaWindow.cpp | 76 +++++++++++++++++------------------
src/preferences/media/MediaWindow.h | 1 -
2 files changed, 36 insertions(+), 41 deletions(-)
diff --git a/src/preferences/media/MediaWindow.cpp b/src/preferences/media/MediaWindow.cpp
index 4a4ee9b..b168d8a 100644
a
|
b
|
MediaWindow::MediaWindow(BRect frame)
|
162 | 162 | fAudioOutputs(5, true), |
163 | 163 | fVideoInputs(5, true), |
164 | 164 | fVideoOutputs(5, true), |
165 | | fNotificationPopup(NULL), |
166 | 165 | fInitCheck(B_OK) |
167 | 166 | { |
168 | 167 | _InitWindow(); |
… |
… |
MediaWindow::MessageReceived(BMessage* message)
|
315 | 314 | case B_SOME_APP_LAUNCHED: |
316 | 315 | { |
317 | 316 | PRINT_OBJECT(*message); |
318 | | if (fNotificationPopup == NULL) { |
319 | | fNotificationPopup = new BNotification(B_PROGRESS_NOTIFICATION); |
320 | | fNotificationPopup->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
321 | | } |
322 | 317 | |
323 | 318 | BString mimeSig; |
324 | 319 | if (message->FindString("be:signature", &mimeSig) == B_OK |
325 | 320 | && (mimeSig == "application/x-vnd.Be.addon-host" |
326 | 321 | || mimeSig == "application/x-vnd.Be.media-server")) { |
327 | | fNotificationPopup->SetContent( |
| 322 | BNotification notificationPopup(B_PROGRESS_NOTIFICATION); |
| 323 | notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
| 324 | notificationPopup.SetTitle(B_TRANSLATE("Media Service")); |
| 325 | notificationPopup.SetProgress(0.5); |
| 326 | notificationPopup.SetContent( |
328 | 327 | B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS)); |
329 | | fNotificationPopup->Send(); |
| 328 | notificationPopup.Send(); |
330 | 329 | } |
331 | 330 | break; |
332 | 331 | } |
… |
… |
MediaWindow::_InitMedia(bool first)
|
420 | 419 | if (alert->Go() == 0) |
421 | 420 | return B_ERROR; |
422 | 421 | |
423 | | fNotificationPopup = new BNotification(B_PROGRESS_NOTIFICATION); |
424 | | fNotificationPopup->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
425 | | fNotificationPopup->SetTitle(B_TRANSLATE("Media Service")); |
426 | | fNotificationPopup->SetProgress(0.5); |
427 | | fNotificationPopup->SetContent( |
| 422 | BNotification notificationPopup(B_PROGRESS_NOTIFICATION); |
| 423 | notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
| 424 | notificationPopup.SetTitle(B_TRANSLATE("Media Service")); |
| 425 | notificationPopup.SetProgress(0.5); |
| 426 | notificationPopup.SetContent( |
428 | 427 | B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS)); |
429 | | fNotificationPopup->Send(); |
| 428 | notificationPopup.Send(); |
430 | 429 | |
431 | 430 | Show(); |
432 | 431 | |
… |
… |
MediaWindow::_InitMedia(bool first)
|
440 | 439 | && fListView->ItemAt(0)->IsSelected()) |
441 | 440 | isVideoSelected = false; |
442 | 441 | |
443 | | if ((!first || (first && err) ) && fNotificationPopup) { |
444 | | fNotificationPopup->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
445 | | fNotificationPopup->SetProgress(1.0); |
446 | | fNotificationPopup->SetContent( |
| 442 | if (!first || (first && err) ) { |
| 443 | BNotification notificationPopup(B_PROGRESS_NOTIFICATION); |
| 444 | notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
| 445 | notificationPopup.SetTitle(B_TRANSLATE("Media Service")); |
| 446 | notificationPopup.SetProgress(1.0); |
| 447 | notificationPopup.SetContent( |
447 | 448 | B_TRANSLATE("Ready for use" B_UTF8_ELLIPSIS)); |
448 | | fNotificationPopup->Send(); |
| 449 | notificationPopup.Send(); |
449 | 450 | } |
450 | 451 | |
451 | 452 | while (fListView->CountItems() > 0) |
… |
… |
status_t
|
648 | 649 | MediaWindow::_RestartMediaServices(void* data) |
649 | 650 | { |
650 | 651 | MediaWindow* window = (MediaWindow*)data; |
651 | | |
652 | | if (window->fNotificationPopup == NULL) { |
653 | | window->fNotificationPopup = new BNotification(B_PROGRESS_NOTIFICATION); |
654 | | window->fNotificationPopup->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
655 | | } |
656 | | |
657 | | window->fNotificationPopup->SetTitle(B_TRANSLATE("Media Service")); |
658 | | window->fNotificationPopup->SetContent( |
659 | | B_TRANSLATE("Shutting down media server")); |
660 | | window->fNotificationPopup->Send(); |
| 652 | |
| 653 | BNotification notificationPopup(B_PROGRESS_NOTIFICATION); |
| 654 | notificationPopup.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
| 655 | notificationPopup.SetTitle(B_TRANSLATE("Media Service")); |
| 656 | notificationPopup.SetContent( B_TRANSLATE("Shutting down media server")); |
661 | 657 | |
662 | 658 | shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::_UpdateProgress, |
663 | | window->fNotificationPopup); |
| 659 | NULL); |
664 | 660 | |
665 | | window->fNotificationPopup->SetContent( |
| 661 | notificationPopup.SetContent( |
666 | 662 | B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS)); |
667 | | window->fNotificationPopup->SetProgress(0.5); |
668 | | window->fNotificationPopup->Send(); |
| 663 | notificationPopup.SetProgress(0.5); |
| 664 | notificationPopup.Send(); |
669 | 665 | |
670 | 666 | launch_media_server(); |
671 | 667 | |
672 | | window->fNotificationPopup->SetProgress(1); |
673 | | window->fNotificationPopup->Send(); |
| 668 | notificationPopup.SetProgress(1); |
| 669 | notificationPopup.Send(); |
674 | 670 | |
675 | 671 | return window->PostMessage(ML_INIT_MEDIA); |
676 | 672 | } |
… |
… |
MediaWindow::_RestartMediaServices(void* data)
|
679 | 675 | bool |
680 | 676 | MediaWindow::_UpdateProgress(int stage, const char* message, void* infoPopup) |
681 | 677 | { |
682 | | BNotification* info = static_cast<BNotification*>(infoPopup); |
683 | 678 | PRINT(("stage : %i\n", stage)); |
684 | 679 | const char* string = "Unknown stage"; |
685 | 680 | switch (stage) { |
… |
… |
MediaWindow::_UpdateProgress(int stage, const char* message, void* infoPopup)
|
700 | 695 | break; |
701 | 696 | } |
702 | 697 | |
703 | | info->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
704 | | info->SetProgress(stage/100.0); |
705 | | info->SetTitle(B_TRANSLATE("Media Service")); |
706 | | info->SetContent(string); |
707 | | info->Send(); |
| 698 | BNotification info(B_PROGRESS_NOTIFICATION); |
| 699 | info.SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID); |
| 700 | info.SetProgress(stage/100.0); |
| 701 | info.SetTitle(B_TRANSLATE("Media Service")); |
| 702 | info.SetContent(string); |
| 703 | info.Send(); |
708 | 704 | |
709 | 705 | return true; |
710 | 706 | } |
diff --git a/src/preferences/media/MediaWindow.h b/src/preferences/media/MediaWindow.h
index 8e23a77..a9681e5 100644
a
|
b
|
private:
|
111 | 111 | NodeList fVideoInputs; |
112 | 112 | NodeList fVideoOutputs; |
113 | 113 | |
114 | | BNotification* fNotificationPopup; |
115 | 114 | status_t fInitCheck; |
116 | 115 | }; |
117 | 116 | |