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.

94 lines
2.9KB

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