Ticket #8171: 0001-Media-service-restart-is-now-using-BNotification-Ticket-8171.patch

File 0001-Media-service-restart-is-now-using-BNotification-Ticket-8171.patch, 5.9 KB (added by MrPingouin, 9 years ago)
  • src/preferences/media/MediaWindow.cpp

    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)  
    162162    fAudioOutputs(5, true),
    163163    fVideoInputs(5, true),
    164164    fVideoOutputs(5, true),
    165     fNotificationPopup(NULL),
    166165    fInitCheck(B_OK)
    167166{
    168167    _InitWindow();
    MediaWindow::MessageReceived(BMessage* message)  
    315314        case B_SOME_APP_LAUNCHED:
    316315        {
    317316            PRINT_OBJECT(*message);
    318             if (fNotificationPopup == NULL) {
    319                 fNotificationPopup = new BNotification(B_PROGRESS_NOTIFICATION);
    320                 fNotificationPopup->SetMessageID(MEDIA_SERVICE_NOTIFICATION_ID);
    321             }
    322317
    323318            BString mimeSig;
    324319            if (message->FindString("be:signature", &mimeSig) == B_OK
    325320                && (mimeSig == "application/x-vnd.Be.addon-host"
    326321                    || 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(
    328327                    B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
    329                 fNotificationPopup->Send();
     328                notificationPopup.Send();
    330329            }
    331330            break;
    332331        }
    MediaWindow::_InitMedia(bool first)  
    420419        if (alert->Go() == 0)
    421420            return B_ERROR;
    422421
    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(
    428427            B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
    429         fNotificationPopup->Send();
     428        notificationPopup.Send();
    430429
    431430        Show();
    432431
    MediaWindow::_InitMedia(bool first)  
    440439        && fListView->ItemAt(0)->IsSelected())
    441440        isVideoSelected = false;
    442441
    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(
    447448            B_TRANSLATE("Ready for use" B_UTF8_ELLIPSIS));
    448         fNotificationPopup->Send();
     449        notificationPopup.Send();
    449450    }
    450451
    451452    while (fListView->CountItems() > 0)
    status_t  
    648649MediaWindow::_RestartMediaServices(void* data)
    649650{
    650651    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"));
    661657
    662658    shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::_UpdateProgress,
    663         window->fNotificationPopup);
     659        NULL);
    664660
    665     window->fNotificationPopup->SetContent(
     661    notificationPopup.SetContent(
    666662        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();
    669665
    670666    launch_media_server();
    671667
    672     window->fNotificationPopup->SetProgress(1);
    673     window->fNotificationPopup->Send();
     668    notificationPopup.SetProgress(1);
     669    notificationPopup.Send();
    674670
    675671    return window->PostMessage(ML_INIT_MEDIA);
    676672}
    MediaWindow::_RestartMediaServices(void* data)  
    679675bool
    680676MediaWindow::_UpdateProgress(int stage, const char* message, void* infoPopup)
    681677{
    682     BNotification* info = static_cast<BNotification*>(infoPopup);
    683678    PRINT(("stage : %i\n", stage));
    684679    const char* string = "Unknown stage";
    685680    switch (stage) {
    MediaWindow::_UpdateProgress(int stage, const char* message, void* infoPopup)  
    700695            break;
    701696    }
    702697
    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();
    708704
    709705    return true;
    710706}
  • src/preferences/media/MediaWindow.h

    diff --git a/src/preferences/media/MediaWindow.h b/src/preferences/media/MediaWindow.h
    index 8e23a77..a9681e5 100644
    a b private:  
    111111            NodeList            fVideoInputs;
    112112            NodeList            fVideoOutputs;
    113113
    114             BNotification*      fNotificationPopup;
    115114            status_t            fInitCheck;
    116115};
    117116