Audio plugin host https://kx.studio/carla
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.

170 lines
6.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_AUDIOCDBURNER_H_INCLUDED
  18. #define JUCE_AUDIOCDBURNER_H_INCLUDED
  19. #if JUCE_USE_CDBURNER || DOXYGEN
  20. //==============================================================================
  21. /**
  22. */
  23. class AudioCDBurner : public ChangeBroadcaster
  24. {
  25. public:
  26. //==============================================================================
  27. /** Returns a list of available optical drives.
  28. Use openDevice() to open one of the items from this list.
  29. */
  30. static StringArray findAvailableDevices();
  31. /** Tries to open one of the optical drives.
  32. The deviceIndex is an index into the array returned by findAvailableDevices().
  33. */
  34. static AudioCDBurner* openDevice (const int deviceIndex);
  35. /** Destructor. */
  36. ~AudioCDBurner();
  37. //==============================================================================
  38. enum DiskState
  39. {
  40. unknown, /**< An error condition, if the device isn't responding. */
  41. trayOpen, /**< The drive is currently open. Note that a slot-loading drive
  42. may seem to be permanently open. */
  43. noDisc, /**< The drive has no disk in it. */
  44. writableDiskPresent, /**< The drive contains a writeable disk. */
  45. readOnlyDiskPresent /**< The drive contains a read-only disk. */
  46. };
  47. /** Returns the current status of the device.
  48. To get informed when the drive's status changes, attach a ChangeListener to
  49. the AudioCDBurner.
  50. */
  51. DiskState getDiskState() const;
  52. /** Returns true if there's a writable disk in the drive. */
  53. bool isDiskPresent() const;
  54. /** Sends an eject signal to the drive.
  55. The eject will happen asynchronously, so you can use getDiskState() and
  56. waitUntilStateChange() to monitor its progress.
  57. */
  58. bool openTray();
  59. /** Blocks the current thread until the drive's state changes, or until the timeout expires.
  60. @returns the device's new state
  61. */
  62. DiskState waitUntilStateChange (int timeOutMilliseconds);
  63. //==============================================================================
  64. /** Returns the set of possible write speeds that the device can handle.
  65. These are as a multiple of 'normal' speed, so e.g. '24x' returns 24, etc.
  66. Note that if there's no media present in the drive, this value may be unavailable!
  67. @see setWriteSpeed, getWriteSpeed
  68. */
  69. Array<int> getAvailableWriteSpeeds() const;
  70. //==============================================================================
  71. /** Tries to enable or disable buffer underrun safety on devices that support it.
  72. @returns true if it's now enabled. If the device doesn't support it, this
  73. will always return false.
  74. */
  75. bool setBufferUnderrunProtection (bool shouldBeEnabled);
  76. //==============================================================================
  77. /** Returns the number of free blocks on the disk.
  78. There are 75 blocks per second, at 44100Hz.
  79. */
  80. int getNumAvailableAudioBlocks() const;
  81. /** Adds a track to be written.
  82. The source passed-in here will be kept by this object, and it will
  83. be used and deleted at some point in the future, either during the
  84. burn() method or when this AudioCDBurner object is deleted. Your caller
  85. method shouldn't keep a reference to it or use it again after passing
  86. it in here.
  87. */
  88. bool addAudioTrack (AudioSource* source, int numSamples);
  89. //==============================================================================
  90. /** Receives progress callbacks during a cd-burn operation.
  91. @see AudioCDBurner::burn()
  92. */
  93. class BurnProgressListener
  94. {
  95. public:
  96. BurnProgressListener() noexcept {}
  97. virtual ~BurnProgressListener() {}
  98. /** Called at intervals to report on the progress of the AudioCDBurner.
  99. To cancel the burn, return true from this method.
  100. */
  101. virtual bool audioCDBurnProgress (float proportionComplete) = 0;
  102. };
  103. /** Runs the burn process.
  104. This method will block until the operation is complete.
  105. @param listener the object to receive callbacks about progress
  106. @param ejectDiscAfterwards whether to eject the disk after the burn completes
  107. @param performFakeBurnForTesting if true, no data will actually be written to the disk
  108. @param writeSpeed one of the write speeds from getAvailableWriteSpeeds(), or
  109. 0 or less to mean the fastest speed.
  110. */
  111. String burn (BurnProgressListener* listener,
  112. bool ejectDiscAfterwards,
  113. bool performFakeBurnForTesting,
  114. int writeSpeed);
  115. /** If a burn operation is currently in progress, this tells it to stop
  116. as soon as possible.
  117. It's also possible to stop the burn process by returning true from
  118. BurnProgressListener::audioCDBurnProgress()
  119. */
  120. void abortBurn();
  121. private:
  122. //==============================================================================
  123. AudioCDBurner (const int deviceIndex);
  124. class Pimpl;
  125. friend struct ContainerDeletePolicy<Pimpl>;
  126. ScopedPointer<Pimpl> pimpl;
  127. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioCDBurner)
  128. };
  129. #endif
  130. #endif // JUCE_AUDIOCDBURNER_H_INCLUDED