Skip to content

Commit

Permalink
[rbp/omxplayer] Cosmetic: Remove option to deinit a component without…
Browse files Browse the repository at this point in the history
… freeing it

We always free a component when deiniting, so remove the option to avoid a way of leaking resources
  • Loading branch information
popcornmix committed Nov 25, 2013
1 parent 19c4438 commit 4efa4c5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
10 changes: 5 additions & 5 deletions xbmc/cores/omxplayer/OMXAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,15 @@ bool COMXAudio::Deinitialize()

m_omx_decoder.FlushInput();

m_omx_decoder.Deinitialize(true);
m_omx_decoder.Deinitialize();
if ( m_omx_mixer.IsInitialized() )
m_omx_mixer.Deinitialize(true);
m_omx_mixer.Deinitialize();
if ( m_omx_splitter.IsInitialized() )
m_omx_splitter.Deinitialize(true);
m_omx_splitter.Deinitialize();
if ( m_omx_render_hdmi.IsInitialized() )
m_omx_render_hdmi.Deinitialize(true);
m_omx_render_hdmi.Deinitialize();
if ( m_omx_render_analog.IsInitialized() )
m_omx_render_analog.Deinitialize(true);
m_omx_render_analog.Deinitialize();

m_BytesPerSec = 0;
m_BufferLen = 0;
Expand Down
18 changes: 9 additions & 9 deletions xbmc/cores/omxplayer/OMXImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,9 @@ void COMXImageDec::Close()
if(m_omx_tunnel_decode.IsInitialized())
m_omx_tunnel_decode.Deestablish();
if(m_omx_decoder.IsInitialized())
m_omx_decoder.Deinitialize(true);
m_omx_decoder.Deinitialize();
if(m_omx_resize.IsInitialized())
m_omx_resize.Deinitialize(true);
m_omx_resize.Deinitialize();
}

bool COMXImageDec::HandlePortSettingChange(unsigned int resize_width, unsigned int resize_height)
Expand Down Expand Up @@ -1189,7 +1189,7 @@ COMXImageEnc::~COMXImageEnc()
OMX_INIT_STRUCTURE(m_encoded_format);
m_encoded_buffer = NULL;
if(m_omx_encoder.IsInitialized())
m_omx_encoder.Deinitialize(true);
m_omx_encoder.Deinitialize();
}

bool COMXImageEnc::Encode(unsigned char *buffer, int size, unsigned width, unsigned height, unsigned int pitch)
Expand Down Expand Up @@ -1435,11 +1435,11 @@ void COMXImageReEnc::Close()
if(m_omx_tunnel_resize.IsInitialized())
m_omx_tunnel_resize.Deestablish();
if(m_omx_decoder.IsInitialized())
m_omx_decoder.Deinitialize(true);
m_omx_decoder.Deinitialize();
if(m_omx_resize.IsInitialized())
m_omx_resize.Deinitialize(true);
m_omx_resize.Deinitialize();
if(m_omx_encoder.IsInitialized())
m_omx_encoder.Deinitialize(true);
m_omx_encoder.Deinitialize();
}


Expand Down Expand Up @@ -1824,11 +1824,11 @@ void COMXTexture::Close()
m_omx_tunnel_egl.Deestablish();
// delete components
if (m_omx_decoder.IsInitialized())
m_omx_decoder.Deinitialize(true);
m_omx_decoder.Deinitialize();
if (m_omx_resize.IsInitialized())
m_omx_resize.Deinitialize(true);
m_omx_resize.Deinitialize();
if (m_omx_egl_render.IsInitialized())
m_omx_egl_render.Deinitialize(true);
m_omx_egl_render.Deinitialize();
}

bool COMXTexture::HandlePortSettingChange(unsigned int resize_width, unsigned int resize_height, void *egl_image, void *egl_display, bool port_settings_changed)
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/omxplayer/OMXVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ void COMXVideo::Close()

m_omx_decoder.FlushInput();

m_omx_sched.Deinitialize(true);
m_omx_decoder.Deinitialize(true);
m_omx_sched.Deinitialize();
m_omx_decoder.Deinitialize();
if(m_deinterlace)
m_omx_image_fx.Deinitialize(true);
m_omx_render.Deinitialize(true);
m_omx_image_fx.Deinitialize();
m_omx_render.Deinitialize();

m_is_open = false;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/linux/OMXClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void OMXClock::OMXDeinitialize()
if(m_omx_clock.GetComponent() == NULL)
return;

m_omx_clock.Deinitialize(true);
m_omx_clock.Deinitialize();

m_omx_speed = DVD_PLAYSPEED_NORMAL;
}
Expand Down
33 changes: 15 additions & 18 deletions xbmc/linux/OMXCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ COMXCoreComponent::COMXCoreComponent()

COMXCoreComponent::~COMXCoreComponent()
{
Deinitialize(true);
Deinitialize();

pthread_mutex_destroy(&m_omx_input_mutex);
pthread_mutex_destroy(&m_omx_output_mutex);
Expand Down Expand Up @@ -1442,7 +1442,7 @@ bool COMXCoreComponent::Initialize( const std::string &component_name, OMX_INDEX
{
CLog::Log(LOGERROR, "COMXCoreComponent::Initialize - could not get component handle for %s omx_err(0x%08x)\n",
component_name.c_str(), (int)omx_err);
Deinitialize(true);
Deinitialize();
return false;
}
}
Expand Down Expand Up @@ -1501,7 +1501,7 @@ void COMXCoreComponent::ResetEos()
pthread_mutex_unlock(&m_omx_eos_mutex);
}

bool COMXCoreComponent::Deinitialize(bool free_component /* = false */)
bool COMXCoreComponent::Deinitialize()
{
OMX_ERRORTYPE omx_err;

Expand All @@ -1519,23 +1519,20 @@ bool COMXCoreComponent::Deinitialize(bool free_component /* = false */)

TransitionToStateLoaded();

if(free_component)
CLog::Log(LOGDEBUG, "COMXCoreComponent::Deinitialize : %s handle %p\n",
m_componentName.c_str(), m_handle);
omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
if (omx_err != OMX_ErrorNone)
{
CLog::Log(LOGDEBUG, "COMXCoreComponent::Deinitialize : %s handle %p\n",
m_componentName.c_str(), m_handle);
omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
if (omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::Deinitialize - failed to free handle for component %s omx_err(0x%08x)",
m_componentName.c_str(), omx_err);
}
m_handle = NULL;

m_input_port = 0;
m_output_port = 0;
m_componentName = "";
m_resource_error = false;
CLog::Log(LOGERROR, "COMXCoreComponent::Deinitialize - failed to free handle for component %s omx_err(0x%08x)",
m_componentName.c_str(), omx_err);
}
m_handle = NULL;

m_input_port = 0;
m_output_port = 0;
m_componentName = "";
m_resource_error = false;
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/linux/OMXCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class COMXCoreComponent

bool Initialize( const std::string &component_name, OMX_INDEXTYPE index);
bool IsInitialized();
bool Deinitialize(bool free_component = false);
bool Deinitialize();

// OMXCore Decoder delegate callback routines.
static OMX_ERRORTYPE DecoderEventHandlerCallback(OMX_HANDLETYPE hComponent, OMX_PTR pAppData,
Expand Down

0 comments on commit 4efa4c5

Please sign in to comment.