示例#1
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);
    }
}
示例#2
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);
	}
}
示例#3
0
// Play must stop before the distructor is called; otherwise, a fatel 
// error occures if the playback is in a subclass.
GameSoundBuffer::~GameSoundBuffer()
{
	BMediaRoster* roster = BMediaRoster::Roster();
	
	if (fIsConnected) {
		// 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.
		roster->Disconnect(fConnection->producer.node, fConnection->source,
							fConnection->consumer.node, fConnection->destination);
		
		roster->ReleaseNode(fConnection->producer);
		roster->ReleaseNode(fConnection->consumer);
	}
	
	delete fGainRamp;
	delete fPanRamp;
	
	delete fConnection;
	delete fNode;
}
示例#4
0
void
MediaAddonServer::_DestroyInstantiatedFlavors(AddOnInfo& info)
{
	printf("MediaAddonServer::_DestroyInstantiatedFlavors addon %ld\n", info.id);

	NodeVector::iterator iterator = info.active_flavors.begin();
	for (; iterator != info.active_flavors.end(); iterator++) {
		media_node& node = *iterator;
		
		printf("node %ld\n", node.node);
		
		if ((node.kind & B_TIME_SOURCE) != 0
			&& (fMediaRoster->StopTimeSource(node, 0, true) != B_OK)) {
			printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop "
				"timesource\n");
			continue;
		}

		if (fMediaRoster->StopNode(node, 0, true) != B_OK) {
			printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop "
				"node\n");
			continue;
		}

		if ((node.kind & B_BUFFER_CONSUMER) != 0) {
			media_input inputs[16];
			int32 count = 0;
			if (fMediaRoster->GetConnectedInputsFor(node, inputs, 16, &count)
					!= B_OK) {
				printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't "
					"get connected inputs\n");
				continue;
			}

			for (int32 i = 0; i < count; i++) {
				media_node_id sourceNode;
				if ((sourceNode = fMediaRoster->NodeIDFor(
						inputs[i].source.port)) < 0) {
					printf("MediaAddonServer::_DestroyInstantiatedFlavors "
						"couldn't get source node id\n");
					continue;
				}

				if (fMediaRoster->Disconnect(sourceNode, inputs[i].source,
						node.node, inputs[i].destination) != B_OK) {
					printf("MediaAddonServer::_DestroyInstantiatedFlavors "
						"couldn't disconnect input\n");
					continue;
				}
			}
		}

		if ((node.kind & B_BUFFER_PRODUCER) != 0) {
			media_output outputs[16];
			int32 count = 0;
			if (fMediaRoster->GetConnectedOutputsFor(node, outputs, 16,
					&count) != B_OK) {
				printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't "
					"get connected outputs\n");
				continue;
			}

			for (int32 i = 0; i < count; i++) {
				media_node_id destNode;
				if ((destNode = fMediaRoster->NodeIDFor(
						outputs[i].destination.port)) < 0) {
					printf("MediaAddonServer::_DestroyInstantiatedFlavors "
						"couldn't get destination node id\n");
					continue;
				}

				if (fMediaRoster->Disconnect(node.node, outputs[i].source,
						destNode, outputs[i].destination) != B_OK) {
					printf("MediaAddonServer::_DestroyInstantiatedFlavors "
						"couldn't disconnect output\n");
					continue;
				}
			}
		}
		
		MediaRosterEx(fMediaRoster)->ReleaseNodeAll(node);
	}

	info.active_flavors.clear();
}
示例#5
0
// -------------------------------------------------------- //
// implementation of BFileInterface
// -------------------------------------------------------- //
status_t MediaReader::SetRef(
				const entry_ref & file,
				bool create,
				bigtime_t * out_time)
{
	CALLED();

	status_t status = AbstractFileInterfaceNode::SetRef(file,B_READ_ONLY,create,out_time);
	if (status != B_OK) {
		PRINT("AbstractFileInterfaceNode::SetRef returned an error\n");
		return status;
	}

	if (output.destination == media_destination::null) {
		// reset the format, and set the requirements imposed by this file
		GetFormat(&output.format);
		AddRequirements(&output.format);
		return B_OK;
	}

	// if we are connected we may have to re-negotiate the connection
	media_format format;
	GetFormat(&format);
	AddRequirements(&format);
	if (format_is_acceptible(format,output.format)) {
		fprintf(stderr,"  compatible format = no re-negotiation necessary\n");
		return B_OK;
	}
	// first try the easy way : SORRY DEPRECATED into private :-(
	// this code from MediaWriter would be different for MediaReader even if it worked...
	//	int32 change_tag = NewChangeTag();
	//	status = this->BBufferConsumer::RequestFormatChange(output.source,output.destination,&format,&change_tag);
	//	if (status == B_OK) {
	//		fprintf(stderr,"  format change successful\n");
	//		return B_OK;
	//	}

	// okay, the hard way requires we get the MediaRoster
	BMediaRoster * roster = BMediaRoster::Roster(&status);
	if (roster == 0)
		return B_MEDIA_SYSTEM_FAILURE;

	if (status != B_OK)
		return status;

	// before disconnect one should always stop the nodes (bebook says)
	// requires run_state cast since the return type on RunState() is
	// wrong [int32]
	run_state destinationRunState = run_state(RunState());
	if (destinationRunState == BMediaEventLooper::B_STARTED)
		Stop(0,true); // stop us right now

	// should also stop the destination if it is running, but how?
	/*	BMediaNode destinationNode = ??
	run_state destinationRunState = destinationNode->??;
	status = destinationNode->StopNode(??,0,true);
	if (status != B_OK) {
		return status;
	}  */
	// we should disconnect right now
	media_destination outputDestination = output.destination;
	status = roster->Disconnect(output.source.id,output.source,
							    output.destination.id,output.destination);
	if (status != B_OK)
		return status;

	// if that went okay, we'll try reconnecting	
	media_output connectOutput;
	media_input connectInput;
	status = roster->Connect(output.source,outputDestination,
							 &format,&connectOutput,&connectInput);
	if (status != B_OK)
		return status;

	// now restart if necessary
	if (destinationRunState == BMediaEventLooper::B_STARTED) {
		Start(0);
	}							 
	return status;
}