void
AudioSettingsView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case ML_DEFAULT_CHANNEL_CHANGED:
			{
				int32 index;
				if (message->FindInt32("index", &index) != B_OK)
					break;
				ChannelMenuItem* item = _ChannelMenuItemAt(index);

				if (item) {
					BMediaRoster* roster = BMediaRoster::Roster();
					roster->SetAudioOutput(*item->Input());
				} else
					fprintf(stderr, "ChannelMenuItem not found\n");
			}
			break;
		case MEDIA_SHOW_HIDE_VOLUME_CONTROL:
		{
			if (fVolumeCheckBox->Value() == B_CONTROL_ON)
				_ShowDeskbarVolumeControl();
			else
				_HideDeskbarVolumeControl();
			break;
		}

		default:
			SettingsView::MessageReceived(message);
	}
}
Beispiel #2
0
MediaWindow::~MediaWindow()
{
	_EmptyNodeLists();
	_ClearParamView();

	char buffer[512];
	BRect rect = Frame();
	PRINT_OBJECT(rect);
	snprintf(buffer, 512, "# MediaPrefs Settings\n rect = %i,%i,%i,%i\n",
		int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));

	BPath path;
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
		path.Append(SETTINGS_FILE);
		BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
		if (file.InitCheck() == B_OK)
			file.Write(buffer, strlen(buffer));
	}

	BMediaRoster* roster = BMediaRoster::CurrentRoster();
	roster->StopWatching(BMessenger(this, this),
		B_MEDIA_SERVER_STARTED);
	roster->StartWatching(BMessenger(this, this),
		B_MEDIA_SERVER_QUIT);
}
Beispiel #3
0
live_node_info*
JackClient::_LiveNodes(int32* live_count)
{
	BMediaRoster* roster = BMediaRoster::Roster();

	// TODO set autodeleter to live_nodes
	live_node_info* live_nodes = (live_node_info*) malloc(100);
	int32 count;

	media_format outFormat;
	memset(&outFormat, 0, sizeof(outFormat));
	outFormat.type = B_MEDIA_RAW_AUDIO;

	media_format inFormat;
	memset(&inFormat, 0, sizeof(inFormat));
	inFormat.type = B_MEDIA_RAW_AUDIO;

	status_t err = roster->GetLiveNodes(live_nodes, &count,
		&inFormat, &outFormat, NULL, 0);

	if (err != B_OK)
		return NULL;

	*live_count = count;
	return live_nodes;
}
status_t ParameterWindow::_startControlPanel() {
    D_INTERNAL(("ParameterWindow::_startControlPanel()\n"));

    // get roster instance
    BMediaRoster *roster = BMediaRoster::CurrentRoster();
    if (!roster) {
        D_INTERNAL((" -> MediaRoster not available\n"));
        return B_ERROR;
    }

    // try to StartControlPanel()
    BMessenger messenger;
    status_t error = roster->StartControlPanel(m_node, &messenger);
    if (error) {
        D_INTERNAL((" -> StartControlPanel() failed (%s)\n", strerror(error)));
        return error;
    }

    // notify the notification target, if any
    if (m_notifyTarget) {
        BMessage message(M_CONTROL_PANEL_STARTED);
        message.AddInt32("nodeID", m_node.node);
        message.AddMessenger("messenger", messenger);
        error = m_notifyTarget->SendMessage(&message);
        if (error) {
            D_INTERNAL((" -> failed to notify target\n"));
        }
    }

    return B_OK;
}
Beispiel #5
0
// --------------------
// NodeHarnessWin implementation
NodeHarnessWin::NodeHarnessWin(BRect frame, const char *title)
    :	BWindow(frame, title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
      mToneNode(NULL), mIsConnected(false), mIsRunning(false)
{
    // build the UI
    BRect r(10, 10, 100, 40);
    mConnectButton = new BButton(r, "Connect", "Connect", new BMessage(BUTTON_CONNECT));
    mConnectButton->SetEnabled(true);
    AddChild(mConnectButton);
    r.OffsetBy(0, 40);
    mStartButton = new BButton(r, "Start", "Start", new BMessage(BUTTON_START));
    mStartButton->SetEnabled(false);
    AddChild(mStartButton);
    r.OffsetBy(0, 40);
    mStopButton = new BButton(r, "Stop", "Stop", new BMessage(BUTTON_STOP));
    mStopButton->SetEnabled(false);
    AddChild(mStopButton);

    // e.moon 2jun99: create the node
    BMediaRoster* roster = BMediaRoster::Roster();
    mToneNode = new ToneProducer();

    status_t err = roster->RegisterNode(mToneNode);
    ErrorCheck(err, "unable to register ToneProducer node!\n");
    // make sure the Media Roster knows that we're using the node
    roster->GetNodeFor(mToneNode->Node().node, &mConnection.producer);
}
Beispiel #6
0
NodeHarnessWin::~NodeHarnessWin()
{
    BMediaRoster* r = BMediaRoster::Roster();

    // tear down the node network
    if (mIsRunning) StopNodes();
    if (mIsConnected)
    {
        status_t err;

        // Ordinarily we'd stop *all* of the nodes in the chain at this point.  However,
        // one of the nodes is the System Mixer, and stopping the Mixer is a Bad Idea (tm).
        // So, we just disconnect from it, and release our references to the nodes that
        // we're using.  We *are* supposed to do that even for global nodes like the Mixer.
        err = r->Disconnect(mConnection.producer.node, mConnection.source,
                            mConnection.consumer.node, mConnection.destination);
        if (err)
        {
            fprintf(stderr, "* Error disconnecting nodes:  %ld (%s)\n", err, strerror(err));
        }

        r->ReleaseNode(mConnection.producer);
        r->ReleaseNode(mConnection.consumer);
    }
}
Beispiel #7
0
void
VolumeControl::_ConnectVolume()
{
	_DisconnectVolume();

	const char* errorString = NULL;
	float volume = 0.0;
	fMixerControl->Connect(fMixerControl->VolumeWhich(), &volume, &errorString);

	if (errorString != NULL) {
		SetLabel(errorString);
		SetLimits(-60, 18);
	} else {
		SetLabel(B_TRANSLATE("Volume"));
		SetLimits((int32)floorf(fMixerControl->Minimum()),
			(int32)ceilf(fMixerControl->Maximum()));

		BMediaRoster* roster = BMediaRoster::CurrentRoster();
		if (roster != NULL && fMixerControl->GainNode() != media_node::null) {
			roster->StartWatching(this, fMixerControl->GainNode(),
				B_MEDIA_NEW_PARAMETER_VALUE);
		}
	}

	SetEnabled(errorString == NULL);

	fOriginalValue = (int32)volume;
	SetValue((int32)volume);
}
Beispiel #8
0
void DormantNodeView::_populateList() {
	D_INTERNAL(("DormantNodeView::_populateList()\n"));

	// init the resizable node-info buffer
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	const int32 bufferInc = 64;
	int32 bufferSize = bufferInc;
	dormant_node_info *infoBuffer = new dormant_node_info[bufferSize];
	int32 numNodes;
	
	// fill the buffer
	while (true) {
		numNodes = bufferSize;
		status_t error = roster->GetDormantNodes(infoBuffer, &numNodes);
		if (error) {
			return;
		}
		if (numNodes < bufferSize) {
			break;
		}
			
		// reallocate buffer & try again
		delete [] infoBuffer;
		bufferSize += bufferInc;
		infoBuffer = new dormant_node_info[bufferSize];
	}
	
	// populate the list
	for (int32 i = 0; i < numNodes; i++) {
		DormantNodeListItem *item = new DormantNodeListItem(infoBuffer[i]);
		AddItem(item);
	}
	SortItems(compareName);
}
Beispiel #9
0
void DormantNodeView::_updateList(
	int32 addOnID) {
	D_INTERNAL(("DormantNodeView::_updateList(%ld)\n", addOnID));

	// init the resizable node-info buffer
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	const int32 bufferInc = 64;
	int32 bufferSize = bufferInc;
	dormant_node_info *infoBuffer = new dormant_node_info[bufferSize];
	int32 numNodes;
	
	// fill the buffer
	while (true) {
		numNodes = bufferSize;
		status_t error = roster->GetDormantNodes(infoBuffer, &numNodes);
		if (error) {
			return;
		}
		if (numNodes < bufferSize) {
			break;
		}
			
		// reallocate buffer & try again
		delete [] infoBuffer;
		bufferSize += bufferInc;
		infoBuffer = new dormant_node_info[bufferSize];
	}

	// sort the list by add-on id to avoid multiple searches through
	// the list
	SortItems(compareAddOnID);

	// Remove all nodes managed by this add-on
	int32 start;
	for (start = 0; start < CountItems(); start++) {
		DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(start));
		if (item && (item->info().addon == addOnID)) {
			break;
		}
	}
	int32 count = 0;
	for (int32 i = start; start < CountItems(); i++) {
		DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(i));
		if (!item || (item->info().addon != addOnID)) {
			break;
		}
		count++;
	}
	RemoveItems(start, count);

	// add the items
	for (int32 i = 0; i < numNodes; i++) {
		if (infoBuffer[i].addon != addOnID) {
			continue;
		}
		AddItem(new DormantNodeListItem(infoBuffer[i]));
	}

	SortItems(compareName);
}
Beispiel #10
0
void
MediaWindow::SmartNode::SetTo(const dormant_node_info* info)
{
	_FreeNode();
	if (!info)
		return;

	fNode = new media_node();
	BMediaRoster* roster = BMediaRoster::Roster();

	status_t status = B_OK;
	media_node_id node_id;
	if (roster->GetInstancesFor(info->addon, info->flavor_id, &node_id) == B_OK)
		status = roster->GetNodeFor(node_id, fNode);
	else
		status = roster->InstantiateDormantNode(*info, fNode, B_FLAVOR_IS_GLOBAL);

	if (status != B_OK) {
		fprintf(stderr, "SmartNode::SetTo error with node %" B_PRId32
			": %s\n", fNode->node, strerror(status));
	}

	status = roster->StartWatching(fMessenger, *fNode, B_MEDIA_WILDCARD);
	if (status != B_OK) {
		fprintf(stderr, "SmartNode::SetTo can't start watching for"
			" node %" B_PRId32 "\n", fNode->node);
	}
}
Beispiel #11
0
NodeRef::~NodeRef() {
	D_METHOD(("~NodeRef[%s]\n", name()));
	Autolock _l(m_manager);
	
	// remove from NodeManager
	m_manager->_removeRef(id());
	
	// [14oct99 e.moon] kill position-report thread if necessary
	if(m_positionThread)
		_stopPositionThread();

	if(m_addonHint) {
		delete m_addonHint;
		m_addonHint = 0;
	}

	// close Media Roster connection [e.moon 11oct99]
	BMediaRoster* r = BMediaRoster::Roster();
	if(m_watching) {
		r->StopWatching(
			BMessenger(this),
			node(),
			B_MEDIA_WILDCARD);
	}
}
Beispiel #12
0
void
MediaWindow::SmartNode::SetTo(const media_node& node)
{
	_FreeNode();
	fNode = new media_node(node);
	BMediaRoster* roster = BMediaRoster::Roster();
	roster->StartWatching(fMessenger, *fNode, B_MEDIA_WILDCARD);
}
Beispiel #13
0
void
VolumeControl::DetachedFromWindow()
{
	_DisconnectVolume();

	BMediaRoster* roster = BMediaRoster::CurrentRoster();
	roster->StopWatching(BMessenger(this), B_MEDIA_SERVER_STARTED);
	roster->StopWatching(BMessenger(this), B_MEDIA_SERVER_QUIT);
}
Beispiel #14
0
void
VolumeControl::_DisconnectVolume()
{
	BMediaRoster* roster = BMediaRoster::CurrentRoster();
	if (roster != NULL && fMixerControl->GainNode() != media_node::null) {
		roster->StopWatching(this, fMixerControl->GainNode(),
			B_MEDIA_NEW_PARAMETER_VALUE);
	}
}
Beispiel #15
0
void
BMediaClient::_Init()
{
	CALLED();

	BMediaRoster* roster = BMediaRoster::Roster(&fInitErr);
	if (fInitErr == B_OK && roster != NULL)
		fInitErr = roster->RegisterNode(fNode);
}
void
AudioSettingsView::_FillChannelMenu(const dormant_node_info* nodeInfo)
{
	_EmptyMenu(fChannelMenu);

	BMediaRoster* roster = BMediaRoster::Roster();
	media_node node;
	media_node_id node_id;

	status_t err = roster->GetInstancesFor(nodeInfo->addon,
		nodeInfo->flavor_id, &node_id);
	if (err != B_OK) {
		err = roster->InstantiateDormantNode(*nodeInfo, &node,
			B_FLAVOR_IS_GLOBAL);
	} else {
		err = roster->GetNodeFor(node_id, &node);
	}

	if (err == B_OK) {
		int32 inputCount = 4;
		media_input* inputs = new media_input[inputCount];
		BPrivate::ArrayDeleter<media_input> inputDeleter(inputs);

		while (true) {
			int32 realInputCount = 0;
			err = roster->GetAllInputsFor(node, inputs,
				inputCount, &realInputCount);
			if (realInputCount > inputCount) {
				inputCount *= 2;
				inputs = new media_input[inputCount];
				inputDeleter.SetTo(inputs);
			} else {
				inputCount = realInputCount;
				break;
			}
		}

		if (err == B_OK) {
			BMessage message(ML_DEFAULT_CHANNEL_CHANGED);

			for (int32 i = 0; i < inputCount; i++) {
				media_input* input = new media_input();
				memcpy(input, &inputs[i], sizeof(*input));
				ChannelMenuItem* channelItem = new ChannelMenuItem(input,
					new BMessage(message));
				fChannelMenu->AddItem(channelItem);

				if (channelItem->DestinationID() == 0)
					channelItem->SetMarked(true);
			}
		}
	}

	if (Window())
		fChannelMenu->SetTargetForItems(BMessenger(this));
}
Beispiel #17
0
MediaNodeControlApp::MediaNodeControlApp(
	const char* pAppSignature,
	media_node_id nodeID) :
	BApplication(pAppSignature) {

	BMediaRoster* r = BMediaRoster::Roster();
	
	// get the node	
	status_t err = r->GetNodeFor(nodeID, &m_node);
	if(err < B_OK) {
		char buffer[512];
		sprintf(buffer,
			"MediaNodeControlApp: couldn't find node (%ld):\n%s\n",
			nodeID, strerror(err));
		(new BAlert("error", buffer, "OK"))->Go();
		return;
	}
	
	// fetch info (name)
	live_node_info nInfo;
	err = r->GetLiveNodeInfo(m_node, &nInfo);
	if(err < B_OK) {
		char buffer[512];
		sprintf(buffer,
			"MediaNodeControlApp: couldn't get node info (%ld):\n%s\n",
			nodeID, strerror(err));
		(new BAlert("error", buffer, "OK"))->Go();
		return;
	}
	
	BString windowTitle;
	windowTitle << nInfo.name << '(' << nodeID << ") controls";		
	
	// get parameter web
	BParameterWeb* pWeb;
	err = r->GetParameterWebFor(m_node, &pWeb);
	if(err < B_OK) {
		char buffer[512];
		sprintf(buffer,
			"MediaNodeControlApp: no parameters for node (%ld):\n%s\n",
			nodeID, strerror(err));
		(new BAlert("error", buffer, "OK"))->Go();
		return;
	}
	
	// build & show control window
	BView* pView = BMediaTheme::ViewFor(pWeb);
	BWindow* pWnd = new PanelWindow();
	pWnd->AddChild(pView);
	pWnd->ResizeTo(pView->Bounds().Width(), pView->Bounds().Height());
	pWnd->SetTitle(windowTitle.String());
	pWnd->Show();
	
	// release the node
	//r->ReleaseNode(m_node);	
}
Beispiel #18
0
void
MediaWindow::SelectAudioMixer(const char* title)
{
	media_node mixerNode;
	BMediaRoster* roster = BMediaRoster::Roster();
	roster->GetAudioMixer(&mixerNode);
	fCurrentNode.SetTo(mixerNode);
	_MakeParamView();
	fTitleView->SetLabel(title);
}
Beispiel #19
0
// Private routines
void
NodeHarnessWin::StopNodes()
{
	mStartButton->SetEnabled(true);
	mStopButton->SetEnabled(false);

	// stop the producer
	{
		BMediaRoster* r = BMediaRoster::Roster();
		r->StopNode(mConnection.producer, 0, true);		// synchronous stop
	}
}
Beispiel #20
0
void
MediaWindow::SmartNode::_FreeNode()
{
	if (!IsSet())
		return;
	// TODO: check error codes
	BMediaRoster* roster = BMediaRoster::Roster();
	roster->StopWatching(fMessenger, *fNode, B_MEDIA_WILDCARD);
	roster->ReleaseNode(*fNode);
	delete fNode;
	fNode = NULL;
}
void ParameterWindow::_updateParameterView(
    BMediaTheme *theme) {
    D_INTERNAL(("ParameterWindow::_updateParameterView()\n"));

    // clear the old version
    if (m_parameters) {
        ParameterContainerView *view = dynamic_cast<ParameterContainerView *>(FindView("ParameterContainerView"));
        RemoveChild(view);
        delete m_parameters;
        m_parameters = 0;
        delete view;
    }

    // fetch ParameterWeb from the MediaRoster
    BMediaRoster *roster = BMediaRoster::CurrentRoster();
    if (roster) {
        BParameterWeb *web;
        status_t error = roster->GetParameterWebFor(m_node, &web);
        if (!error && (web->CountParameters() || web->CountGroups())) {
            // if no theme was specified, use the preferred theme
            if (!theme) {
                theme = BMediaTheme::PreferredTheme();
            }
            // acquire the view
            m_parameters = BMediaTheme::ViewFor(web, 0, theme);
            if (m_parameters) {
                BMenuBar *menuBar = KeyMenuBar();
                m_idealSize = m_parameters->Bounds();
                m_idealSize.right += B_V_SCROLL_BAR_WIDTH;
                m_idealSize.bottom += B_H_SCROLL_BAR_HEIGHT;
                if (menuBar) {
                    m_parameters->MoveTo(0.0, menuBar->Bounds().bottom + 1.0);
                    m_idealSize.bottom += menuBar->Bounds().bottom + 1.0;
                }
            }
        }
    }

    // limit min size to avoid funny-looking scrollbars
    float hMin = B_V_SCROLL_BAR_WIDTH*6, vMin = B_H_SCROLL_BAR_HEIGHT*3;
    // limit max size to full extents of the parameter view
    float hMax = m_idealSize.Width(), vMax = m_idealSize.Height();
    SetSizeLimits(hMin, hMax, vMin, vMax);

    // adapt the window to the new dimensions
    ResizeTo(m_idealSize.Width(), m_idealSize.Height());
    m_zoomed = true;

    if (m_parameters) {
        BRect paramRect = m_parameters->Bounds();
        AddChild(new ParameterContainerView(paramRect, m_parameters));
    }
}
Beispiel #22
0
void DormantNodeView::AttachedToWindow() {
	D_HOOK(("DormantNodeView::AttachedToWindow()\n"));

	// populate the list
	_populateList();

	// Start watching the MediaRoster for flavor changes
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	if (roster) {
		BMessenger messenger(this, Window());
		roster->StartWatching(messenger, B_MEDIA_FLAVORS_CHANGED);
	}
}
Beispiel #23
0
void DormantNodeView::DetachedFromWindow() {
	D_HOOK(("DormantNodeView::DetachedFromWindow()\n"));

	// delete the lists contents
	_freeList();

	// Stop watching the MediaRoster for flavor changes
	BMediaRoster *roster = BMediaRoster::CurrentRoster();
	if (roster) {
		BMessenger messenger(this, Window());
		roster->StopWatching(messenger, B_MEDIA_FLAVORS_CHANGED);
	}
}
Beispiel #24
0
// Private routines
void
NodeHarnessWin::StopNodes()
{
    mStartButton->SetEnabled(true);
    mStopButton->SetEnabled(false);

    // generally, one only stops the initial producer(s), and lets the rest of the node
    // chain just follow along as the buffers drain out.
    {
        BMediaRoster* r = BMediaRoster::Roster();
        r->StopNode(mConnection.producer, 0, true);		// synchronous stop
    }
}
Beispiel #25
0
status_t
GameSoundBuffer::StopPlaying()
{
	if (!fIsPlaying) 
		return EALREADY;
	
	BMediaRoster* roster = BMediaRoster::Roster();
	roster->StopNode(fConnection->producer, 0, true);
		// synchronous stop

	Reset();
	fIsPlaying = false;
	
	return B_OK;
}
Beispiel #26
0
NodeHarnessWin::~NodeHarnessWin()
{
	BMediaRoster* r = BMediaRoster::Roster();

	// tear down the node network
	if (mIsRunning) StopNodes();
	if (mIsConnected)
	{
		printf("Total late buffers: %ld\n", mLogNode->LateBuffers());
		r->StopNode(mConnection.consumer, 0, true);
		r->Disconnect(mConnection.producer.node, mConnection.source,
			mConnection.consumer.node, mConnection.destination);
		r->ReleaseNode(mConnection.producer);
		r->ReleaseNode(mConnection.consumer);
	}
}
Beispiel #27
0
status_t
GameSoundBuffer::Connect(media_node * consumer)
{
	BMediaRoster* roster = BMediaRoster::Roster();
	status_t err = roster->RegisterNode(fNode);
	
	if (err != B_OK) 
		return err;
	
	// make sure the Media Roster knows that we're using the node
	err = roster->GetNodeFor(fNode->Node().node, &fConnection->producer);

	if (err != B_OK)
        	return err;
	
	// connect to the mixer
	fConnection->consumer = *consumer;

	// set the producer's time source to be the "default" time source, which
	// the Mixer uses too.
	err = roster->GetTimeSource(&fConnection->timeSource);
	if (err != B_OK)
                return err;	

	err = roster->SetTimeSourceFor(fConnection->producer.node, fConnection->timeSource.node);
        if (err != B_OK)
                return err;
	// got the nodes; now we find the endpoints of the connection
	media_input mixerInput;
	media_output soundOutput;
	int32 count = 1;
	err = roster->GetFreeOutputsFor(fConnection->producer, &soundOutput, 1, &count);
	if (err != B_OK) 
		return err;
	count = 1;
	err = roster->GetFreeInputsFor(fConnection->consumer, &mixerInput, 1, &count);
	if (err != B_OK) 
		return err;

	// got the endpoints; now we connect it!
	media_format format;
	format.type = B_MEDIA_RAW_AUDIO;	
	format.u.raw_audio = media_raw_audio_format::wildcard;
	err = roster->Connect(soundOutput.source, mixerInput.destination, &format, &soundOutput, &mixerInput);
	if (err != B_OK) 
		return err;
	
	// the inputs and outputs might have been reassigned during the
	// nodes' negotiation of the Connect().  That's why we wait until
	// after Connect() finishes to save their contents.
	fConnection->format = format;
	fConnection->source = soundOutput.source;
	fConnection->destination = mixerInput.destination;

	fIsConnected = true;
	return B_OK;
}
Beispiel #28
0
void
MediaWindow::SmartNode::SetTo(const dormant_node_info* info)
{
	_FreeNode();
	if (!info)
		return;

	fNode = new media_node();
	BMediaRoster* roster = BMediaRoster::Roster();

	// TODO: error codes
	media_node_id node_id;
	if (roster->GetInstancesFor(info->addon, info->flavor_id, &node_id) == B_OK)
		roster->GetNodeFor(node_id, fNode);
	else
		roster->InstantiateDormantNode(*info, fNode, B_FLAVOR_IS_GLOBAL);
	roster->StartWatching(fMessenger, *fNode, B_MEDIA_WILDCARD);
}
Beispiel #29
0
status_t
launch_media_server(bigtime_t timeout,
	bool (*progress)(int stage, const char* message, void* cookie),
	void* cookie, uint32 flags)
{
	if (BMediaRoster::IsRunning())
		return B_ALREADY_RUNNING;

	status_t err = B_MEDIA_SYSTEM_FAILURE;
	BMediaRoster* roster = BMediaRoster::Roster(&err);
	if (roster == NULL || err != B_OK)
		return err;

	if (progress == NULL && roster->Lock()) {
		MediaRosterEx(roster)->EnableLaunchNotification(true, true);
		roster->Unlock();
	}

	// The media_server crashed
	if (be_roster->IsRunning(B_MEDIA_ADDON_SERVER_SIGNATURE)) {
		progress_startup(10, progress, cookie);
		kill_team(be_roster->TeamFor(B_MEDIA_ADDON_SERVER_SIGNATURE));
	}

	// The media_addon_server crashed
	if (be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
		progress_startup(20, progress, cookie);
		kill_team(be_roster->TeamFor(B_MEDIA_SERVER_SIGNATURE));
	}

	progress_startup(50, progress, cookie);

	err = BLaunchRoster().Start(B_MEDIA_SERVER_SIGNATURE);

	if (err != B_OK)
		progress_startup(90, progress, cookie);
	else if (progress != NULL) {
		progress_startup(100, progress, cookie);
		err = B_OK;
	}

	return err;
}
Beispiel #30
0
ServerApp::~ServerApp()
{
	TRACE("ServerApp::~ServerApp()\n");

	delete_port(fControlPort);
	wait_for_thread(fControlThread, NULL);

	delete gNotificationManager;
	delete gBufferManager;
	delete gAppManager;
	delete gNodeManager;
	delete gMediaFilesManager;

	BMediaRoster* roster = BMediaRoster::CurrentRoster();
	if (roster->StopWatching(BMessenger(this, this),
			B_MEDIA_SERVER_QUIT) != B_OK) {
		TRACE("ServerApp: can't unwatch for B_MEDIA_SERVER_QUIT");
	}
}