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.

86 lines
2.6KB

  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. #include "JackAlsaDriver.h"
  19. #include "JackPort.h"
  20. #include "alsa_midi_impl.h"
  21. using Jack::JackAlsaDriver;
  22. struct fake_port_t {
  23. JackAlsaDriver* driver;
  24. int port_id;
  25. fake_port_t(JackAlsaDriver *d, int i) : driver(d), port_id(i) {}
  26. };
  27. int JACK_is_realtime(jack_client_t* client)
  28. {
  29. return ((JackAlsaDriver*)client)->is_realtime();
  30. }
  31. int JACK_client_create_thread(jack_client_t* client, pthread_t *thread, int priority, int realtime, void *(*start_routine)(void*), void *arg)
  32. {
  33. return ((JackAlsaDriver*)client)->create_thread(thread, priority, realtime, start_routine, arg);
  34. }
  35. 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)
  36. {
  37. JackAlsaDriver *driver = (JackAlsaDriver*)client;
  38. int port_id = driver->port_register(port_name, port_type, flags, buffer_size);
  39. if (port_id == NO_PORT) {
  40. return 0;
  41. } else {
  42. return (jack_port_t*) new fake_port_t(driver, port_id);
  43. }
  44. }
  45. int JACK_port_unregister(jack_client_t *client, jack_port_t *port)
  46. {
  47. fake_port_t* real = (fake_port_t*)port;
  48. int res = real->driver->port_unregister(real->port_id);
  49. delete real;
  50. return res;
  51. }
  52. void* JACK_port_get_buffer(jack_port_t *port, jack_nframes_t nframes)
  53. {
  54. fake_port_t* real = (fake_port_t*)port;
  55. return real->driver->port_get_buffer(real->port_id, nframes);
  56. }
  57. int JACK_port_set_alias(jack_port_t *port, const char* name)
  58. {
  59. fake_port_t* real = (fake_port_t*)port;
  60. return real->driver->port_set_alias(real->port_id, name);
  61. }
  62. jack_nframes_t JACK_get_sample_rate(jack_client_t *client)
  63. {
  64. return ((JackAlsaDriver*)client)->get_sample_rate();
  65. }
  66. jack_nframes_t JACK_frame_time(jack_client_t *client)
  67. {
  68. return ((JackAlsaDriver*)client)->frame_time();
  69. }
  70. jack_nframes_t JACK_last_frame_time(jack_client_t *client)
  71. {
  72. return ((JackAlsaDriver*)client)->last_frame_time();
  73. }