Audio plugin host https://kx.studio/carla
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.

78 lines
3.1KB

  1. /*
  2. * Carla REST API Server
  3. * Copyright (C) 2018 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "common.hpp"
  18. #include "CarlaHost.h"
  19. // -------------------------------------------------------------------------------------------------------------------
  20. void handle_carla_get_engine_driver_count(const std::shared_ptr<Session> session)
  21. {
  22. const char* const buf = str_buf_uint(carla_get_engine_driver_count());
  23. session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
  24. }
  25. void handle_carla_get_engine_driver_name(const std::shared_ptr<Session> session)
  26. {
  27. const std::shared_ptr<const Request> request = session->get_request();
  28. const int index = std::atoi(request->get_path_parameter("index").c_str());
  29. CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
  30. const char* const buf = str_buf_string(carla_get_engine_driver_name(index));
  31. session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
  32. }
  33. void handle_carla_get_engine_driver_device_names(const std::shared_ptr<Session> session)
  34. {
  35. const std::shared_ptr<const Request> request = session->get_request();
  36. const int index = std::atoi(request->get_path_parameter("index").c_str());
  37. CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
  38. const char* const buf = str_buf_string_array(carla_get_engine_driver_device_names(index));
  39. session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
  40. }
  41. void handle_carla_get_engine_driver_device_info(const std::shared_ptr<Session> session)
  42. {
  43. const std::shared_ptr<const Request> request = session->get_request();
  44. const int index = std::atoi(request->get_path_parameter("index").c_str());
  45. CARLA_SAFE_ASSERT_RETURN(index >= 0 /*&& index < INT_MAX*/,)
  46. const std::string name = request->get_path_parameter("name");
  47. const EngineDriverDeviceInfo* const info = carla_get_engine_driver_device_info(index, name.c_str());
  48. char* jsonBuf;
  49. jsonBuf = json_buf_start();
  50. jsonBuf = json_buf_add_uint(jsonBuf, "hints", info->hints);
  51. // TODO
  52. //jsonBuf = json_buf_add_uint(jsonBuf, "bufferSizes", info->bufferSizes);
  53. //jsonBuf = json_buf_add_uint(jsonBuf, "sampleRates", info->sampleRates);
  54. const char* const buf = json_buf_end(jsonBuf);
  55. session->close(OK, buf, { { "Content-Length", size_buf(buf) } } );
  56. }
  57. // -------------------------------------------------------------------------------------------------------------------
  58. // -------------------------------------------------------------------------------------------------------------------