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.

83 lines
2.8KB

  1. /*
  2. * Common JACK code
  3. * Copyright (C) 2012 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. const char** connections = jackbridge_port_get_all_connections(client, port);
  28. if (connections)
  29. {
  30. for (int i=0; connections[i]; i++)
  31. connectionsVector.push_back(strdup(connections[i]));
  32. jackbridge_free(connections);
  33. }
  34. return connectionsVector;
  35. }
  36. static inline
  37. std::string jackbridge_status_get_error_string(const jack_status_t& status)
  38. {
  39. std::string errorString;
  40. if (status & JackFailure)
  41. errorString += "Overall operation failed;\n";
  42. if (status & JackInvalidOption)
  43. errorString += "The operation contained an invalid or unsupported option;\n";
  44. if (status & JackNameNotUnique)
  45. errorString += "The desired client name was not unique;\n";
  46. if (status & JackServerStarted)
  47. errorString += "The JACK server was started as a result of this operation;\n";
  48. if (status & JackServerFailed)
  49. errorString += "Unable to connect to the JACK server;\n";
  50. if (status & JackServerError)
  51. errorString += "Communication error with the JACK server;\n";
  52. if (status & JackNoSuchClient)
  53. errorString += "Requested client does not exist;\n";
  54. if (status & JackLoadFailure)
  55. errorString += "Unable to load internal client;\n";
  56. if (status & JackInitFailure)
  57. errorString += "Unable to initialize client;\n";
  58. if (status & JackShmFailure)
  59. errorString += "Unable to access shared memory;\n";
  60. if (status & JackVersionError)
  61. errorString += "Client's protocol version does not match;\n";
  62. if (status & JackBackendError)
  63. errorString += "Backend Error;\n";
  64. if (status & JackClientZombie)
  65. errorString += "Client is being shutdown against its will;\n";
  66. if (errorString.size() > 2)
  67. errorString.replace(errorString.size()-2, 2, ".");
  68. return errorString;
  69. }
  70. #endif // __JACK_UTILS_HPP__