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.

79 lines
2.6KB

  1. /*
  2. * AudioRender.h
  3. *
  4. * Copyright (c) 2004 Johnny Petrantoni. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 2.1
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this program; if not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. *
  21. * Created by Johnny Petrantoni on Fri Jan 30 2004.
  22. * This code is part of Panda framework (moduleloader.cpp)
  23. * http://xpanda.sourceforge.net
  24. */
  25. #include <Carbon/Carbon.h>
  26. #include <CoreAudio/CoreAudio.h>
  27. #define Print4CharCode(msg, c) { \
  28. UInt32 __4CC_number = (c); \
  29. char __4CC_string[5]; \
  30. memcpy(__4CC_string, &__4CC_number, 4); \
  31. __4CC_string[4] = 0; \
  32. printf("%s'%s'\n", (msg), __4CC_string);\
  33. }
  34. typedef int (*JackRunCyclePtr) (void *driver, long bufferSize);
  35. class AudioRender {
  36. public:
  37. AudioRender(float sampleRate, long bufferSize, int inChannels,
  38. int outChannels, char *device);
  39. ~AudioRender();
  40. bool ConfigureAudioProc(float sampleRate, long bufferSize,
  41. int channels, int inChannels, char *device);
  42. bool StartAudio();
  43. bool StopAudio();
  44. void *jackData;
  45. bool status;
  46. JackRunCyclePtr f_JackRunCycle;
  47. float **inBuffers;
  48. float **outBuffers;
  49. AudioDeviceID vDevice;
  50. float vSampleRate;
  51. long vBufferSize;
  52. int vChannels; //output channels
  53. int vInChannels; //input chennels
  54. static float **getADC();
  55. static float **getDAC();
  56. static float gSampleRate;
  57. static long gBufferSize;
  58. static int gInputChannels;
  59. static int gOutputChannels;
  60. static bool isProcessing;
  61. static const AudioTimeStamp *gTime;
  62. int *isInterleaved, *numberOfStreams, *channelsPerStream,
  63. *out_numberOfStreams, *out_channelsPerStream;
  64. int n_streams, n_out_streams;
  65. private:
  66. static OSStatus process(AudioDeviceID inDevice,
  67. const AudioTimeStamp * inNow,
  68. const AudioBufferList * inInputData,
  69. const AudioTimeStamp * inInputTime,
  70. AudioBufferList * outOutputData,
  71. const AudioTimeStamp * inOutputTime,
  72. void *inClientData);
  73. static AudioRender *theRender;
  74. };