Esempio n. 1
0
static filter_t *FindResampler (vlc_object_t *obj,
                                const audio_sample_format_t *infmt,
                                const audio_sample_format_t *outfmt)
{
    return FindFilter (obj, "audio resampler", "$audio-resampler",
                       infmt, outfmt);
}
Esempio n. 2
0
BOOL OpMenuSave::FindFilterAndSave ( CCLexFile* pFile, UINT32 nPrefFilter )
{
	// Find the appropriate filter.
	Filter *pFilter = FindFilter ( nPrefFilter );

	// And save the file using it.
	return Save ( pFilter, pFile );
}
Esempio n. 3
0
bool CDirectShowFilterFinder::FindFilter(const GUID *pidInType,const GUID *pidInSubType,const GUID *pidOutType,const GUID *pidOutSubType,DWORD Merit)
{
	GUID arInType[2],arOutType[2];
	GUID *pInTypes=NULL,*pOutTypes=NULL;

	if (pidInType || pidInSubType) {
		arInType[0] = pidInType ? *pidInType : GUID_NULL;
		arInType[1] = pidInSubType ? *pidInSubType : GUID_NULL;
		pInTypes = arInType;
	}
	if (pidOutType || pidOutSubType) {
		arOutType[0] = pidOutType ? *pidOutType : GUID_NULL;
		arOutType[1] = pidOutSubType ? *pidOutSubType : GUID_NULL;
		pOutTypes = arOutType;
	}

	return FindFilter(pInTypes, pInTypes ? 1 : 0,
					  pOutTypes, pOutTypes ? 1 : 0,
					  Merit);
}
int32 VirtualRenderer::RenderLoop()
{
	BList			timeList(1);
	EventComposant 	*composant;
	bigtime_t		*time, *time2, duration;
	
	bool		firstTrackActive = true;
	int			i, j, timeEvent;
	roster = BMediaRoster::Roster();
	
	/* Retrieve all the times where an event occur (starts and stops) in the list */
	for (i = 0; i < eventList->CountItems(); i++)
	{
		composant = eventList->ItemAt(i);
		composant->startRendered = false;
		composant->endRendered = false;
		time = new bigtime_t;
		*time = composant->time;
		timeList.AddItem(time);
		time = new bigtime_t;
		*time = composant->time + composant->end;
		timeList.AddItem(time);
	}
	timeList.SortItems(compare);
	/*  Instantiate a writer node */
	writer = new DiskWriter(prefs->saveFile, prefs->format, prefs->video_codec, prefs->audio_codec, 0);
	roster->SetRefFor(writer->Node(), prefs->saveFile, true, &duration);
	BMessenger	*messenger = new BMessenger(this);;
	roster->SetRunModeNode(writer->Node(), BMediaNode::B_OFFLINE);
	roster->StartWatching(*messenger, writer->Node(), B_MEDIA_NODE_STOPPED);
	/* 	if there is not video available at the beginning, we need a null generator
		to fill in the beginning of the file, else we enter the loop	*/
	//	if (eventList->FirstItem()->time != 0)
//	{
//		nullgen = new NullGen;
//		
//	}
	timeEvent = 0;
	media_output		outputs[3];
	int32				numOutputs;
	media_input			inputs[4];
	int32				numInputs;
	media_source		sources[2];
	media_destination	destinations[2];
	media_format		format;
	media_node			filterNode, transitionNode;
	bool				doConnect = false;
	bool				writerConnected = false;
	bool				reader1Connected = false;
	bool				reader2Connected = false;
	bool				filterConnected = false;
	bool				transitionConnected = false;
	
	for (timeEvent = 0; timeEvent < timeList.CountItems(); timeEvent++)
	{
		if (acquire_sem(lock_sem) == B_OK)
		{
			i = 0;
//			while (*((bigtime_t*)timeList.ItemAt(timeEvent)) != eventList->ItemAt(i)->time)
//				i++;
			duration = *((bigtime_t*)timeList.ItemAt(timeEvent));
			while (i < eventList->CountItems())
			{
				composant = eventList->ItemAt(i);
				if ((composant->time == duration) && !composant->startRendered)
				{
					composant->startRendered = true;
					break;
				}
				if ((composant->time + composant->end == duration) && !composant->endRendered)
				{
					composant->endRendered = true;
					break;
				}
				i++;
			}
			/*  We must find the events that just terminated */
			for (j = i; j < eventList->CountItems(); j++)
			{
				composant = (EventComposant*)eventList->ItemAt(j);
				if (composant->time + composant->end == *(bigtime_t*)timeList.ItemAt(timeEvent))
				switch (composant->event)
				{
					case video1:
						roster->ReleaseNode(reader1->Node());
						reader1 = NULL;
						reader1Connected = false;
						break;
					case video2:
						roster->ReleaseNode(reader2->Node());
						reader2 = NULL;
						reader2Connected = false;
						break;
					case transition:
						firstTrackActive = !firstTrackActive;
						roster->GetConnectedInputsFor(filterNode, &inputs[0], 2, &numInputs);
						roster->Disconnect(reader1->Node().node, inputs[0].source, transitionNode.node, inputs[0].destination);
						roster->Disconnect(reader2->Node().node, inputs[1].source, transitionNode.node, inputs[1].destination);
						
						roster->GetConnectedOutputsFor(transitionNode, &outputs[0], 1, &numOutputs);
						if (filterConnected)
						{
							roster->Disconnect(transitionNode.node, outputs[0].source, filterNode.node, outputs[0].destination);
							if (firstTrackActive)
								roster->Connect(inputs[0].source, outputs[0].destination, &inputs[0].format, &outputs[0], &inputs[0]);
							else
								roster->Connect(inputs[1].source, outputs[0].destination, &inputs[1].format,  &outputs[0], &inputs[1]);
						}
						else
						{
							roster->Disconnect(transitionNode.node, outputs[0].source, writer->Node().node, outputs[0].destination);
							if (firstTrackActive)
								roster->Connect(inputs[0].source, outputs[0].destination, &inputs[0].format, &outputs[0], &inputs[0]);
							else
								roster->Connect(inputs[1].source, outputs[0].destination, &inputs[1].format, &outputs[0], &inputs[1]);						
						}
						transitionConnected = false;
						break;
					case filter:
						roster->GetConnectedInputsFor(filterNode, &inputs[0], 1, &numInputs);
						if (transitionConnected)
						{
							roster->Disconnect(transitionNode.node, inputs[0].source, filterNode.node, inputs[0].destination);
							roster->GetConnectedOutputsFor(filterNode, &outputs[0], 1, &numOutputs);
							roster->Disconnect(filterNode.node, outputs[0].source, writer->Node().node, outputs[0].destination);
							roster->Connect(inputs[0].source, outputs[0].destination, &inputs[0].format, &outputs[0], &inputs[0]);
							filterConnected = false;
						}
						else if (firstTrackActive)
						{
							roster->Disconnect(reader1->Node().node, inputs[0].source, filterNode.node, inputs[0].destination);
							roster->GetConnectedOutputsFor(filterNode, &outputs[0], 1, &numOutputs);
							roster->Disconnect(filterNode.node, outputs[0].source, writer->Node().node, outputs[0].destination);
							roster->Connect(inputs[0].source, outputs[0].destination, &inputs[0].format, &outputs[0], &inputs[0]);
							filterConnected = false;							
						}
						else if (!firstTrackActive)
						{
							roster->Disconnect(reader2->Node().node, inputs[0].source, filterNode.node, inputs[0].destination);
							roster->GetConnectedOutputsFor(filterNode, &outputs[0], 1, &numOutputs);
							roster->Disconnect(filterNode.node, outputs[0].source, writer->Node().node, outputs[0].destination);
							roster->Connect(inputs[0].source, outputs[0].destination, &inputs[0].format, &outputs[0], &inputs[0]);
							filterConnected = false;							
						}
						
						
						break;
					default:
						break;
				}
			}
			if (timeEvent == timeList.CountItems() - 1)
				break;
		
			doConnect = false;
			composant = eventList->ItemAt(i);
			switch (composant->event)
			{
				case video1:
					if (reader1 != NULL)
					{
						roster->GetConnectedOutputsFor(reader1->Node(), outputs, 1, &numOutputs);
						if (numOutputs == 1)
						{
							destinations[0] = outputs[0].destination;
							doConnect = true;
						}
						//roster->ReleaseNode(reader1->Node());
						delete reader1;
						reader1Connected = false;
						reader1 = NULL;
					}
					reader1 = new FileReader(composant->u.video.filepath, composant->u.video.filepath, 0);
					roster->SetRunModeNode(reader1->Node(), BMediaNode::B_OFFLINE);
					if (doConnect)
					{
						roster->GetFreeOutputsFor(reader1->Node(), outputs, 1, &numOutputs);
						roster->Connect(outputs[0].source, destinations[0], &outputs[0].format, &outputs[0], &inputs[0]);
						reader1Connected = true;
					}
					else if (transitionConnected)
					{
						roster->GetFreeInputsFor(transitionNode, inputs, 1, &numInputs);
						roster->GetFreeOutputsFor(reader1->Node(), outputs, 1, &numOutputs);
						roster->GetFormatFor(outputs[0], &format);
						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
						reader1Connected = true;
					}
					else if (filterConnected)
					{
						roster->GetFreeInputsFor(filterNode, inputs, 1, &numInputs);
						roster->GetFreeOutputsFor(reader1->Node(), outputs, 1, &numOutputs);
						roster->GetFormatFor(outputs[0], &format);
						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
						reader1Connected = true;					
					}
					else if (!writerConnected && firstTrackActive)
					{
						roster->GetFreeInputsFor(writer->Node(), inputs, 1, &numInputs);
						roster->GetFreeOutputsFor(reader1->Node(), outputs, 1, &numOutputs);
						roster->GetFormatFor(outputs[0], &format);
						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
						writerConnected = true;
						reader1Connected = true;
					}
					time = (bigtime_t*)timeList.ItemAt(timeEvent);
					time2 = (bigtime_t*)timeList.ItemAt(timeEvent + 1);
					
					/* Tell the nodes to start until next time event */
					roster->RollNode(writer->Node(), *time, *time2);
					if (filterConnected)
						roster->RollNode(filterNode, *time, *time2);
					if (transitionConnected)
						roster->RollNode(transitionNode, *time, *time2);
					roster->RollNode(reader1->Node(), *time, *time2, composant->u.video.begin);
					break;
				case video2:
					if (reader2 != NULL)
					{
						roster->GetConnectedOutputsFor(reader2->Node(), outputs, 1, &numOutputs);
						if (numOutputs == 1)
						{
							destinations[0] = outputs[0].destination;
							doConnect = true;
						}
						//roster->ReleaseNode(reader2->Node());
						delete reader2;
						reader2Connected = false;
						reader2 = NULL;
					}
					reader2 = new FileReader(composant->u.video.filepath, composant->u.video.filepath, 0);
					roster->SetRunModeNode(reader2->Node(), BMediaNode::B_OFFLINE);
					if (doConnect)
					{
						roster->GetFreeOutputsFor(reader2->Node(), outputs, 1, &numOutputs);
						roster->Connect(outputs[0].source, destinations[0], &outputs[0].format, &outputs[0], &inputs[0]);
						reader2Connected = true;
					}
//					else if (transitionConnected)
//					{
//						roster->GetFreeInputsFor(transitionNode, inputs, 1, &numInputs);
//						roster->GetFreeOutputsFor(reader2->Node(), outputs, 1, &numOutputs);
//						roster->GetFormatFor(outputs[0], &format);
//						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
//						reader2Connected = true;
//					}
//					else if (filterConnected)
//					{
//						roster->GetFreeInputsFor(filterNode, inputs, 1, &numInputs);
//						roster->GetFreeOutputsFor(reader2->Node(), outputs, 1, &numOutputs);
//						roster->GetFormatFor(outputs[0], &format);
//						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
//						reader2Connected = true;					
//					}
//					else if (!writerConnected && !firstTrackActive)
//					{
//						roster->GetFreeInputsFor(writer->Node(), inputs, 1, &numInputs);
//						roster->GetFreeOutputsFor(reader2->Node(), outputs, 1, &numOutputs);
//						roster->GetFormatFor(outputs[0], &format);
//						roster->Connect(outputs[0].source, inputs[0].destination, &format, &outputs[0], &inputs[0]);
//						writerConnected = true;
//						reader2Connected = true;
//					}
					time = (bigtime_t*)timeList.ItemAt(timeEvent);
					time2 = (bigtime_t*)timeList.ItemAt(timeEvent + 1);
					
					roster->RollNode(writer->Node(), *time, *time2);
					if (filterConnected)
						roster->RollNode(filterNode, *time, *time2);
					if (transitionConnected)
						roster->RollNode(transitionNode, *time, *time2);
					if (reader1Connected && firstTrackActive)
						roster->RollNode(transitionNode, *time, *time2);
					if (reader2Connected && !firstTrackActive)
						roster->RollNode(reader2->Node(), *time, *time2, composant->u.video.begin);
					break;
				case filter:
				/* Handle filter events */
				if (filterConnected)
					{
						roster->GetConnectedOutputsFor(filterNode, outputs, 1, &numOutputs);
						if (numOutputs == 1)
						{
							destinations[0] = outputs[0].destination;
							doConnect = true;
						}
						roster->GetConnectedInputsFor(filterNode, inputs, 1, &numInputs);
						if (numInputs == 1)
						{
							sources[0] = inputs[0].source;
						}
						roster->ReleaseNode(filterNode);
						filterConnected = false;
					}
					FindFilter(composant->u.filter.type, &filterNode);
					SetFilterParameters(filterNode, composant->u.filter.param_list);
					roster->SetRunModeNode(filterNode, BMediaNode::B_OFFLINE);
					if (doConnect)
					{
						roster->GetFreeOutputsFor(filterNode, &outputs[1], 1, &numOutputs);
						roster->Connect(outputs[1].source, destinations[0], &outputs[0].format, &outputs[1], &inputs[1]);
						filterConnected = true;
					}
					else if (transitionConnected)
					{
						roster->GetConnectedOutputsFor(transitionNode, &outputs[0], 1, &numOutputs);
						roster->Disconnect(transitionNode.node, outputs[0].source, writer->Node().node, outputs[0].destination);
						roster->GetFreeInputsFor(filterNode, &inputs[0], 1, &numInputs);
						roster->Connect(outputs[0].source, inputs[0].destination, &outputs[0].format, &outputs[0], &inputs[0]);
						roster->GetFreeOutputsFor(filterNode, &outputs[1], 1, &numOutputs);
						roster->GetFreeInputsFor(writer->Node(), &inputs[1], 1, &numInputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &inputs[1].format, &outputs[1], &inputs[1]);
						filterConnected = true;
					}
					else if (reader1Connected && firstTrackActive)
					{
						roster->GetConnectedOutputsFor(reader1->Node(), &outputs[0], 1, &numOutputs);
						roster->Disconnect(reader1->Node().node, outputs[0].source, writer->Node().node, outputs[0].destination);
						roster->GetFreeInputsFor(filterNode, &inputs[0], 1, &numInputs);
						roster->Connect(outputs[0].source, inputs[0].destination, &outputs[0].format, &outputs[0], &inputs[0]);
						roster->GetFreeOutputsFor(filterNode, &outputs[1], 1, &numOutputs);
						roster->GetFreeInputsFor(writer->Node(), &inputs[1], 1, &numInputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &inputs[1].format, &outputs[1], &inputs[1]);
						filterConnected = true;
					}
					else if (reader2Connected && !firstTrackActive)
					{
						roster->GetConnectedOutputsFor(reader2->Node(), &outputs[0], 1, &numOutputs);
						roster->Disconnect(reader2->Node().node, outputs[0].source, writer->Node().node, outputs[0].destination);
						roster->GetFreeInputsFor(filterNode, &inputs[0], 1, &numInputs);
						roster->Connect(outputs[0].source, inputs[0].destination, &outputs[0].format, &outputs[0], &inputs[0]);
						roster->GetFreeOutputsFor(filterNode, &outputs[1], 1, &numOutputs);
						roster->GetFreeInputsFor(writer->Node(), &inputs[1], 1, &numInputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &inputs[1].format, &outputs[1], &inputs[1]);
						filterConnected = true;					
					}
					time = (bigtime_t*)timeList.ItemAt(timeEvent);
					time2 = (bigtime_t*)timeList.ItemAt(timeEvent + 1);
					
					/* Tell the nodes to start until next time event */
					roster->RollNode(writer->Node(), *time, *time2);
					if (filterConnected)
						roster->RollNode(filterNode, *time, *time2);
					if (transitionConnected)
						roster->RollNode(transitionNode, *time, *time2);
					if (reader2Connected)
						roster->RollNode(reader2->Node(), *time, *time2);
					if (reader1Connected)
						roster->RollNode(reader1->Node(), *time, *time2);
					break;
				case transition:
				
				/* Handle transition events */
					if (transitionConnected)
					{
						roster->GetConnectedOutputsFor(transitionNode, outputs, 1, &numOutputs);
						if (numOutputs == 1)
						{
							destinations[0] = outputs[0].destination;
							doConnect = true;
						}
						roster->GetConnectedInputsFor(transitionNode, inputs, 2, &numInputs);
						if (numInputs)
						{
							sources[0] = inputs[0].source;
							sources[1] = inputs[1].source;
						}
						roster->ReleaseNode(transitionNode);
						transitionConnected = false;
					}
					FindTransition(composant->u.transition.type, &transitionNode);
					roster->SetRunModeNode(transitionNode, BMediaNode::B_OFFLINE);
					if (doConnect)
					{
						roster->GetFreeInputsFor(transitionNode, &inputs[2], 2, &numInputs);
						roster->Connect(inputs[0].source, inputs[2].destination, &inputs[0].format, &outputs[1], &inputs[2]);
						roster->Connect(inputs[1].source, inputs[3].destination, &inputs[1].format, &outputs[1], &inputs[2]);
						roster->GetFreeOutputsFor(transitionNode, &outputs[1], 1, &numOutputs);
						roster->Connect(outputs[1].source, destinations[0], &outputs[0].format, &outputs[1], &inputs[0]);
						transitionConnected = true;
					}
					else if (filterConnected)
					{
						roster->GetConnectedInputsFor(filterNode, inputs, 1, &numInputs);
						if (reader1Connected)
							roster->Disconnect(reader1->Node().node, inputs[0].source, filterNode.node, inputs[0].destination);
						else if (reader2Connected)
							roster->Disconnect(reader2->Node().node, inputs[0].source, filterNode.node, inputs[0].destination);
						roster->GetFreeInputsFor(transitionNode, &inputs[2], 2, &numInputs);
						roster->GetFreeOutputsFor(reader1->Node(), &outputs[0], 1, &numOutputs);
						roster->Connect(outputs[0].source, inputs[2].destination, &outputs[0].format, &outputs[0], &inputs[2]);
						roster->GetFreeOutputsFor(reader2->Node(), &outputs[0], 1, &numOutputs);
						roster->Connect(outputs[0].source, inputs[3].destination, &outputs[0].format, &outputs[0], &inputs[3]);
						roster->GetFreeOutputsFor(transitionNode, &outputs[2], 1, &numOutputs);
						roster->Connect(outputs[2].source, inputs[0].destination, &inputs[0].format, &outputs[2], &inputs[0]);
						transitionConnected = true;
					}
					else if (reader1Connected && firstTrackActive)
					{
						roster->GetConnectedOutputsFor(reader1->Node(), &outputs[0], 1, &numOutputs);
						roster->Disconnect(reader1->Node().node, outputs[0].source, writer->Node().node, outputs[0].destination);
						roster->GetFreeInputsFor(transitionNode, &inputs[0], 2, &numInputs);
						roster->Connect(outputs[0].source, inputs[0].destination, &outputs[0].format, &outputs[0], &inputs[0]);
						roster->GetFreeOutputsFor(reader2->Node(), &outputs[1], 1, &numOutputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &outputs[0].format, &outputs[1], &inputs[1]);
						roster->GetFreeOutputsFor(transitionNode, &outputs[1], 1, &numOutputs);
						roster->GetFreeInputsFor(writer->Node(), &inputs[1], 1, &numInputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &inputs[1].format, &outputs[1], &inputs[1]);
						transitionConnected = true;
					}
					else if (reader2Connected && !firstTrackActive)
					{
						roster->GetConnectedOutputsFor(reader2->Node(), &outputs[0], 1, &numOutputs);
						roster->Disconnect(reader2->Node().node, outputs[0].source, writer->Node().node, outputs[0].destination);
						roster->GetFreeInputsFor(transitionNode, &inputs[0], 2, &numInputs);
						roster->Connect(outputs[0].source, inputs[0].destination, &outputs[0].format, &outputs[0], &inputs[0]);
						roster->GetFreeOutputsFor(reader1->Node(), &outputs[1], 1, &numOutputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &outputs[0].format, &outputs[1], &inputs[1]);
						roster->GetFreeOutputsFor(transitionNode, &outputs[1], 1, &numOutputs);
						roster->GetFreeInputsFor(writer->Node(), &inputs[1], 1, &numInputs);
						roster->Connect(outputs[1].source, inputs[1].destination, &inputs[1].format, &outputs[1], &inputs[1]);
						transitionConnected = true;
					}
					time = (bigtime_t*)timeList.ItemAt(timeEvent);
					time2 = (bigtime_t*)timeList.ItemAt(timeEvent + 1);
					
					/* Tell the nodes to start until next time event */
					roster->RollNode(writer->Node(), *time, *time2);
					if (filterConnected)
						roster->RollNode(filterNode, *time, *time2);
					if (transitionConnected)
						roster->RollNode(transitionNode, *time, *time2);
					if (reader2Connected)
						roster->RollNode(reader2->Node(), *time, *time2);
					if (reader1Connected)
						roster->RollNode(reader1->Node(), *time, *time2);
					break;
				default:
					break;
			}
		}
	//	release_sem(lock_sem);
	}
	delete writer;
	return B_OK;
}
Esempio n. 5
0
/*****************************************************************************
 * aout_FiltersCreatePipeline: create a filters pipeline to transform a sample
 *                             format to another
 *****************************************************************************
 * TODO : allow the user to add/remove specific filters
 *****************************************************************************/
