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.

100 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. class iOSAudioIODeviceType;
  19. class iOSAudioIODevice : public AudioIODevice
  20. {
  21. public:
  22. //==============================================================================
  23. String open (const BigInteger&, const BigInteger&, double, int) override;
  24. void close() override;
  25. void start (AudioIODeviceCallback*) override;
  26. void stop() override;
  27. Array<double> getAvailableSampleRates() override;
  28. Array<int> getAvailableBufferSizes() override;
  29. bool setAudioPreprocessingEnabled (bool) override;
  30. //==============================================================================
  31. bool isPlaying() override { return isRunning && callback != nullptr; }
  32. bool isOpen() override { return isRunning; }
  33. String getLastError() override { return lastError; }
  34. //==============================================================================
  35. StringArray getOutputChannelNames() override { return { "Left", "Right" }; }
  36. StringArray getInputChannelNames() override { return audioInputIsAvailable ? getOutputChannelNames() : StringArray(); }
  37. int getDefaultBufferSize() override { return defaultBufferSize; }
  38. int getCurrentBufferSizeSamples() override { return actualBufferSize; }
  39. double getCurrentSampleRate() override { return sampleRate; }
  40. int getCurrentBitDepth() override { return 16; }
  41. BigInteger getActiveOutputChannels() const override { return activeOutputChans; }
  42. BigInteger getActiveInputChannels() const override { return activeInputChans; }
  43. int getOutputLatencyInSamples() override;
  44. int getInputLatencyInSamples() override;
  45. //==============================================================================
  46. void handleStatusChange (bool enabled, const char* reason);
  47. void handleRouteChange (const char* reason);
  48. //==============================================================================
  49. virtual void setMidiMessageCollector (MidiMessageCollector* collector) { messageCollector = collector; }
  50. virtual AudioPlayHead* getAudioPlayHead() const;
  51. //==============================================================================
  52. virtual bool isInterAppAudioConnected() const { return interAppAudioConnected; }
  53. #if JUCE_MODULE_AVAILABLE_juce_graphics
  54. virtual Image getIcon (int size);
  55. #endif
  56. virtual void switchApplication();
  57. private:
  58. //==============================================================================
  59. void updateSampleRateAndAudioInput();
  60. //==============================================================================
  61. friend class iOSAudioIODeviceType;
  62. iOSAudioIODevice (const String& deviceName);
  63. //==============================================================================
  64. const int defaultBufferSize;
  65. double sampleRate;
  66. int numInputChannels, numOutputChannels;
  67. int preferredBufferSize, actualBufferSize;
  68. bool isRunning;
  69. String lastError;
  70. bool audioInputIsAvailable, interAppAudioConnected;
  71. BigInteger activeOutputChans, activeInputChans;
  72. AudioIODeviceCallback* callback;
  73. MidiMessageCollector* messageCollector;
  74. class Pimpl;
  75. friend class Pimpl;
  76. ScopedPointer<Pimpl> pimpl;
  77. JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice)
  78. };