jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.0KB

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