The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

108 lines
4.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #pragma once
  24. class iOSAudioIODeviceType;
  25. class iOSAudioIODevice : public AudioIODevice
  26. {
  27. public:
  28. //==============================================================================
  29. String open (const BigInteger&, const BigInteger&, double, int) override;
  30. void close() override;
  31. void start (AudioIODeviceCallback*) override;
  32. void stop() override;
  33. Array<double> getAvailableSampleRates() override;
  34. Array<int> getAvailableBufferSizes() override;
  35. bool setAudioPreprocessingEnabled (bool) override;
  36. //==============================================================================
  37. bool isPlaying() override { return isRunning && callback != nullptr; }
  38. bool isOpen() override { return isRunning; }
  39. String getLastError() override { return lastError; };
  40. //==============================================================================
  41. StringArray getOutputChannelNames() override { return { "Left", "Right" }; }
  42. StringArray getInputChannelNames() override { return audioInputIsAvailable ? getOutputChannelNames() : StringArray(); }
  43. int getDefaultBufferSize() override { return defaultBufferSize; }
  44. int getCurrentBufferSizeSamples() override { return actualBufferSize; }
  45. double getCurrentSampleRate() override { return sampleRate; }
  46. int getCurrentBitDepth() override { return 16; }
  47. BigInteger getActiveOutputChannels() const override { return activeOutputChans; }
  48. BigInteger getActiveInputChannels() const override { return activeInputChans; }
  49. int getOutputLatencyInSamples() override;
  50. int getInputLatencyInSamples() override;
  51. //==============================================================================
  52. void handleStatusChange (bool enabled, const char* reason);
  53. void handleRouteChange (const char* reason);
  54. //==============================================================================
  55. virtual void setMidiMessageCollector (MidiMessageCollector* collector) { messageCollector = collector; }
  56. virtual AudioPlayHead* getAudioPlayHead() const;
  57. //==============================================================================
  58. virtual bool isInterAppAudioConnected() const { return interAppAudioConnected; }
  59. #if JUCE_MODULE_AVAILABLE_juce_graphics
  60. virtual Image getIcon (int size);
  61. #endif
  62. virtual void switchApplication();
  63. private:
  64. //==============================================================================
  65. void updateSampleRateAndAudioInput();
  66. //==============================================================================
  67. friend class iOSAudioIODeviceType;
  68. iOSAudioIODevice (const String& deviceName);
  69. //==============================================================================
  70. const int defaultBufferSize;
  71. double sampleRate;
  72. int numInputChannels, numOutputChannels;
  73. int preferredBufferSize, actualBufferSize;
  74. bool isRunning;
  75. String lastError;
  76. bool audioInputIsAvailable, interAppAudioConnected;
  77. BigInteger activeOutputChans, activeInputChans;
  78. AudioIODeviceCallback* callback;
  79. MidiMessageCollector* messageCollector;
  80. class Pimpl;
  81. friend class Pimpl;
  82. ScopedPointer<Pimpl> pimpl;
  83. JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice)
  84. };