Skip to content

Commit

Permalink
PCM renderer component component based on non-blocking ALSA apis. Closes
Browse files Browse the repository at this point in the history
 #7.
  • Loading branch information
Juan A. Rubio committed Jul 30, 2013
1 parent b6b86e8 commit 5263fc4
Show file tree
Hide file tree
Showing 18 changed files with 1,982 additions and 78 deletions.
9 changes: 9 additions & 0 deletions config/tizonia.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ OMX.Aratelia.audio_renderer.pcm.alsa_device = default
OMX.Aratelia.audio_renderer.pcm.testfile1_uri = @localstatedir@/lib/tizonia/tizonia-test-media/pcm/strum12str_5sec_le_signed_16_48_stereo.raw
OMX.Aratelia.audio_renderer.pcm.testfile2_uri = @localstatedir@/lib/tizonia/tizonia-test-media/pcm/strum12str_5sec_le_signed_16_44_1_stereo.raw

###############################
# Audio Renderer non-blocking #
###############################

OMX.Aratelia.audio_renderer_nb.pcm.preannouncements_disabled.port0 = false
OMX.Aratelia.audio_renderer_nb.pcm.alsa_device = default
OMX.Aratelia.audio_renderer_nb.pcm.testfile1_uri = @localstatedir@/lib/tizonia/tizonia-test-media/pcm/strum12str_5sec_le_signed_16_48_stereo.raw
OMX.Aratelia.audio_renderer_nb.pcm.testfile2_uri = @localstatedir@/lib/tizonia/tizonia-test-media/pcm/strum12str_5sec_le_signed_16_44_1_stereo.raw

