m_eEncoding (OMX_AUDIO_CodingPCM),
m_extradata (NULL ),
m_extrasize (0 ),
+ m_omx_render (NULL ),
m_last_pts (DVD_NOPTS_VALUE)
{
m_vizBufferSize = m_vizRemapBufferSize = VIS_PACKET_SIZE * sizeof(float);
std::string componentName = "";
componentName = "OMX.broadcom.audio_render";
- if(!m_omx_render.Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
+ m_omx_render = new COMXCoreComponent();
+ if(!m_omx_render)
+ {
+ CLog::Log(LOGERROR, "COMXAudio::Initialize error allocate OMX.broadcom.audio_render\n");
+ return false;
+ }
+
+ if(!m_omx_render->Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
return false;
OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
OMX_INIT_STRUCTURE(audioDest);
strncpy((char *)audioDest.sName, device.c_str(), strlen(device.c_str()));
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
+ omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
if (omx_err != OMX_ErrorNone)
return false;
OMX_INIT_STRUCTURE(configBool);
configBool.bEnabled = OMX_FALSE;
- omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
+ omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
if (omx_err != OMX_ErrorNone)
return false;
return false;
}
+ OMX_CONFIG_BOOLEANTYPE boolType;
+ OMX_INIT_STRUCTURE(boolType);
if(m_Passthrough)
- {
- OMX_CONFIG_BOOLEANTYPE boolType;
- OMX_INIT_STRUCTURE(boolType);
boolType.bEnabled = OMX_TRUE;
- omx_err = m_omx_decoder.SetParameter(OMX_IndexParamBrcmDecoderPassThrough, &boolType);
- if(omx_err != OMX_ErrorNone)
- {
- CLog::Log(LOGERROR, "COMXAudio::Initialize - Error OMX_IndexParamBrcmDecoderPassThrough 0x%08x", omx_err);
- return false;
- }
+ else
+ boolType.bEnabled = OMX_FALSE;
+ omx_err = m_omx_decoder.SetParameter(OMX_IndexParamBrcmDecoderPassThrough, &boolType);
+ if(omx_err != OMX_ErrorNone)
+ {
+ CLog::Log(LOGERROR, "COMXAudio::Initialize - Error OMX_IndexParamBrcmDecoderPassThrough 0x%08x", omx_err);
+ return false;
}
// set up the number/size of buffers
return false;
}
- if(m_HWDecode)
+ //if(m_HWDecode)
{
OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
OMX_INIT_STRUCTURE(formatType);
}
}
- m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), &m_omx_render, m_omx_render.GetInputPort()+1);
+ m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), m_omx_render, m_omx_render->GetInputPort()+1);
omx_err = m_omx_tunnel_clock.Establish(false);
if(omx_err != OMX_ErrorNone)
return false;
}
- m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+ m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
omx_err = m_omx_tunnel_mixer.Establish(false);
if(omx_err != OMX_ErrorNone)
{
}
else
{
- m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+ m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
omx_err = m_omx_tunnel_decoder.Establish(false);
if(omx_err != OMX_ErrorNone)
{
}
}
- omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
+ omx_err = m_omx_render->SetStateForComponent(OMX_StateExecuting);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
return false;
}
+ m_omx_decoder.EnablePort(m_omx_decoder.GetInputPort(), true);
+
if(m_eEncoding == OMX_AUDIO_CodingPCM)
{
OMX_BUFFERHEADERTYPE *omx_buffer = m_omx_decoder.GetInputBuffer();
if(!m_Initialized)
return true;
- /*
- if(m_av_clock && !m_external_clock)
- m_av_clock->OMXStop();
- */
+ CSingleLock lock (m_critSection);
if(m_av_clock && !m_external_clock)
{
m_omx_decoder.FlushInput();
- m_omx_render.Deinitialize();
+ m_omx_render->Deinitialize();
if(!m_Passthrough)
m_omx_mixer.Deinitialize();
m_omx_decoder.Deinitialize();
- m_Initialized = false;
m_BytesPerSec = 0;
m_BufferLen = 0;
{
m_av_clock->OMXReset(false);
m_av_clock->UnLock();
- }
-
- if(!m_external_clock && m_av_clock != NULL)
- {
delete m_av_clock;
- m_av_clock = NULL;
m_external_clock = false;
}
m_first_frame = true;
m_last_pts = DVD_NOPTS_VALUE;
+ delete m_omx_render;
+ m_omx_render = NULL;
+
return true;
}
//***********************************************************************************************
bool COMXAudio::SetCurrentVolume(float fVolume)
{
+ CSingleLock lock (m_critSection);
+
if(!m_Initialized || m_Passthrough)
return -1;
OMX_AUDIO_CONFIG_VOLUMETYPE volume;
OMX_INIT_STRUCTURE(volume);
- volume.nPortIndex = m_omx_render.GetInputPort();
+ volume.nPortIndex = m_omx_render->GetInputPort();
volume.bLinear = OMX_TRUE;
float hardwareVolume = std::max(VOLUME_MINIMUM, std::min(VOLUME_MAXIMUM, fVolume)) * 100.0f;
volume.sVolume.nValue = (int)hardwareVolume;
- m_omx_render.SetConfig(OMX_IndexConfigAudioVolume, &volume);
+ m_omx_render->SetConfig(OMX_IndexConfigAudioVolume, &volume);
return true;
}
//***********************************************************************************************
unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dts, double pts)
{
+ CSingleLock lock (m_critSection);
+
if(!m_Initialized)
{
CLog::Log(LOGERROR,"COMXAudio::AddPackets - sanity failed. no valid play handle!");
m_first_frame = false;
//m_omx_render.WaitForEvent(OMX_EventPortSettingsChanged);
- m_omx_render.DisablePort(m_omx_render.GetInputPort(), false);
+ m_omx_render->DisablePort(m_omx_render->GetInputPort(), false);
if(!m_Passthrough)
{
m_omx_mixer.DisablePort(m_omx_mixer.GetOutputPort(), false);
m_pcm_output.nSamplingRate = m_format.m_sampleRate;
- m_pcm_output.nPortIndex = m_omx_render.GetInputPort();
- omx_err = m_omx_render.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
+ m_pcm_output.nPortIndex = m_omx_render->GetInputPort();
+ omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 render omx_err(0x%08x)\n", omx_err);
}
- omx_err = m_omx_render.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
+ omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 render omx_err(0x%08x)\n", omx_err);
}
else
{
- m_pcm_output.nPortIndex = m_omx_decoder.GetOutputPort();
- m_omx_decoder.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
- PrintPCM(&m_pcm_output, std::string("output"));
-
OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
OMX_INIT_STRUCTURE(formatType);
- formatType.nPortIndex = m_omx_render.GetInputPort();
+ formatType.nPortIndex = m_omx_render->GetInputPort();
- omx_err = m_omx_render.GetParameter(OMX_IndexParamAudioPortFormat, &formatType);
+ omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPortFormat, &formatType);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
formatType.eEncoding = m_eEncoding;
- omx_err = m_omx_render.SetParameter(OMX_IndexParamAudioPortFormat, &formatType);
+ omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPortFormat, &formatType);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
OMX_AUDIO_PARAM_DDPTYPE m_ddParam;
OMX_INIT_STRUCTURE(m_ddParam);
- m_ddParam.nPortIndex = m_omx_render.GetInputPort();
+ m_ddParam.nPortIndex = m_omx_render->GetInputPort();
m_ddParam.nChannels = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
m_ddParam.nSampleRate = m_SampleRate;
m_ddParam.eChannelMapping[i] = OMXChannels[i];
}
- m_omx_render.SetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
- m_omx_render.GetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
+ m_omx_render->SetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
+ m_omx_render->GetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
PrintDDP(&m_ddParam);
}
else if(m_eEncoding == OMX_AUDIO_CodingDTS)
{
- m_dtsParam.nPortIndex = m_omx_render.GetInputPort();
+ m_dtsParam.nPortIndex = m_omx_render->GetInputPort();
m_dtsParam.nChannels = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
m_dtsParam.nBitRate = 0;
m_dtsParam.eChannelMapping[i] = OMXChannels[i];
}
- m_omx_render.SetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
- m_omx_render.GetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
+ m_omx_render->SetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
+ m_omx_render->GetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
PrintDTS(&m_dtsParam);
}
}
- m_omx_render.EnablePort(m_omx_render.GetInputPort(), false);
+ m_omx_render->EnablePort(m_omx_render->GetInputPort(), false);
if(!m_Passthrough)
{
m_omx_mixer.EnablePort(m_omx_mixer.GetOutputPort(), false);
unsigned int COMXAudio::GetAudioRenderingLatency()
{
+ if(!m_Initialized)
+ return 0;
+
OMX_PARAM_U32TYPE param;
OMX_INIT_STRUCTURE(param);
- param.nPortIndex = m_omx_render.GetInputPort();
+ param.nPortIndex = m_omx_render->GetInputPort();
OMX_ERRORTYPE omx_err =
- m_omx_render.GetConfig(OMX_IndexConfigAudioRenderingLatency, ¶m);
+ m_omx_render->GetConfig(OMX_IndexConfigAudioRenderingLatency, ¶m);
if(omx_err != OMX_ErrorNone)
{
void COMXAudio::WaitCompletion()
{
+ CSingleLock lock (m_critSection);
+
if(!m_Initialized || m_Pause)
return;
unsigned int nTimeOut = AUDIO_BUFFER_SECONDS * 1000;
while(nTimeOut)
{
- if(m_omx_render.IsEOS())
+ if(m_omx_render->IsEOS())
break;
if(nTimeOut == 0)
m_av_clock->Lock();
m_av_clock->OMXStop(false);
- m_omxVideo.Close();
m_av_clock->HasVideo(false);
+ m_omxVideo.Close();
m_av_clock->OMXReset(false);
m_av_clock->UnLock();
m_av_clock->Lock();
m_av_clock->OMXStop(false);
- if(!m_omxVideo.Open(m_hints, m_av_clock, m_Deinterlace, m_hdmi_clock_sync))
+
+ bool bVideoDecoderOpen = m_omxVideo.Open(m_hints, m_av_clock, m_Deinterlace, m_hdmi_clock_sync);
+
+ if(!bVideoDecoderOpen)
{
CLog::Log(LOGERROR, "OMXPlayerAudio : Error open video output");
- m_av_clock->HasVideo(false);
- m_av_clock->OMXReset(false);
- m_av_clock->UnLock();
- return false;
+ m_omxVideo.Close();
}
else
+ {
CLog::Log(LOGINFO, "OMXPlayerVideo::OpenDecoder : Video codec %s width %d height %d profile %d fps %f\n",
m_omxVideo.GetDecoderName().c_str() , m_hints.width, m_hints.height, m_hints.profile, m_fFrameRate);
- m_codecname = m_omxVideo.GetDecoderName();
+ m_codecname = m_omxVideo.GetDecoderName();
- // if we are closer to ntsc version of framerate, let gpu know
- int iFrameRate = (int)(m_fFrameRate + 0.5f);
- bool bNtscFreq = fabs(m_fFrameRate * 1001.0f / 1000.0f - iFrameRate) < fabs(m_fFrameRate - iFrameRate);
- char response[80], command[80];
- sprintf(command, "hdmi_ntsc_freqs %d", bNtscFreq);
- CLog::Log(LOGINFO, "OMXPlayerVideo::OpenDecoder fps: %f %s\n", m_fFrameRate, command);
- m_DllBcmHost.vc_gencmd(response, sizeof response, command);
+ // if we are closer to ntsc version of framerate, let gpu know
+ int iFrameRate = (int)(m_fFrameRate + 0.5f);
+ bool bNtscFreq = fabs(m_fFrameRate * 1001.0f / 1000.0f - iFrameRate) < fabs(m_fFrameRate - iFrameRate);
+ char response[80], command[80];
+ sprintf(command, "hdmi_ntsc_freqs %d", bNtscFreq);
+ CLog::Log(LOGINFO, "OMXPlayerVideo::OpenDecoder fps: %f %s\n", m_fFrameRate, command);
+ m_DllBcmHost.vc_gencmd(response, sizeof response, command);
- if(m_av_clock)
- m_av_clock->SetRefreshRate(m_fFrameRate);
+ if(m_av_clock)
+ m_av_clock->SetRefreshRate(m_fFrameRate);
+ }
- m_av_clock->HasVideo(true);
+ m_av_clock->HasVideo(bVideoDecoderOpen);
m_av_clock->OMXReset(false);
m_av_clock->UnLock();
- return true;
+ return bVideoDecoderOpen;
}
int OMXPlayerVideo::GetDecoderBufferSize()