Skip to content

Commit

Permalink
Initial alsa support
Browse files Browse the repository at this point in the history
  • Loading branch information
fabled committed Aug 3, 2016
1 parent 66f9076 commit c84083d
Show file tree
Hide file tree
Showing 8 changed files with 1,406 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ include Makefile.include

CFLAGS+=-std=c++0x -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -DTARGET_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CMAKE_CONFIG -D__VIDEOCORE4__ -U_FORTIFY_SOURCE -Wall -DHAVE_OMXLIB -DUSE_EXTERNAL_FFMPEG -DHAVE_LIBAVCODEC_AVCODEC_H -DHAVE_LIBAVUTIL_OPT_H -DHAVE_LIBAVUTIL_MEM_H -DHAVE_LIBAVUTIL_AVUTIL_H -DHAVE_LIBAVFORMAT_AVFORMAT_H -DHAVE_LIBAVFILTER_AVFILTER_H -DHAVE_LIBSWRESAMPLE_SWRESAMPLE_H -DOMX -DOMX_SKIP64BIT -ftree-vectorize -DUSE_EXTERNAL_OMX -DTARGET_RASPBERRY_PI -DUSE_EXTERNAL_LIBBCM_HOST

LDFLAGS+=-L./ -Lffmpeg_compiled/usr/local/lib/ -lc -lWFC -lGLESv2 -lEGL -lbcm_host -lopenmaxil -lfreetype -lz
LDFLAGS+=-L./ -Lffmpeg_compiled/usr/local/lib/ -lc -lWFC -lGLESv2 -lEGL -lbcm_host -lopenmaxil -lfreetype -lz -lasound

INCLUDES+=-I./ -Ilinux -Iffmpeg_compiled/usr/local/include/ -I /usr/include/dbus-1.0 -I /usr/lib/arm-linux-gnueabihf/dbus-1.0/include

DIST ?= omxplayer-dist

SRC=linux/XMemUtils.cpp \
SRC= linux/XMemUtils.cpp \
linux/OMXAlsa.cpp \
utils/log.cpp \
DynamicDll.cpp \
utils/PCMRemap.cpp \
Expand Down
7 changes: 6 additions & 1 deletion OMXAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ bool COMXAudio::PortSettingsChanged()
if(!m_omx_render_hdmi.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
return false;
}
if (m_config.device == "omx:alsa")
{
if(!m_omx_render_analog.Initialize("OMX.alsa.audio_render", OMX_IndexParamAudioInit))
return false;
}

UpdateAttenuation();

Expand Down Expand Up @@ -235,7 +240,7 @@ bool COMXAudio::PortSettingsChanged()

OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
OMX_INIT_STRUCTURE(audioDest);
strncpy((char *)audioDest.sName, "local", strlen("local"));
strncpy((char *)audioDest.sName, m_config.device == "omx:alsa" ? m_config.subdevice.c_str() : "local", sizeof(audioDest.sName));
omx_err = m_omx_render_analog.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
if (omx_err != OMX_ErrorNone)
{
Expand Down
1 change: 1 addition & 0 deletions OMXAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class OMXAudioConfig
COMXStreamInfo hints;
bool use_thread;
CStdString device;
CStdString subdevice;
enum PCMLayout layout;
bool boostOnDownmix;
bool passthrough;
Expand Down
11 changes: 11 additions & 0 deletions OMXCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#ifdef TARGET_LINUX
#include "XMemUtils.h"
#include "OMXAlsa.h"
#endif

//#define OMX_DEBUG_EVENTS
Expand Down Expand Up @@ -1429,6 +1430,11 @@ bool COMXCoreComponent::Initialize( const std::string &component_name, OMX_INDEX
// Get video component handle setting up callbacks, component is in loaded state on return.
if(!m_handle)
{
#ifdef TARGET_LINUX
if (strncmp("OMX.alsa.", component_name.c_str(), 9) == 0)
omx_err = OMXALSA_GetHandle(&m_handle, (char*) component_name.c_str(), this, &m_callbacks);
else
#endif
omx_err = m_DllOMX->OMX_GetHandle(&m_handle, (char*)component_name.c_str(), this, &m_callbacks);
if (!m_handle || omx_err != OMX_ErrorNone)
{
Expand Down Expand Up @@ -1505,6 +1511,11 @@ bool COMXCoreComponent::Deinitialize()

CLog::Log(LOGDEBUG, "COMXCoreComponent::Deinitialize : %s handle %p\n",
m_componentName.c_str(), m_handle);
#ifdef TARGET_LINUX
if (strncmp("OMX.alsa.", m_componentName.c_str(), 9) == 0)
omx_err = OMXALSA_FreeHandle(m_handle);
else
#endif
omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
if (omx_err != OMX_ErrorNone)
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Usage: omxplayer [OPTIONS] [FILE]
-v --version Print version info
-k --keys Print key bindings
-n --aidx index Audio stream index : e.g. 1
-o --adev device Audio out device : e.g. hdmi/local/both
-o --adev device Audio out device : e.g. hdmi/local/both/alsa[:device]
-i --info Dump stream format and exit
-I --with-info dump stream format before playback
-s --stats Pts and buffer stats
Expand Down
Loading

0 comments on commit c84083d

Please sign in to comment.