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.

50 lines
1.1 KiB

12 years ago
12 years ago
  1. #include <iostream>
  2. #include "client.h"
  3. bool Client::open(const char *name)
  4. {
  5. jack_status_t status;
  6. m_client = jack_client_open(name, JackNoStartServer, &status);
  7. if (m_client == NULL) {
  8. if (status & JackServerFailed) {
  9. std::cerr << "JACK server not running" << std::endl;
  10. } else {
  11. std::cerr << "jack_client_open() failed, status = " << status << std::endl;
  12. }
  13. return false;
  14. }
  15. m_name = jack_get_client_name(m_client);
  16. m_sample_rate = jack_get_sample_rate(m_client);
  17. jack_on_shutdown(m_client, &shutdown, this);
  18. jack_set_process_callback(m_client, &process, this);
  19. jack_activate(m_client);
  20. return true;
  21. }
  22. void Client::close()
  23. {
  24. if (m_client == NULL) return;
  25. jack_deactivate(m_client);
  26. jack_client_close(m_client);
  27. }
  28. void Client::shutdown(void *arg)
  29. {
  30. ((Client *)arg)->shutdown();
  31. }
  32. int Client::process(jack_nframes_t nframes, void *arg)
  33. {
  34. return ((Client *)arg)->process(nframes);
  35. }
  36. jack_port_t *Client::port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size)
  37. {
  38. return jack_port_register(m_client, port_name, port_type, flags, buffer_size);
  39. }