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.

86 lines
2.8KB

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