From b48cbd4906afa39b60dacfce7dfd4239207a9b78 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 27 Apr 2016 22:07:08 +0100 Subject: [PATCH] omxplayer: Avoid CAEFactory::Suspend which should only be called by application --- xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp | 14 +++++++++++--- xbmc/cores/omxplayer/OMXAudio.cpp | 15 +++++++++++---- xbmc/cores/omxplayer/OMXAudio.h | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp index 214468398fb57..dc6ef06168e87 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp @@ -217,8 +217,6 @@ bool CAESinkPi::Initialize(AEAudioFormat &format, std::string &device) format.m_sampleRate = std::max(8000U, std::min(192000U, format.m_sampleRate)); format.m_frames = format.m_sampleRate * m_latency / NUM_OMX_BUFFERS; - SetAudioProps(m_passthrough, GetChannelMap(format.m_channelLayout, m_passthrough)); - m_format = format; m_sinkbuffer_sec_per_byte = 1.0 / (double)(m_format.m_frameSize * m_format.m_sampleRate); @@ -226,6 +224,12 @@ bool CAESinkPi::Initialize(AEAudioFormat &format, std::string &device) m_format.m_dataFormat, channels, m_format.m_sampleRate, m_format.m_frameSize, m_format.m_frameSize * m_format.m_frames, 1.0/m_sinkbuffer_sec_per_byte, CSettings::GetInstance().GetString(CSettings::SETTING_AUDIOOUTPUT_AUDIODEVICE).c_str()); + // magic value used when omxplayer is playing - want sink to be disabled + if (m_passthrough && m_format.m_streamInfo.m_sampleRate == 16000) + return true; + + SetAudioProps(m_passthrough, GetChannelMap(m_format.m_channelLayout, m_passthrough)); + OMX_ERRORTYPE omx_err = OMX_ErrorNone; if (!m_omx_render.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit)) @@ -434,9 +438,13 @@ double CAESinkPi::GetCacheTotal() unsigned int CAESinkPi::AddPackets(uint8_t **data, unsigned int frames, unsigned int offset) { + CLog::Log(LOGDEBUG, "%s:%s frames=%d format=%x", CLASSNAME, __func__, frames, m_format.m_dataFormat); + if (!m_Initialized || !m_omx_output || !frames) + { + Sleep(10); return frames; - + } OMX_ERRORTYPE omx_err = OMX_ErrorNone; OMX_BUFFERHEADERTYPE *omx_buffer = NULL; diff --git a/xbmc/cores/omxplayer/OMXAudio.cpp b/xbmc/cores/omxplayer/OMXAudio.cpp index 03c9e8e039ff9..03dbd13b8e73d 100644 --- a/xbmc/cores/omxplayer/OMXAudio.cpp +++ b/xbmc/cores/omxplayer/OMXAudio.cpp @@ -95,16 +95,23 @@ COMXAudio::COMXAudio() : m_failed_eos (false ), m_output (AESINKPI_UNKNOWN) { - CAEFactory::Suspend(); - while (!CAEFactory::IsSuspended()) - Sleep(10); + // magic value used when omxplayer is playing - want sink to be disabled + AEAudioFormat m_format; + m_format.m_dataFormat = AE_FMT_RAW; + m_format.m_streamInfo.m_type = CAEStreamInfo::STREAM_TYPE_AC3; + m_format.m_streamInfo.m_sampleRate = 16000; + m_format.m_streamInfo.m_channels = 2; + m_format.m_sampleRate = 16000; + m_format.m_frameSize = 1; + m_pAudioStream = CAEFactory::MakeStream(m_format, 0, nullptr); } COMXAudio::~COMXAudio() { Deinitialize(); - CAEFactory::Resume(); + if (m_pAudioStream) + CAEFactory::FreeStream(m_pAudioStream); } bool COMXAudio::PortSettingsChanged() diff --git a/xbmc/cores/omxplayer/OMXAudio.h b/xbmc/cores/omxplayer/OMXAudio.h index db7f98ddbc2db..02acfc8cfe574 100644 --- a/xbmc/cores/omxplayer/OMXAudio.h +++ b/xbmc/cores/omxplayer/OMXAudio.h @@ -24,6 +24,7 @@ #include "cores/AudioEngine/Utils/AEAudioFormat.h" #include "cores/AudioEngine/Utils/AEUtil.h" +#include "cores/AudioEngine/Interfaces/AEStream.h" #include "linux/PlatformDefs.h" #include "DVDStreamInfo.h" @@ -145,6 +146,7 @@ class COMXAudio OMX_AUDIO_PARAM_PCMMODETYPE m_pcm_input; OMX_AUDIO_PARAM_DTSTYPE m_dtsParam; WAVEFORMATEXTENSIBLE m_wave_header; + IAEStream *m_pAudioStream; protected: COMXCoreComponent m_omx_render_analog; COMXCoreComponent m_omx_render_hdmi;