Skip to content

Commit c84083d

Browse files
committed
Initial alsa support
1 parent 66f9076 commit c84083d

8 files changed

+1406
-7
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ include Makefile.include
22

33
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
44

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

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

99
DIST ?= omxplayer-dist
1010

11-
SRC=linux/XMemUtils.cpp \
11+
SRC= linux/XMemUtils.cpp \
12+
linux/OMXAlsa.cpp \
1213
utils/log.cpp \
1314
DynamicDll.cpp \
1415
utils/PCMRemap.cpp \

OMXAudio.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ bool COMXAudio::PortSettingsChanged()
112112
if(!m_omx_render_hdmi.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
113113
return false;
114114
}
115+
if (m_config.device == "omx:alsa")
116+
{
117+
if(!m_omx_render_analog.Initialize("OMX.alsa.audio_render", OMX_IndexParamAudioInit))
118+
return false;
119+
}
115120

116121
UpdateAttenuation();
117122

@@ -235,7 +240,7 @@ bool COMXAudio::PortSettingsChanged()
235240

236241
OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
237242
OMX_INIT_STRUCTURE(audioDest);
238-
strncpy((char *)audioDest.sName, "local", strlen("local"));
243+
strncpy((char *)audioDest.sName, m_config.device == "omx:alsa" ? m_config.subdevice.c_str() : "local", sizeof(audioDest.sName));
239244
omx_err = m_omx_render_analog.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
240245
if (omx_err != OMX_ErrorNone)
241246
{

OMXAudio.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class OMXAudioConfig
4646
COMXStreamInfo hints;
4747
bool use_thread;
4848
CStdString device;
49+
CStdString subdevice;
4950
enum PCMLayout layout;
5051
bool boostOnDownmix;
5152
bool passthrough;

OMXCore.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#ifdef TARGET_LINUX
3737
#include "XMemUtils.h"
38+
#include "OMXAlsa.h"
3839
#endif
3940

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

15061512
CLog::Log(LOGDEBUG, "COMXCoreComponent::Deinitialize : %s handle %p\n",
15071513
m_componentName.c_str(), m_handle);
1514+
#ifdef TARGET_LINUX
1515+
if (strncmp("OMX.alsa.", m_componentName.c_str(), 9) == 0)
1516+
omx_err = OMXALSA_FreeHandle(m_handle);
1517+
else
1518+
#endif
15081519
omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
15091520
if (omx_err != OMX_ErrorNone)
15101521
{

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Usage: omxplayer [OPTIONS] [FILE]
5555
-v --version Print version info
5656
-k --keys Print key bindings
5757
-n --aidx index Audio stream index : e.g. 1
58-
-o --adev device Audio out device : e.g. hdmi/local/both
58+
-o --adev device Audio out device : e.g. hdmi/local/both/alsa[:device]
5959
-i --info Dump stream format and exit
6060
-I --with-info dump stream format before playback
6161
-s --stats Pts and buffer stats

0 commit comments

Comments
 (0)