summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
diff options
context:
space:
mode:
authorAdrian Scarlat <adrian.scarlat@windriver.com>2015-05-22 14:16:45 +0000
committerJames Thomas <james.thomas@codethink.co.uk>2015-05-22 14:18:47 +0000
commitba709ee7d4f9f81af638a3d3c640b7152bbe32bc (patch)
tree3d05af7d27b462dbafcea61116474c9d9da3b3fd /PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
parent64d2ba454ecfb1ea9bef3b4b717989afa58db1c7 (diff)
downloadaudiomanager-ba709ee7d4f9f81af638a3d3c640b7152bbe32bc.tar.gz
This Routing Interface is needed for any application that will
be developed on top of AM and will use PulseAudio Sound Server to control the sources and sinks present on the system. It must be loaded by AM; The interface can be built by supplying cmake with the -DWITH_PULSE_ROUTING_PLUGIN=ON; After building one configuration file will be available: 1. libPluginRoutingInterfacePULSE.conf - configuration file for Pulse Routing Plugin; it will be loaded at runtime by the Pulse Routing Interface; Changed files: CMakeLists.txt Added new folders: PluginRoutingInterfacePulse/ Added new files: PluginRoutingInterfacePulse/CMakeLists.txt PluginRoutingInterfacePulse/README PluginRoutingInterfacePulse/data/libPluginRoutingInterfacePULSE.conf PluginRoutingInterfacePulse/include/RoutingSenderMainloopPULSE.h PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h PluginRoutingInterfacePulse/src/RoutingSenderMainloopPULSE.cpp PluginRoutingInterfacePulse/src/RoutingSenderPULSE.cpp Signed-off-by: Adrian Scarlat <adrian.scarlat@windriver.com>
Diffstat (limited to 'PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h')
-rw-r--r--PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h b/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
new file mode 100644
index 0000000..0fc2197
--- /dev/null
+++ b/PluginRoutingInterfacePulse/include/RoutingSenderPULSE.h
@@ -0,0 +1,131 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2014, Wind River Systems
+ * Copyright (C) 2014, GENIVI Alliance
+ *
+ * This file is part of Pulse Audio Interface Routing Plugin.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ *
+ * List of changes:
+ *
+ * 21.08.2014, Adrian Scarlat, First version of the code;
+ * Porting code from AM ver1.x to AM ver3.0;
+ * Added Copyright and License information;
+ */
+
+#ifndef ROUTINGSENDERPULSE_H_
+#define ROUTINGSENDERPULSE_H_
+
+/* Includes */
+#include "routing/IAmRoutingSend.h"
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <getopt.h>
+#include <locale.h>
+#include <map>
+#include <pulse/pulseaudio.h>
+
+using namespace am;
+
+struct RoutingSenderPULSEConnection
+{
+ am_connectionID_t connectionID;
+ am_sourceID_t sourceID;
+ am_sinkID_t sinkID;
+ am_Handle_s handle;
+ bool pending;
+};
+
+
+struct RoutingSenderPULSESourceSinkConfig
+{
+ am_Source_s source;
+ am_Sink_s sink;
+
+ std::string name;//e.g. {"gst-launch-0.10", "mono", "aplay"};
+ std::string clazz;//e.g. {"Entertainment", "Navigation", "TTS"};
+ std::string propertyName;//e.g. {"application.process.binary", "application.process.binary", "application.process.app"};
+ std::string propertyValue;//
+};
+
+
+/* Prototypes */
+class RoutingSenderPULSE : public IAmRoutingSend
+{
+public:
+ RoutingSenderPULSE(pa_context *p_paContext);
+ ~RoutingSenderPULSE();
+
+ am::am_Error_e startupInterface(am::IAmRoutingReceive* p_routingReceiver);
+ void setRoutingReady(uint16_t handle);
+ void setRoutingRundown(uint16_t handle);
+ am_Error_e asyncAbort(const am_Handle_s handle);
+ am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat);
+ am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID);
+ am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+ am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+ am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+ am_Error_e asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties);
+ am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
+ am_Error_e asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties);
+ am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
+ am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time);
+ am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
+ am_Error_e returnBusName(std::string& BusName) const;
+ void getInterfaceVersion(std::string& out_ver) const;
+
+ void setPAContext(pa_context *p_paContext) {
+ this->m_paContext = p_paContext;
+ }
+ am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes);
+ am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration);
+ am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration);
+//Pulse Audio callbacks
+ void getSinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata);
+ void getSourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *userdata);
+ void getSinkInputInfoCallback(pa_context *c, const pa_sink_input_info *i, void *userdata);
+ void getSourceOutputInfoCallback(pa_context *c, const pa_source_output_info *i, void *userdata);
+
+private:
+ void loadConfig();
+
+ am_Domain_s m_domain;
+
+ std::vector<RoutingSenderPULSESourceSinkConfig> m_sinks;
+ std::vector<RoutingSenderPULSESourceSinkConfig> m_sources;
+
+ std::map<uint16_t, uint32_t> m_sourceToPASinkInput;
+ std::map<uint16_t, uint32_t> m_sourceToPASource;
+ std::map<uint16_t, uint32_t> m_sinkToPASourceOutput;
+ std::map<uint16_t, uint32_t> m_sinkToPASink;
+
+ uint16_t m_paSinkNullIndex;
+ uint16_t m_paSourceNullIndex;
+
+ IAmRoutingReceive *m_routingReceiver;
+ pa_context *m_paContext;
+
+/**
+ * Maintain a list of pending actions: there is a high change that the HMI first call connect,
+ * then the audio client start to play, therefore, sink-input is not yet created by the time "connect" method was called.
+ * same for volume? not sure - probably the sink input is created when the user change the volume.
+ * same for disconnect? not sure - probably the sink input was already created by the time the user is calling disconnect
+ */
+ std::vector<RoutingSenderPULSEConnection> m_activeConnections;
+ std::map<uint16_t, uint16_t> m_sinkToVolume;
+ std::map<uint16_t, uint16_t> m_sourceToVolume;
+};
+
+#endif