Collection of tools useful for audio production
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.

82 lines
2.8KB

  1. /*
  2. * Common JACK code
  3. * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef __JACK_UTILS_HPP__
  18. #define __JACK_UTILS_HPP__
  19. #include "jackbridge/JackBridge.cpp"
  20. #include <cstring>
  21. #include <string>
  22. #include <vector>
  23. static inline
  24. std::vector<char*> jackbridge_port_get_all_connections_as_vector(jack_client_t* const client, jack_port_t* const port)
  25. {
  26. std::vector<char*> connectionsVector;
  27. if (const char** const connections = jackbridge_port_get_all_connections(client, port))
  28. {
  29. for (int i=0; connections[i]; i++)
  30. connectionsVector.push_back(strdup(connections[i]));
  31. jackbridge_free(connections);
  32. }
  33. return connectionsVector;
  34. }
  35. static inline
  36. std::string jackbridge_status_get_error_string(const jack_status_t& status)
  37. {
  38. std::string errorString;
  39. if (status & JackFailure)
  40. errorString += "Overall operation failed;\n";
  41. if (status & JackInvalidOption)
  42. errorString += "The operation contained an invalid or unsupported option;\n";
  43. if (status & JackNameNotUnique)
  44. errorString += "The desired client name was not unique;\n";
  45. if (status & JackServerStarted)
  46. errorString += "The JACK server was started as a result of this operation;\n";
  47. if (status & JackServerFailed)
  48. errorString += "Unable to connect to the JACK server;\n";
  49. if (status & JackServerError)
  50. errorString += "Communication error with the JACK server;\n";
  51. if (status & JackNoSuchClient)
  52. errorString += "Requested client does not exist;\n";
  53. if (status & JackLoadFailure)
  54. errorString += "Unable to load internal client;\n";
  55. if (status & JackInitFailure)
  56. errorString += "Unable to initialize client;\n";
  57. if (status & JackShmFailure)
  58. errorString += "Unable to access shared memory;\n";
  59. if (status & JackVersionError)
  60. errorString += "Client's protocol version does not match;\n";
  61. if (status & JackBackendError)
  62. errorString += "Backend Error;\n";
  63. if (status & JackClientZombie)
  64. errorString += "Client is being shutdown against its will;\n";
  65. if (errorString.size() > 2)
  66. errorString.replace(errorString.size()-2, 2, ".");
  67. return errorString;
  68. }
  69. #endif // __JACK_UTILS_HPP__