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.

92 lines
2.7KB

  1. /*
  2. * Copyright (c) 2006,2007 Dmitry S. Baikov <c0ff@konstruktiv.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #if defined(HAVE_CONFIG_H)
  19. #include "config.h"
  20. #endif
  21. #include "JackAlsaDriver.h"
  22. #include "JackPort.h"
  23. #include "alsa_midi_impl.h"
  24. using Jack::JackAlsaDriver;
  25. struct fake_port_t
  26. {
  27. JackAlsaDriver* driver;
  28. int port_id;
  29. fake_port_t(JackAlsaDriver *d, int i) : driver(d), port_id(i)
  30. {}
  31. };
  32. int JACK_is_realtime(jack_client_t* client)
  33. {
  34. return ((JackAlsaDriver*)client)->is_realtime();
  35. }
  36. int JACK_client_create_thread(jack_client_t* client, pthread_t *thread, int priority, int realtime, void *(*start_routine)(void*), void *arg)
  37. {
  38. return ((JackAlsaDriver*)client)->create_thread(thread, priority, realtime, start_routine, arg);
  39. }
  40. jack_port_t* JACK_port_register(jack_client_t *client, const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size)
  41. {
  42. JackAlsaDriver *driver = (JackAlsaDriver*)client;
  43. int port_id = driver->port_register(port_name, port_type, flags, buffer_size);
  44. if (port_id == NO_PORT) {
  45. return 0;
  46. } else {
  47. return (jack_port_t*) new fake_port_t(driver, port_id);
  48. }
  49. }
  50. int JACK_port_unregister(jack_client_t *client, jack_port_t *port)
  51. {
  52. fake_port_t* real = (fake_port_t*)port;
  53. int res = real->driver->port_unregister(real->port_id);
  54. delete real;
  55. return res;
  56. }
  57. void* JACK_port_get_buffer(jack_port_t *port, jack_nframes_t nframes)
  58. {
  59. fake_port_t* real = (fake_port_t*)port;
  60. return real->driver->port_get_buffer(real->port_id, nframes);
  61. }
  62. int JACK_port_set_alias(jack_port_t *port, const char* name)
  63. {
  64. fake_port_t* real = (fake_port_t*)port;
  65. return real->driver->port_set_alias(real->port_id, name);
  66. }
  67. jack_nframes_t JACK_get_sample_rate(jack_client_t *client)
  68. {
  69. return ((JackAlsaDriver*)client)->get_sample_rate();
  70. }
  71. jack_nframes_t JACK_frame_time(jack_client_t *client)
  72. {
  73. return ((JackAlsaDriver*)client)->frame_time();
  74. }
  75. jack_nframes_t JACK_last_frame_time(jack_client_t *client)
  76. {
  77. return ((JackAlsaDriver*)client)->last_frame_time();
  78. }