Add zalsa configure flag, enabled by default if possible
[jack2.git] / android / JackSapaProxyIn.cpp
blob1879a990249d5152ec0be6edc5cbef107f24759d
1 /*
2 Copyright (C) 2014 Samsung Electronics
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "JackSapaProxy.h"
21 #include "JackServerGlobals.h"
22 #include "JackEngineControl.h"
23 #include "JackLockedEngine.h"
24 #include "JackArgParser.h"
25 #include <assert.h>
26 #include <string>
28 #ifdef __cplusplus
29 extern "C"
31 #endif
33 #include "driver_interface.h"
35 using namespace Jack;
37 static Jack::JackSapaProxy* sapaproxy = NULL;
39 SERVER_EXPORT jack_driver_desc_t* jack_get_descriptor()
41 jack_driver_desc_t * desc;
42 jack_driver_desc_filler_t filler;
43 jack_driver_param_value_t value;
45 desc = jack_driver_descriptor_construct("in", JackDriverNone, "sapaproxy client", &filler);
47 value.ui = 0U;
48 jack_driver_descriptor_add_parameter(desc, &filler, "capture", 'C', JackDriverParamUInt, &value, NULL, "Number of capture ports", NULL);
49 jack_driver_descriptor_add_parameter(desc, &filler, "playback", 'P', JackDriverParamUInt, &value, NULL, "Number of playback ports", NULL);
51 return desc;
54 SERVER_EXPORT int jack_internal_initialize(jack_client_t* jack_client, const JSList* params)
56 if (sapaproxy) {
57 jack_info("sapaproxy already loaded");
58 return 1;
61 jack_log("Loading sapaproxy");
62 sapaproxy = new Jack::JackSapaProxy(jack_client, params);
63 if (!params) {
64 sapaproxy->fCapturePorts = 2U;
65 sapaproxy->fPlaybackPorts = 0U;
67 sapaproxy->Setup(jack_client);
68 assert(sapaproxy);
69 return 0;
72 SERVER_EXPORT int jack_initialize(jack_client_t* jack_client, const char* load_init)
74 JSList* params = NULL;
75 bool parse_params = true;
76 int res = 1;
77 jack_driver_desc_t* desc = jack_get_descriptor();
79 Jack::JackArgParser parser(load_init);
80 if (parser.GetArgc() > 0)
81 parse_params = parser.ParseParams(desc, &params);
83 if (parse_params) {
84 res = jack_internal_initialize(jack_client, params);
85 parser.FreeParams(params);
87 return res;
90 SERVER_EXPORT void jack_finish(void* arg)
92 Jack::JackSapaProxy* sapaproxy = static_cast<Jack::JackSapaProxy*>(arg);
94 if (sapaproxy) {
95 jack_log("Unloading sapaproxy");
96 delete sapaproxy;
100 #ifdef __cplusplus
102 #endif