jack1 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.

139 lines
3.2KB

  1. /*
  2. * AudioRenderBridge.c
  3. * jack_coreaudio
  4. *
  5. * Copyright (c) 2004 Johnny Petrantoni. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 2.1
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this program; if not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. *
  22. * Created by Johnny Petrantoni on Fri Jan 30 2004.
  23. * This code is part of Panda framework (moduleloader.cpp)
  24. * http://xpanda.sourceforge.net
  25. */
  26. #include "AudioRenderBridge.h"
  27. #include "AudioRender.h"
  28. void *openPandaAudioInstance(float sampleRate, long bufferSize,
  29. int inChannels, int outChannels, char *device)
  30. {
  31. AudioRender *newInst =
  32. new AudioRender(sampleRate, bufferSize, inChannels, outChannels,
  33. device);
  34. if (newInst->status)
  35. return newInst;
  36. else {
  37. delete newInst;
  38. return NULL;
  39. }
  40. }
  41. void closePandaAudioInstance(void *instance)
  42. {
  43. if (instance) {
  44. AudioRender *inst = (AudioRender *) instance;
  45. inst->StopAudio();
  46. delete inst;
  47. }
  48. }
  49. int startPandaAudioProcess(void *instance)
  50. {
  51. if (instance) {
  52. AudioRender *inst = (AudioRender *) instance;
  53. return inst->StartAudio();
  54. }
  55. return FALSE;
  56. }
  57. int stopPandaAudioProcess(void *instance)
  58. {
  59. if (instance) {
  60. AudioRender *inst = (AudioRender *) instance;
  61. return inst->StopAudio();
  62. }
  63. return FALSE;
  64. }
  65. float **getPandaAudioInputs(void *instance)
  66. {
  67. if (instance) {
  68. AudioRender *inst = (AudioRender *) instance;
  69. return inst->inBuffers;
  70. }
  71. return NULL;
  72. }
  73. float **getPandaAudioOutputs(void *instance)
  74. {
  75. if (instance) {
  76. AudioRender *inst = (AudioRender *) instance;
  77. return inst->outBuffers;
  78. }
  79. return NULL;
  80. }
  81. void *getHostData(void *instance)
  82. {
  83. if (instance) {
  84. AudioRender *inst = (AudioRender *) instance;
  85. return inst->jackData;
  86. }
  87. return NULL;
  88. }
  89. void setHostData(void *instance, void *hostData)
  90. {
  91. if (instance) {
  92. AudioRender *inst = (AudioRender *) instance;
  93. inst->jackData = hostData;
  94. }
  95. }
  96. void setCycleFun(void *instance, JackRunCyclePtr fun)
  97. {
  98. if (instance) {
  99. AudioRender *inst = (AudioRender *) instance;
  100. inst->f_JackRunCycle = fun;
  101. }
  102. }
  103. void setParameter(void *instance, int id, void *data)
  104. {
  105. if (instance) {
  106. AudioRender *inst = (AudioRender *) instance;
  107. switch (id) {
  108. case 'inte':
  109. inst->isInterleaved = (int *) data;
  110. break;
  111. case 'nstr':
  112. inst->numberOfStreams = (int *) data;
  113. *inst->numberOfStreams = inst->n_in_streams;
  114. break;
  115. case 'cstr':
  116. inst->channelsPerStream = (int *) data;
  117. break;
  118. case 'nstO':
  119. inst->out_numberOfStreams = (int *) data;
  120. *inst->out_numberOfStreams = inst->n_out_streams;
  121. break;
  122. case 'cstO':
  123. inst->out_channelsPerStream = (int *) data;
  124. break;
  125. }
  126. }
  127. }