Exemple #1
0
bool Component::tunnelToNull(int port)
{
    bool result = false;
    OMX_ERRORTYPE error;
    if(CustomFillBufferDoneHandler)
    {
        CustomFillBufferDoneHandler = NULL;
    }
    
    if(setToStateIdle())
    {
        disableAllPorts();
        if(getName() != "OMX.broadcom.clock" &&
           getName() != "OMX.broadcom.audio_render" &&
           getName() != "OMX.broadcom.audio_mixer")
        {
            error = OMX_SetupTunnel(handle, port, NULL, 0);
            OMX_TRACE(error);
            if(error == OMX_ErrorNone)
            {
                result = true;  
            } 
        }else
        {
            result = true; 
        }
        
        
    }
    ofLogVerbose(__func__) << getName() << " TUNNELED TO NULL: " << result;
    return result;
    
}
Exemple #2
0
MidiInputController::~MidiInputController() {
    if (logFileCreated)
    {
        midiLog.close();
    }
    disableAllPorts();
}
Exemple #3
0
bool Component::init( std::string& component_name, OMX_INDEXTYPE index)
{

	componentName = component_name;

	callbacks.EventHandler    = &Component::EventHandlerCallback;
	callbacks.EmptyBufferDone = &Component::EmptyBufferDoneCallback;
	callbacks.FillBufferDone  = &Component::FillBufferDoneCallback;

	// Get video component handle setting up callbacks, component is in loaded state on return.
	OMX_ERRORTYPE error = OMX_GetHandle(&handle, (char*)component_name.c_str(), this, &callbacks);
    OMX_TRACE(error);
    
	if (error != OMX_ErrorNone)
	{
        ofLogError(__func__) << componentName << " FAIL ";
		return false;
	}
    
    
	OMX_PORT_PARAM_TYPE port_param;
	OMX_INIT_STRUCTURE(port_param);

	error = OMX_GetParameter(handle, index, &port_param);
    OMX_TRACE(error);


	disableAllPorts();


	inputPort  = port_param.nStartPortNumber;
	outputPort = inputPort + 1;

	if(componentName == "OMX.broadcom.audio_mixer")
	{
		inputPort  = 232;
		outputPort = 231;
	}

	if (outputPort > port_param.nStartPortNumber+port_param.nPorts-1)
	{
		outputPort = port_param.nStartPortNumber+port_param.nPorts-1;
	}

	return true;
}
Exemple #4
0
Component::~Component()
{
    
    ofLogVerbose(__func__) << getName();
    OMX_ERRORTYPE error;

    if(handle)
    {
        for (size_t i = 0; i < inputBuffers.size(); i++)
        {
            error = OMX_FreeBuffer(handle, inputPort, inputBuffers[i]);
            OMX_TRACE(error);
        }
       
    }
    
    while (!inputBuffersAvailable.empty())
    {
        inputBuffersAvailable.pop();
    }
    inputBuffers.clear();
    
    //if(componentName != "OMX.broadcom.video_decode")
    //{
        
    if (doFreeHandle) 
    {
        
        error = OMX_FreeHandle(handle);
        OMX_TRACE(error); 
        ofLogVerbose(__func__) << componentName << " FREED";
    }else
    {
        stringstream info;
        
        OMX_STATETYPE currentState;
        OMX_GetState(handle, &currentState);
        
        
        OMX_PARAM_U32TYPE extra_buffers;
        OMX_INIT_STRUCTURE(extra_buffers);
        
        error = getParameter(OMX_IndexParamBrcmExtraBuffers, &extra_buffers);
        OMX_TRACE(error);
        info << "currentState: " << GetOMXStateString(currentState) << endl;
        info << "PRE extra_buffers.nU32: " << (int)extra_buffers.nU32 << endl;
       
        extra_buffers.nU32 = 0;
        error = setParameter(OMX_IndexParamBrcmExtraBuffers, &extra_buffers);
        OMX_TRACE(error);
        
        error = getParameter(OMX_IndexParamBrcmExtraBuffers, &extra_buffers);
        info << "POST extra_buffers.nU32: " << (int)extra_buffers.nU32 << endl;
        
        flushAll();
        
        disableAllPorts();
        ofLogVerbose(__func__) << info.str();
        //error = OMX_FreeHandle(handle);
        //OMX_TRACE(error); 
        //ofLogVerbose(__func__) << info.str() << " " << componentName << " FREED";

    }

    //}
    
    handle = NULL;
    
    
    //error =  waitForCommand(OMX_CommandPortDisable, inputPort);
    //OMX_TRACE(error);
    
  
 
	pthread_mutex_destroy(&m_omx_input_mutex);
	pthread_mutex_destroy(&m_omx_output_mutex);
	pthread_mutex_destroy(&event_mutex);
	pthread_mutex_destroy(&eos_mutex);
	pthread_cond_destroy(&m_input_buffer_cond);
	pthread_cond_destroy(&m_output_buffer_cond);
	pthread_cond_destroy(&m_omx_event_cond);

	pthread_mutex_destroy(&m_lock);
	sem_destroy(&m_omx_fill_buffer_done);

}