Skip to content

Commit

Permalink
omxplayer: Avoid CAEFactory::Suspend which should only be called by a…
Browse files Browse the repository at this point in the history
…pplication
  • Loading branch information
popcornmix committed Apr 30, 2016
1 parent 992c462 commit b48cbd4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 11 additions & 3 deletions xbmc/cores/AudioEngine/Sinks/AESinkPi.cpp
Expand Up @@ -217,15 +217,19 @@ 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);

CLog::Log(LOGDEBUG, "%s:%s Format:%d Channels:%d Samplerate:%d framesize:%d bufsize:%d bytes/s=%.2f dest=%s", CLASSNAME, __func__,
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))
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 11 additions & 4 deletions xbmc/cores/omxplayer/OMXAudio.cpp
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/omxplayer/OMXAudio.h
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b48cbd4

Please sign in to comment.