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.

136 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. return NULL;
  37. }
  38. void closePandaAudioInstance(void *instance)
  39. {
  40. if (instance) {
  41. AudioRender *inst = (AudioRender *) instance;
  42. inst->StopAudio();
  43. delete inst;
  44. }
  45. }
  46. int startPandaAudioProcess(void *instance)
  47. {
  48. if (instance) {
  49. AudioRender *inst = (AudioRender *) instance;
  50. return inst->StartAudio();
  51. }
  52. return FALSE;
  53. }
  54. int stopPandaAudioProcess(void *instance)
  55. {
  56. if (instance) {
  57. AudioRender *inst = (AudioRender *) instance;
  58. return inst->StopAudio();
  59. }
  60. return FALSE;
  61. }
  62. float **getPandaAudioInputs(void *instance)
  63. {
  64. if (instance) {
  65. AudioRender *inst = (AudioRender *) instance;
  66. return inst->inBuffers;
  67. }
  68. return NULL;
  69. }
  70. float **getPandaAudioOutputs(void *instance)
  71. {
  72. if (instance) {
  73. AudioRender *inst = (AudioRender *) instance;
  74. return inst->outBuffers;
  75. }
  76. return NULL;
  77. }
  78. void *getHostData(void *instance)
  79. {
  80. if (instance) {
  81. AudioRender *inst = (AudioRender *) instance;
  82. return inst->jackData;
  83. }
  84. return NULL;
  85. }
  86. void setHostData(void *instance, void *hostData)
  87. {
  88. if (instance) {
  89. AudioRender *inst = (AudioRender *) instance;
  90. inst->jackData = hostData;
  91. }
  92. }
  93. void setCycleFun(void *instance, JackRunCyclePtr fun)
  94. {
  95. if (instance) {
  96. AudioRender *inst = (AudioRender *) instance;
  97. inst->f_JackRunCycle = fun;
  98. }
  99. }
  100. void setParameter(void *instance, int id, void *data)
  101. {
  102. if (instance) {
  103. AudioRender *inst = (AudioRender *) instance;
  104. switch (id) {
  105. case 'inte':
  106. inst->isInterleaved = (int *) data;
  107. break;
  108. case 'nstr':
  109. inst->numberOfStreams = (int *) data;
  110. *inst->numberOfStreams = inst->n_in_streams;
  111. break;
  112. case 'cstr':
  113. inst->channelsPerStream = (int *) data;
  114. break;
  115. case 'nstO':
  116. inst->out_numberOfStreams = (int *) data;
  117. *inst->out_numberOfStreams = inst->n_out_streams;
  118. break;
  119. case 'cstO':
  120. inst->out_channelsPerStream = (int *) data;
  121. break;
  122. }
  123. }
  124. }