Ticket #11922: 0012-media_server-watch-for-media-services-status-and-cal.patch

File 0012-media_server-watch-for-media-services-status-and-cal.patch, 1.9 KB (added by Barrett, 5 years ago)
  • src/servers/media/media_server.cpp

    From 0ff89c3c75b175aba9e57661c1cce9003dd8382e Mon Sep 17 00:00:00 2001
    From: Dario Casalinuovo <b.vitruvio@gmail.com>
    Date: Thu, 9 Apr 2015 16:02:01 +0200
    Subject: [PATCH 12/13] media_server: watch for media services status and call
     CleanupDormantInfos when media_addon_server die.
    
    ---
     src/servers/media/media_server.cpp | 19 +++++++++++++++++++
     1 file changed, 19 insertions(+)
    
    diff --git a/src/servers/media/media_server.cpp b/src/servers/media/media_server.cpp
    index def5467..bca1e6b 100644
    a b char __dont_remove_copyright_from_binary[] = "Copyright (c) 2002, 2003 "  
    4343#include <Roster.h>
    4444#include <MediaDefs.h>
    4545#include <MediaFormats.h>
     46#include <MediaRoster.h>
    4647#include <Messenger.h>
    4748
    4849#include <syscalls.h>
    ServerApp::ServerApp()  
    112113    fControlThread = spawn_thread(_ControlThread, "media_server control", 105,
    113114        this);
    114115    resume_thread(fControlThread);
     116
     117    BMediaRoster* roster = BMediaRoster::Roster();
     118    if (roster->StartWatching(BMessenger(this, this),
     119        B_MEDIA_SERVER_QUIT) != B_OK) {
     120            TRACE("ServerApp: can't watch for B_MEDIA_SERVER_QUIT");
     121    }
    115122}
    116123
    117124
     125
    118126ServerApp::~ServerApp()
    119127{
    120128    TRACE("ServerApp::~ServerApp()\n");
    ServerApp::~ServerApp()  
    127135    delete gAppManager;
    128136    delete gNodeManager;
    129137    delete gMediaFilesManager;
     138
     139    BMediaRoster* roster = BMediaRoster::CurrentRoster();
     140    if (roster->StopWatching(BMessenger(this, this),
     141        B_MEDIA_SERVER_QUIT) != B_OK) {
     142            TRACE("ServerApp: can't unwatch for B_MEDIA_SERVER_QUIT");
     143    }
    130144}
    131145
    132146
    ServerApp::MessageReceived(BMessage* msg)  
    918932        case MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT:
    919933            gMediaFilesManager->HandleAddSystemBeepEvent(msg);
    920934            break;
     935
     936        case B_MEDIA_SERVER_QUIT:
     937            gNodeManager->CleanupDormantFlavorInfos();
     938            break;
     939
    921940        default:
    922941            BApplication::MessageReceived(msg);
    923942            printf("\nmedia_server: unknown message received:\n");