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.

109 lines
2.7KB

  1. /*
  2. Copyright (C) 2008 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include "JackAudioAdapter.h"
  16. #include "JackTools.h"
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <assert.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. #include "driver_interface.h"
  25. #ifdef __linux__
  26. #include "JackAlsaAdapter.h"
  27. #endif
  28. #ifdef __APPLE__
  29. #include "JackCoreAudioAdapter.h"
  30. #endif
  31. #ifdef WIN32
  32. #include "JackPortAudioAdapter.h"
  33. #endif
  34. using namespace Jack;
  35. EXPORT int jack_internal_initialize(jack_client_t* jack_client, const JSList* params)
  36. {
  37. jack_log("Loading audioadapter");
  38. Jack::JackAudioAdapter* adapter;
  39. jack_nframes_t buffer_size = jack_get_buffer_size(jack_client);
  40. jack_nframes_t sample_rate = jack_get_sample_rate(jack_client);
  41. #ifdef __linux__
  42. adapter = new Jack::JackAudioAdapter(jack_client, new Jack::JackAlsaAdapter(buffer_size, sample_rate, params));
  43. #endif
  44. #ifdef WIN32
  45. adapter = new Jack::JackAudioAdapter(jack_client, new Jack::JackPortAudioAdapter(buffer_size, sample_rate, params));
  46. #endif
  47. #ifdef __APPLE__
  48. adapter = new Jack::JackAudioAdapter(jack_client, new Jack::JackCoreAudioAdapter(buffer_size, sample_rate, params));
  49. #endif
  50. assert(adapter);
  51. if (adapter->Open() == 0)
  52. return 0;
  53. else
  54. {
  55. delete adapter;
  56. return 1;
  57. }
  58. }
  59. EXPORT int jack_initialize(jack_client_t* jack_client, const char* load_init)
  60. {
  61. JSList* params = NULL;
  62. jack_driver_desc_t *desc = jack_get_descriptor();
  63. JackArgParser parser(load_init);
  64. if (parser.GetArgc() > 0)
  65. {
  66. if (parser.ParseParams(desc, &params) != 0)
  67. jack_error("Internal client : JackArgParser::ParseParams error.");
  68. }
  69. return jack_internal_initialize(jack_client, params);
  70. }
  71. EXPORT void jack_finish(void* arg)
  72. {
  73. Jack::JackAudioAdapter* adapter = static_cast<Jack::JackAudioAdapter*>(arg);
  74. if (adapter)
  75. {
  76. jack_log("Unloading audioadapter");
  77. adapter->Close();
  78. delete adapter;
  79. }
  80. }
  81. #ifdef __cplusplus
  82. }
  83. #endif