###############
# MP3 Decoder #
###############
Expand Down
13 changes: 7 additions & 6 deletions examples/tplay/src/tizgraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
if (eEvent == OMX_EventCmdComplete)
{
TIZ_LOG (TIZ_DEBUG, "[%s] : "
"eEvent = [%s] event [%s] state [%s] error [%p]\n",
"[%s] [%s] [%s] error [%p]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent),
tiz_cmd_to_str ((OMX_COMMANDTYPE)nData1),
Expand All @@ -155,7 +155,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
else if (eEvent == OMX_EventPortSettingsChanged)
{
TIZ_LOG (TIZ_DEBUG, "[%s] : "
"eEvent = [%s] port [%lu] index [%s] pEventData [%p]\n",
"[%s] port [%lu] index [%s] pEventData [%p]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent), nData1,
tiz_idx_to_str ((OMX_INDEXTYPE)nData2),
Expand All @@ -164,7 +164,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
else if (eEvent == OMX_EventBufferFlag)
{
TIZ_LOG (TIZ_DEBUG, "[%s] : "
"eEvent = [%s] port [%lu] flags [%lX] pEventData [%p]\n",
"[%s] port [%lu] flags [%lX] pEventData [%p]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent), nData1, nData2,
pEventData);
Expand All @@ -174,7 +174,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
else if (eEvent == OMX_EventError)
{
TIZ_LOG (TIZ_DEBUG, "[%s] : "
"eEvent = [%s] error [%s] port [%lu] pEventData [%p]\n",
"[%s] error [%s] port [%lu] pEventData [%p]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent), tiz_err_to_str ((OMX_ERRORTYPE)nData1),
nData2, pEventData);
Expand All @@ -190,7 +190,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
}
else if (eEvent == OMX_EventVendorStartUnused)
{
TIZ_LOG (TIZ_DEBUG, "[%s] : eEvent = [%s]\n",
TIZ_LOG (TIZ_DEBUG, "[%s] : [%s]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent));
expected_list_.clear();
Expand All @@ -199,7 +199,7 @@ tizcback_handler::receive_event(OMX_HANDLETYPE hComponent,
else
{
TIZ_LOG (TIZ_DEBUG, "Received from [%s] : "
"eEvent = [%s]\n",
"[%s]\n",
const_cast<tizgraph &>(parent_).h2n_[hComponent].c_str(),
tiz_evt_to_str (eEvent));
return;
Expand Down Expand Up @@ -233,6 +233,7 @@ tizcback_handler::wait_for_event_list (const waitevent_list_t &event_list)

TIZ_LOG (TIZ_DEBUG, "events_outstanding_ = [%s] event_list size [%d]",
events_outstanding_ ? "true" : "false", event_list.size());

for (waitevent_list_t::const_iterator it = event_list.begin ();
it != event_list.end (); ++it)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/tplay/src/tizmp3graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tizmp3graph::do_load ()
component_names_t comp_list;
comp_list.push_back ("OMX.Aratelia.file_reader.binary");
comp_list.push_back ("OMX.Aratelia.audio_decoder.mp3");
comp_list.push_back ("OMX.Aratelia.audio_renderer.pcm");
comp_list.push_back ("OMX.Aratelia.audio_renderer_nb.pcm");

if (OMX_ErrorNone != (ret = verify_existence (comp_list)))
{
Expand Down
1 change: 1 addition & 0 deletions plugins/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

SUBDIRS = \
audio_renderer \
audio_renderer_non_block \
file_reader \
file_writer \
mp3_decoder \
Expand Down
23 changes: 23 additions & 0 deletions plugins/audio_renderer_non_block/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2011-2013 Aratelia Limited - Juan A. Rubio
#
# This file is part of Tizonia
#
# Tizonia is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Tizonia is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tizonia. If not, see <http://www.gnu.org/licenses/>.


SUBDIRS= src tests

#pkgconfigdir = $(libdir)/pkgconfig
#pkgconfig_DATA = tizcomps.pc

58 changes: 58 additions & 0 deletions plugins/audio_renderer_non_block/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2011-2013 Aratelia Limited - Juan A. Rubio
#
# This file is part of Tizonia
#
# Tizonia is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Tizonia is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tizonia. If not, see <http://www.gnu.org/licenses/>.

AC_PREREQ([2.67])
AC_INIT([libtizarnb], [0.1.0], [juan.rubio@aratelia.com])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([foreign color-tests silent-rules -Wall -Werror])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])



# Checks for programs.
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_GCC_TRADITIONAL
LT_INIT
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG()

# Checks for libraries.
PKG_CHECK_MODULES([ALSA], [alsa])
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
#PKG_CHECK_MODULES([KHROMTIZ12], [libkhromxil12])
#PKG_CHECK_MODULES([TIZ], [libtizosal])
#PKG_CHECK_MODULES([TIZCORE], [libtizcore])

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.


AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile])

# End the configure script.
AC_OUTPUT
39 changes: 39 additions & 0 deletions plugins/audio_renderer_non_block/src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2011-2013 Aratelia Limited - Juan A. Rubio
#
# This file is part of Tizonia
#
# Tizonia is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Tizonia is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tizonia. If not, see <http://www.gnu.org/licenses/>.

lib_LTLIBRARIES = libtizarnb.la

noinst_HEADERS = \
arprc.h \
arprc_decls.h

libtizarnb_la_SOURCES = \
ar.c \
arprc.c

libtizarnb_la_CFLAGS = \
-I$(top_srcdir)/../../include/omxil-1.2 \
-I$(top_srcdir)/../../libtizosal/src \
-I$(top_srcdir)/../../libtizonia/src \
@ALSA_CFLAGS@

libtizarnb_la_LIBADD = \
$(top_builddir)/../../libtizosal/src/libtizosal.la \
$(top_builddir)/../../libtizonia/src/libtizonia.la \
@ALSA_LIBS@


174 changes: 174 additions & 0 deletions plugins/audio_renderer_non_block/src/ar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/**
* Copyright (C) 2011-2013 Aratelia Limited - Juan A. Rubio
*
* This file is part of Tizonia
*
* Tizonia is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Tizonia is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tizonia. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file audio_renderer.c
* @author Juan A. Rubio <juan.rubio@aratelia.com>
*
* @brief Tizonia OpenMAX IL - PCM Audio Renderer based on ALSA
*
*
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <assert.h>
#include <string.h>

#include "OMX_Core.h"
#include "OMX_Component.h"
#include "OMX_Types.h"

#include "tizosal.h"
#include "tizutils.h"
#include "tizscheduler.h"
#include "tizpcmport.h"
#include "tizconfigport.h"
#include "arprc.h"

#ifdef TIZ_LOG_CATEGORY_NAME
#undef TIZ_LOG_CATEGORY_NAME
#define TIZ_LOG_CATEGORY_NAME "tiz.audio_renderer"
#endif

#define ARATELIA_AUDIO_RENDERER_DEFAULT_ROLE "audio_renderer.pcm"
#define ARATELIA_AUDIO_RENDERER_COMPONENT_NAME "OMX.Aratelia.audio_renderer_nb.pcm"
#define ARATELIA_AUDIO_RENDERER_PORT_INDEX 0 /* With libtizonia, port indexes must start at index 0 */
#define ARATELIA_AUDIO_RENDERER_PORT_MIN_BUF_COUNT 2
#define ARATELIA_AUDIO_RENDERER_PORT_MIN_BUF_SIZE 1024
#define ARATELIA_AUDIO_RENDERER_PORT_NONCONTIGUOUS OMX_FALSE
#define ARATELIA_AUDIO_RENDERER_PORT_ALIGNMENT 0
#define ARATELIA_AUDIO_RENDERER_PORT_SUPPLIERPREF OMX_BufferSupplyInput

static OMX_VERSIONTYPE audio_renderer_version = { {1, 0, 0, 0} };

static OMX_PTR
instantiate_pcm_port (OMX_HANDLETYPE ap_hdl)
{
OMX_PTR p_pcmport = NULL;
OMX_AUDIO_PARAM_PCMMODETYPE pcmmode;
OMX_AUDIO_CONFIG_VOLUMETYPE volume;
OMX_AUDIO_CONFIG_MUTETYPE mute;
OMX_AUDIO_CODINGTYPE encodings[] = {
OMX_AUDIO_CodingPCM,
OMX_AUDIO_CodingMax
};
tiz_port_options_t port_opts = {
OMX_PortDomainAudio,
OMX_DirInput,
ARATELIA_AUDIO_RENDERER_PORT_MIN_BUF_COUNT,
ARATELIA_AUDIO_RENDERER_PORT_MIN_BUF_SIZE,
ARATELIA_AUDIO_RENDERER_PORT_NONCONTIGUOUS,
ARATELIA_AUDIO_RENDERER_PORT_ALIGNMENT,
ARATELIA_AUDIO_RENDERER_PORT_SUPPLIERPREF,
{ARATELIA_AUDIO_RENDERER_PORT_INDEX, NULL, NULL, NULL},
-1 /* use -1 for now */
};

/* Instantiate the pcm port */
pcmmode.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
pcmmode.nVersion.nVersion = OMX_VERSION;
pcmmode.nPortIndex = ARATELIA_AUDIO_RENDERER_PORT_INDEX;
pcmmode.nChannels = 2;
pcmmode.eNumData = OMX_NumericalDataSigned;
pcmmode.eEndian = OMX_EndianLittle;
pcmmode.bInterleaved = OMX_TRUE;
pcmmode.nBitPerSample = 16;
pcmmode.nSamplingRate = 48000;
pcmmode.ePCMMode = OMX_AUDIO_PCMModeLinear;
pcmmode.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
pcmmode.eChannelMapping[1] = OMX_AUDIO_ChannelRF;


volume.nSize = sizeof (OMX_AUDIO_CONFIG_VOLUMETYPE);
volume.nVersion.nVersion = OMX_VERSION;
volume.nPortIndex = ARATELIA_AUDIO_RENDERER_PORT_INDEX;
volume.bLinear = OMX_FALSE;
volume.sVolume.nValue = 50;
volume.sVolume.nMin = 0;
volume.sVolume.nMax = 100;


mute.nSize = sizeof (OMX_AUDIO_CONFIG_MUTETYPE);
mute.nVersion.nVersion = OMX_VERSION;
mute.nPortIndex = ARATELIA_AUDIO_RENDERER_PORT_INDEX;
mute.bMute = OMX_FALSE;

tiz_pcmport_init ();
p_pcmport = factory_new (tizpcmport, &port_opts, &encodings,
&pcmmode, &volume, &mute);
assert (p_pcmport);

return p_pcmport;
}

static OMX_PTR
instantiate_config_port (OMX_HANDLETYPE ap_hdl)
{
OMX_PTR p_cport = NULL;

/* Instantiate the config port */
tiz_configport_init ();
p_cport = factory_new (tizconfigport, NULL, /* this port does not take options */
ARATELIA_AUDIO_RENDERER_COMPONENT_NAME,
audio_renderer_version);
assert (p_cport);

return p_cport;
}

static OMX_PTR
instantiate_processor (OMX_HANDLETYPE ap_hdl)
{
OMX_PTR p_proc = NULL;

/* Instantiate the processor */
ar_prc_init ();
p_proc = factory_new (arprc, ap_hdl);
assert (p_proc);

return p_proc;
}

OMX_ERRORTYPE
OMX_ComponentInit (OMX_HANDLETYPE ap_hdl)
{
tiz_role_factory_t role_factory;
const tiz_role_factory_t *rf_list[] = { &role_factory };

assert (ap_hdl);

TIZ_LOG (TIZ_TRACE, "OMX_ComponentInit: Inititializing [%s]",
ARATELIA_AUDIO_RENDERER_COMPONENT_NAME);

strcpy ((OMX_STRING) role_factory.role,
ARATELIA_AUDIO_RENDERER_DEFAULT_ROLE);
role_factory.pf_cport = instantiate_config_port;
role_factory.pf_port[0] = instantiate_pcm_port;
role_factory.nports = 1;
role_factory.pf_proc = instantiate_processor;

tiz_comp_init (ap_hdl, ARATELIA_AUDIO_RENDERER_COMPONENT_NAME);

tiz_comp_register_roles (ap_hdl, rf_list, 1);

return OMX_ErrorNone;
}
Loading

0 comments on commit 5263fc4

Please sign in to comment.