int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
                                aout_filter_t ** pp_filters,
                                int * pi_nb_filters,
                                const audio_sample_format_t * p_input_format,
                                const audio_sample_format_t * p_output_format )
{
    audio_sample_format_t temp_format;
    int i_nb_conversions;

    if ( AOUT_FMTS_IDENTICAL( p_input_format, p_output_format ) )
    {
        msg_Dbg( p_aout, "no need for any filter" );
        *pi_nb_filters = 0;
        return 0;
    }

    aout_FormatsPrint( p_aout, "filter(s)", p_input_format, p_output_format );

    /* Try to find a filter to do the whole conversion. */
    pp_filters[0] = FindFilter( p_aout, p_input_format, p_output_format );
    if ( pp_filters[0] != NULL )
    {
        msg_Dbg( p_aout, "found a filter for the whole conversion" );
        *pi_nb_filters = 1;
        return 0;
    }

    /* We'll have to split the conversion. We always do the downmixing
     * before the resampling, because the audio decoder can probably do it
     * for us. */
    i_nb_conversions = SplitConversion( p_input_format,
                                        p_output_format, &temp_format );
    if ( !i_nb_conversions )
    {
        /* There was only one conversion to do, and we already failed. */
        msg_Err( p_aout, "couldn't find a filter for the conversion" );
        return -1;
    }

    pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
    if ( pp_filters[0] == NULL && i_nb_conversions == 2 )
    {
        /* Try with only one conversion. */
        SplitConversion( p_input_format, &temp_format, &temp_format );
        pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
    }
    if ( pp_filters[0] == NULL )
    {
        msg_Err( p_aout,
              "couldn't find a filter for the first part of the conversion" );
        return -1;
    }

    /* We have the first stage of the conversion. Find a filter for
     * the rest. */
    pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
                                p_output_format );
    if ( pp_filters[1] == NULL )
    {
        /* Try to split the conversion. */
        i_nb_conversions = SplitConversion( &pp_filters[0]->output,
                                           p_output_format, &temp_format );
        if ( !i_nb_conversions )
        {
            vlc_object_detach( pp_filters[0] );
            vlc_object_destroy( pp_filters[0] );
            msg_Err( p_aout,
              "couldn't find a filter for the second part of the conversion" );
        }
        pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
                                    &temp_format );
        pp_filters[2] = FindFilter( p_aout, &temp_format,
                                    p_output_format );

        if ( pp_filters[1] == NULL || pp_filters[2] == NULL )
        {
            vlc_object_detach( pp_filters[0] );
            vlc_object_destroy( pp_filters[0] );
            if ( pp_filters[1] != NULL )
            {
                vlc_object_detach( pp_filters[1] );
                vlc_object_destroy( pp_filters[1] );
            }
            if ( pp_filters[2] != NULL )
            {
                vlc_object_detach( pp_filters[2] );
                vlc_object_destroy( pp_filters[2] );
            }
            msg_Err( p_aout,
               "couldn't find filters for the second part of the conversion" );
        }
        *pi_nb_filters = 3;
    }
    else
    {
        *pi_nb_filters = 2;
    }

    /* We have enough filters. */
    msg_Dbg( p_aout, "found %d filters for the whole conversion",
             *pi_nb_filters );
    return 0;
}
Esempio n. 6
0
static filter_t *FindConverter (vlc_object_t *obj,
                                const audio_sample_format_t *infmt,
                                const audio_sample_format_t *outfmt)
{
    return FindFilter (obj, "audio converter", NULL, infmt, outfmt);
}
Esempio n. 7
0
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	static DWORD			dwFilters;
	static DWORD			dwpFilters;
	static LPCFOLDERDATA	lpFilterRecord;
	char					strText[250];
	int 					i;

	switch (Msg)
	{
	case WM_INITDIALOG:
	{
		LPTREEFOLDER folder = GetCurrentFolder();
		LPTREEFOLDER lpParent = NULL;
		LPCFILTER_ITEM g_lpFilterList = GetFilterList();

		dwFilters = 0;

		if (folder != NULL)
		{
			char tmp[80];

			win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText);
			Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
			// Mask out non filter flags
			dwFilters = folder->m_dwFlags & F_MASK;
			// Display current folder name in dialog titlebar
			snprintf(tmp,ARRAY_LENGTH(tmp),"Filters for %s Folder",folder->m_lpTitle);
			win_set_window_text_utf8(hDlg, tmp);
			if ( GetFilterInherit() )
			{
				BOOL bShowExplanation = FALSE;
				lpParent = GetFolder( folder->m_nParent );
				if( lpParent )
				{
					/* Check the Parent Filters and inherit them on child,
                     * No need to promote all games to parent folder, works as is */
					dwpFilters = lpParent->m_dwFlags & F_MASK;
					/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/
					if( (dwpFilters & F_CLONES) && !(dwFilters & F_CLONES) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_RASTER) && !(dwFilters & F_RASTER) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_WORKING) && !(dwFilters & F_WORKING) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText);
						bShowExplanation = TRUE;
					}
					if( (dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL) )
					{
						/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
						win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText, 250);
						strcat(strText, " (*)");
						win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText);
						bShowExplanation = TRUE;
					}
					/*Do not or in the Values of the parent, so that the values of the folder still can be set*/
					//dwFilters |= dwpFilters;
				}
				if( ! bShowExplanation )
				{
					ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE );
				}
			}
			else
			{
				ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), FALSE );
			}
			// Find the matching filter record if it exists
			lpFilterRecord = FindFilter(folder->m_nFolderId);

			// initialize and disable appropriate controls
			for (i = 0; g_lpFilterList[i].m_dwFilterType; i++)
			{
				DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
			}
		}
		SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
		return FALSE;
	}
	case WM_HELP:
		// User clicked the ? from the upper right on a control
		HelpFunction((HWND)((LPHELPINFO)lParam)->hItemHandle, MAMEUICONTEXTHELP,
					 HH_TP_HELP_WM_HELP, GetHelpIDs());
		break;

	case WM_CONTEXTMENU:
		HelpFunction((HWND)wParam, MAMEUICONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs());
		break;

	case WM_COMMAND:
	{
		WORD wID		 = GET_WM_COMMAND_ID(wParam, lParam);
		WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
		LPTREEFOLDER folder = GetCurrentFolder();
		LPCFILTER_ITEM g_lpFilterList = GetFilterList();

		switch (wID)
		{
		case IDOK:
			dwFilters = 0;

			win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText, FILTERTEXT_LEN);

			// see which buttons are checked
			for (i = 0; g_lpFilterList[i].m_dwFilterType; i++)
			{
				if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID)))
					dwFilters |= g_lpFilterList[i].m_dwFilterType;
			}

			// Mask out invalid filters
			dwFilters = ValidateFilters(lpFilterRecord, dwFilters);

			// Keep non filter flags
			folder->m_dwFlags &= ~F_MASK;

			// put in the set filters
			folder->m_dwFlags |= dwFilters;

			EndDialog(hDlg, 1);
			return TRUE;

		case IDCANCEL:
			EndDialog(hDlg, 0);
			return TRUE;

		default:
			// Handle unchecking mutually exclusive filters
			if (wNotifyCode == BN_CLICKED)
				EnableFilterExclusions(hDlg, wID);
		}
	}
	break;
	}
	return 0;
}
Esempio n. 8
0
void OpMenuSave::Do(OpDescriptor* pOpDesc)
{
	//First get the selected document
	Document* pdocToSave=Document::GetSelected();
	CCamDoc* pccamdocToSave = pdocToSave->GetOilDoc();

	if (pdocToSave==NULL || pccamdocToSave==NULL)
	{
		ERROR2RAW("No default document!");
		return;
	}

	//And we'll need a pointer to the application
	Application*		pCamelot = GetApplication();
	CTemplateManager&	TemplateManager( pCamelot->GetTemplateManager() );

	//And put the default templates path in the dialog
	PathName			pathToPutInDialog = TemplateManager.GetTemplatesPath();

	FileUtil::RecursiveCreateDirectory( pathToPutInDialog.GetPath() );
	
	//Now create the dialog
	SaveTemplateDialog	dialogToDisplay(pathToPutInDialog);
		
	//And show it
	if (dialogToDisplay.ShowModal() == wxID_OK)
	{
		//Then get the path they specified, using this amazingly bad, confusing and
		//undocumented file dialog code

		//The "CString" reference should ideally go in Winoil
		PathName pathToSaveTo;
		dialogToDisplay.GetChosenFileName(&pathToSaveTo);

		wxString cstrPathToSaveTo=pathToSaveTo.GetPath(FALSE);
		dialogToDisplay.AppendExtension(&cstrPathToSaveTo);

		String_256 strPathToSaveTo=cstrPathToSaveTo;
		pathToSaveTo=strPathToSaveTo;
						
		// Create the save file.
		CCDiskFile file(pathToSaveTo, ios::out | ios::binary | ios::trunc);

		// First find the filter.
		Filter *pFilter = FindFilter ( FILTERID_NATIVE );

		// Tell it to save attributes.
		pFilter->SetSaveAttributes ( TRUE );

		// Then save the image to the file.
		Save ( pFilter, &file );
		
		//Now, if we should make that path the default path
		if (SaveTemplateDialog::m_fUseAsDefault)
		{
			if (pdocToSave->IsAnimated())
			{
				CTemplateManager::SetDefaultAnimationTemplate( strPathToSaveTo );
			}
			else
			{
				CTemplateManager::SetDefaultDrawingTemplate( strPathToSaveTo );
			}
		}

		if (SaveTemplateDialog::m_fDefaultTemplatesFolder)
		{
			String_256	strDefaultPath = pathToSaveTo.GetLocation( TRUE );
			CTemplateManager::SetTemplatesPath( strDefaultPath );
		}
	}

	// Finished the operation
	End();
}
Esempio n. 9
0
_Use_decl_annotations_
NTSTATUS
FilterDeviceIoControl(
    PDEVICE_OBJECT        DeviceObject,
    PIRP                  Irp
    )
{
    PIO_STACK_LOCATION          irp_sp;
    NTSTATUS                    status = STATUS_SUCCESS;
    PFILTER_DEVICE_EXTENSION    filter_device_extension;
    PUCHAR                      input_buffer;
    PUCHAR                      output_buffer;
    ULONG                       input_buffer_length, output_buffer_length;
    PLIST_ENTRY                 link;
    PUCHAR                      info;
    ULONG                       InfoLength = 0;
    PLCXL_FILTER                filter = NULL;
    BOOLEAN                     bFalse = FALSE;


    UNREFERENCED_PARAMETER(DeviceObject);


    irp_sp = IoGetCurrentIrpStackLocation(Irp);

    if (irp_sp->FileObject == NULL) {
        return(STATUS_UNSUCCESSFUL);
    }


    filter_device_extension = (PFILTER_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(DeviceObject);

    ASSERT(filter_device_extension->Signature == 'FTDR');

    Irp->IoStatus.Information = 0;

	input_buffer = output_buffer = (PUCHAR)Irp->AssociatedIrp.SystemBuffer;
	input_buffer_length = output_buffer_length = irp_sp->Parameters.DeviceIoControl.InputBufferLength;

    switch (irp_sp->Parameters.DeviceIoControl.IoControlCode) {

        case IOCTL_FILTER_RESTART_ALL:
            break;

        case IOCTL_FILTER_RESTART_ONE_INSTANCE:
            filter = filterFindFilterModule (input_buffer, input_buffer_length);

            if (filter == NULL) {

                break;
            }
            NdisFRestartFilter(filter->filter_handle);
            break;

        case IOCTL_FILTER_ENUERATE_ALL_INSTANCES:

            info = output_buffer;
			LockLCXLLockList(&g_filter_list);
            
            link = GetListofLCXLLockList(&g_filter_list)->Flink;
			//遍历列表
			while (link != GetListofLCXLLockList(&g_filter_list)) {
                filter = CONTAINING_RECORD(link, LCXL_FILTER, filter_module_link);

                InfoLength += (filter->module_setting->filter_module_name->Length + sizeof(USHORT));

                if (InfoLength <= output_buffer_length) {
					*(PUSHORT)info = filter->module_setting->filter_module_name->Length;
                    NdisMoveMemory(info + sizeof(USHORT),
						(PUCHAR)(filter->module_setting->filter_module_name->Buffer),
						filter->module_setting->filter_module_name->Length);

					info += (filter->module_setting->filter_module_name->Length + sizeof(USHORT));
                }
                link = link->Flink;
            }
			UnlockLCXLLockList(&g_filter_list);
            if (InfoLength <= output_buffer_length) {
                status = NDIS_STATUS_SUCCESS;
            }
            //
            // Buffer is small
            //
            else {
                status = STATUS_BUFFER_TOO_SMALL;
            }
            break;
		//添加代码
		case IOCTL_LOADER_ALL_APP_MODULE:
		{
			PAPP_MODULE_INFO cur_buf;
			PLCXL_MODULE_SETTING_LIST_ENTRY module;

			cur_buf = (PAPP_MODULE_INFO)output_buffer;
			LockLCXLLockList(&g_setting.module_list);
			module = CONTAINING_RECORD(GetListofLCXLLockList(&g_setting.module_list)->Flink, LCXL_MODULE_SETTING_LIST_ENTRY, list_entry);
			while (&module->list_entry != GetListofLCXLLockList(&g_setting.module_list)) {
				//先判断缓冲区是否足够
				if (output_buffer_length - (ULONG)((LONG_PTR)cur_buf - (LONG_PTR)output_buffer) < sizeof(APP_MODULE_INFO)) {
					status = STATUS_BUFFER_TOO_SMALL;
					break;
				}
				cur_buf->app_module_status = module->ref_count == 0 ? AMS_NO_FILTER : AMS_NORMAL;
				FILTER_ACQUIRE_LOCK(&module->lock, bFalse);
				cur_buf->real_addr = module->real_addr;
				cur_buf->virtual_ipv4 = module->virtual_ipv4;
				cur_buf->virtual_ipv6 = module->virtual_ipv6;
				LockLCXLLockList(&module->server_list);
				cur_buf->server_count = GetListCountofLCXLLockList(&module->server_list);
				UnlockLCXLLockList(&module->server_list);
				FILTER_RELEASE_LOCK(&module->lock, bFalse);
				cur_buf->miniport_net_luid = module->miniport_net_luid;

				cur_buf->filter_module_name_len = (sizeof(cur_buf->filter_module_name) < module->filter_module_name->Length) ? sizeof(cur_buf->filter_module_name) : module->filter_module_name->Length;
				RtlCopyMemory(cur_buf->filter_module_name, module->filter_module_name->Buffer, cur_buf->filter_module_name_len);

				cur_buf->miniport_friendly_name_len = (sizeof(cur_buf->miniport_friendly_name) < module->miniport_friendly_name->Length) ? sizeof(cur_buf->miniport_friendly_name) : module->miniport_friendly_name->Length;
				RtlCopyMemory(cur_buf->miniport_friendly_name, module->miniport_friendly_name->Buffer, cur_buf->miniport_friendly_name_len);

				cur_buf->miniport_name_len = (sizeof(cur_buf->miniport_name) < module->miniport_name->Length) ? sizeof(cur_buf->miniport_name) : module->miniport_name->Length;
				RtlCopyMemory(cur_buf->miniport_name, module->miniport_name->Buffer, cur_buf->miniport_name_len);

				cur_buf++;
				module = CONTAINING_RECORD(module->list_entry.Flink, LCXL_MODULE_SETTING_LIST_ENTRY, list_entry);
			}
			UnlockLCXLLockList(&g_setting.module_list);
			InfoLength = (ULONG)((ULONG_PTR)cur_buf - (ULONG_PTR)output_buffer);
		}
			break;
		case IOCTL_LOADER_SET_VIRTUAL_IP:
			if (input_buffer_length == sizeof(APP_IP)) {
				PAPP_IP ip;
				PLCXL_FILTER pFilter;

				ip = (PAPP_IP)input_buffer;
				LockLCXLLockList(&g_filter_list);
				pFilter = FindFilter(ip->miniport_net_luid);
				if (pFilter != NULL) {
					NdisAcquireSpinLock(&pFilter->module_setting->lock);
					switch (ip->ip.ip_mode) {
						//IPv4模式
					case IM_IPV4:
						pFilter->module_setting->virtual_ipv4 = ip->ip.addr.ip_4;
						break;
						//IPv6模式
					case IM_IPV6:
						pFilter->module_setting->virtual_ipv6 = ip->ip.addr.ip_6;
						break;
					default:
						status = STATUS_INVALID_PARAMETER;
						break;
					}
					NdisReleaseSpinLock(&pFilter->module_setting->lock);
				}
				
				UnlockLCXLLockList(&g_filter_list);
			} else {
				status = STATUS_INFO_LENGTH_MISMATCH;
			}
			break;
		case IOCTL_LOADER_GET_SERVER_LIST:
			if (input_buffer_length == sizeof(NET_LUID)) {
				PLCXL_FILTER pFilter;

				LockLCXLLockList(&g_filter_list); 
				pFilter = FindFilter(*(PNET_LUID)input_buffer);
				if (pFilter != NULL) {
					if (pFilter->module_setting != NULL && (pFilter->module_setting->flag & MSF_DELETE_AFTER_RESTART) == 0) {
						
					} else {
						status = STATUS_NOT_FOUND;
					}
				} else {
					status = STATUS_NOT_FOUND;
				}
				UnlockLCXLLockList(&g_filter_list);
			} else {
				status = STATUS_INFO_LENGTH_MISMATCH;
			}
			break;
		case IOCTL_LOADER_ADD_SERVER:
			if (sizeof(APP_ADD_SERVER) == input_buffer_length) {
				PAPP_ADD_SERVER app_add_server;
				PLCXL_FILTER pFilter;
				
				app_add_server = (PAPP_ADD_SERVER)input_buffer;
				LockLCXLLockList(&g_filter_list);
				pFilter = FindFilter(app_add_server->miniport_net_luid);
				if (pFilter != NULL) {
					
					LockLCXLLockList(&pFilter->module_setting->server_list);
					
					
					UnlockLCXLLockList(&pFilter->module_setting->server_list);
				}
				UnlockLCXLLockList(&g_filter_list);
			} else {
				status = STATUS_INFO_LENGTH_MISMATCH;
			}
			break;
		case IOCTL_LOADER_DEL_SERVER:
			if (sizeof(APP_DEL_SERVER) == input_buffer_length) {
				PAPP_DEL_SERVER app_del_server = (PAPP_DEL_SERVER)input_buffer;
				PLCXL_FILTER pFilter;

				LockLCXLLockList(&g_filter_list);
				pFilter = FindFilter(app_del_server->miniport_net_luid);
				UnlockLCXLLockList(&g_filter_list);
				
			} else {
				status = STATUS_INFO_LENGTH_MISMATCH;
			}
			break;
		//!添加代码!
        default:
			status = STATUS_INVALID_PARAMETER;
            break;
    }

    Irp->IoStatus.Status = status;
    Irp->IoStatus.Information = InfoLength;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    return status;
}
Esempio n. 10
0
/*****************************************************************************
 * aout_FiltersCreatePipeline: create a filters pipeline to transform a sample
 *                             format to another
 *****************************************************************************
 * pi_nb_filters must be initialized before calling this function
 *****************************************************************************/
int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
                                aout_filter_t ** pp_filters_start,
                                int * pi_nb_filters,
                                const audio_sample_format_t * p_input_format,
                                const audio_sample_format_t * p_output_format )
{
    aout_filter_t** pp_filters = pp_filters_start + *pi_nb_filters;
    audio_sample_format_t temp_format;
    int i_nb_conversions;

    if ( AOUT_FMTS_IDENTICAL( p_input_format, p_output_format ) )
    {
        msg_Dbg( p_aout, "no need for any filter" );
        return 0;
    }

    aout_FormatsPrint( p_aout, "filter(s)", p_input_format, p_output_format );

    if( *pi_nb_filters + 1 > AOUT_MAX_FILTERS )
    {
        msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
        return -1;
    }

    /* Try to find a filter to do the whole conversion. */
    pp_filters[0] = FindFilter( p_aout, p_input_format, p_output_format );
    if ( pp_filters[0] != NULL )
    {
        msg_Dbg( p_aout, "found a filter for the whole conversion" );
        ++*pi_nb_filters;
        return 0;
    }

    /* We'll have to split the conversion. We always do the downmixing
     * before the resampling, because the audio decoder can probably do it
     * for us. */
    i_nb_conversions = SplitConversion( p_input_format,
                                        p_output_format, &temp_format );
    if ( !i_nb_conversions )
    {
        /* There was only one conversion to do, and we already failed. */
        msg_Err( p_aout, "couldn't find a filter for the conversion" );
        return -1;
    }

    pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
    if ( pp_filters[0] == NULL && i_nb_conversions == 2 )
    {
        /* Try with only one conversion. */
        SplitConversion( p_input_format, &temp_format, &temp_format );
        pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
    }
    if ( pp_filters[0] == NULL )
    {
        msg_Err( p_aout,
              "couldn't find a filter for the first part of the conversion" );
        return -1;
    }

    /* We have the first stage of the conversion. Find a filter for
     * the rest. */
    if( *pi_nb_filters + 2 > AOUT_MAX_FILTERS )
    {
        ReleaseFilter( pp_filters[0] );
        msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
        return -1;
    }
    pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
                                p_output_format );
    if ( pp_filters[1] == NULL )
    {
        /* Try to split the conversion. */
        i_nb_conversions = SplitConversion( &pp_filters[0]->output,
                                           p_output_format, &temp_format );
        if ( !i_nb_conversions )
        {
            ReleaseFilter( pp_filters[0] );
            msg_Err( p_aout,
              "couldn't find a filter for the second part of the conversion" );
            return -1;
        }
        if( *pi_nb_filters + 3 > AOUT_MAX_FILTERS )
        {
            ReleaseFilter( pp_filters[0] );
            msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
            return -1;
        }
        pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
                                    &temp_format );
        pp_filters[2] = FindFilter( p_aout, &temp_format,
                                    p_output_format );

        if ( pp_filters[1] == NULL || pp_filters[2] == NULL )
        {
            ReleaseFilter( pp_filters[0] );
            if ( pp_filters[1] != NULL )
            {
                ReleaseFilter( pp_filters[1] );
            }
            if ( pp_filters[2] != NULL )
            {
                ReleaseFilter( pp_filters[2] );
            }
            msg_Err( p_aout,
               "couldn't find filters for the second part of the conversion" );
            return -1;
        }
        *pi_nb_filters += 3;
        msg_Dbg( p_aout, "found 3 filters for the whole conversion" );
    }
    else
    {
        *pi_nb_filters += 2;
        msg_Dbg( p_aout, "found 2 filters for the whole conversion" );
    }

    return 0;
}
Esempio n. 11
0
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	switch (Msg)
	{
		case WM_INITDIALOG:
		{
			CenterWindow(hDlg);
			hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
			hBrush = CreateSolidBrush(RGB(240, 240, 240));
			DisableVisualStylesFilters(hDlg);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPTREEFOLDER lpParent = NULL;
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();
			dwFilters = 0;

			if (folder != NULL)
			{
				char tmp[80];
				win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str());
				Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
				// Mask out non filter flags
				dwFilters = folder->m_dwFlags & F_MASK;
				// Display current folder name in dialog titlebar
				snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle);
				win_set_window_text_utf8(hDlg, tmp);

				if (GetFilterInherit())
				{
					lpParent = GetFolder(folder->m_nParent);
					bool bShowExplanation = false;

					if (lpParent)
					{
						std::string strText;
						/* Check the Parent Filters and inherit them on child,
						* No need to promote all games to parent folder, works as is */
						dwpFilters = lpParent->m_dwFlags & F_MASK;
						/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/

						if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str());
							bShowExplanation = true;
						}

						if ((dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL))
						{
							/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
							strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL));
							strText.append(" (*)");
							win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str());
							bShowExplanation = true;
						}
						/*Do not or in the Values of the parent, so that the values of the folder still can be set*/
						//dwFilters |= dwpFilters;
					}

					if(bShowExplanation)
					{
						ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), true);
					}
				}
				else
				{
					ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false);
				}

				// Find the matching filter record if it exists
				lpFilterRecord = FindFilter(folder->m_nFolderId);

				// initialize and disable appropriate controls
				for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
				{
					DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters);
				}
			}

			SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT));
			return false;
		}

		case WM_CTLCOLORDLG:
			return (LRESULT) hBrush;	

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLORBTN:
			hDC = (HDC)wParam;
			SetBkMode(hDC, TRANSPARENT);
			SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
			return (LRESULT) hBrush;

		case WM_COMMAND:
		{
			WORD wID = GET_WM_COMMAND_ID(wParam, lParam);
			WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam);
			LPTREEFOLDER folder = GetCurrentFolder();
			LPCFILTER_ITEM g_lpFilterList = GetFilterList();

			switch (wID)
			{
				case IDOK:
					dwFilters = 0;
					g_FilterText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT));

					// see which buttons are checked
					for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++)
					{
						if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID)))
							dwFilters |= g_lpFilterList[i].m_dwFilterType;
					}

					// Mask out invalid filters
					dwFilters = ValidateFilters(lpFilterRecord, dwFilters);
					// Keep non filter flags
					folder->m_dwFlags &= ~F_MASK;
					// put in the set filters
					folder->m_dwFlags |= dwFilters;
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 1);
					return true;

				case IDCANCEL:
					DestroyIcon(hIcon);
					DeleteObject(hBrush);
					EndDialog(hDlg, 0);
					return true;

				default:
					// Handle unchecking mutually exclusive filters
					if (wNotifyCode == BN_CLICKED)
						EnableFilterExclusions(hDlg, wID);
			}

			break;
		}
	}

	return false;
}