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.

634 lines
22KB

  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. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. #if JUCE_USE_FLAC
  22. }
  23. #if defined _WIN32 && !defined __CYGWIN__
  24. #include <io.h>
  25. #else
  26. #include <unistd.h>
  27. #endif
  28. #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
  29. #include <sys/types.h> /* for off_t */
  30. #endif
  31. #if HAVE_INTTYPES_H
  32. #define __STDC_FORMAT_MACROS
  33. #include <inttypes.h>
  34. #endif
  35. #if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__
  36. #include <io.h> /* for _setmode(), chmod() */
  37. #include <fcntl.h> /* for _O_BINARY */
  38. #else
  39. #include <unistd.h> /* for chown(), unlink() */
  40. #endif
  41. #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
  42. #if defined __BORLANDC__
  43. #include <utime.h> /* for utime() */
  44. #else
  45. #include <sys/utime.h> /* for utime() */
  46. #endif
  47. #else
  48. #include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
  49. #include <utime.h> /* for utime() */
  50. #endif
  51. #if defined _MSC_VER
  52. #if _MSC_VER >= 1600
  53. #include <stdint.h>
  54. #else
  55. #include <limits.h>
  56. #endif
  57. #endif
  58. #ifdef _WIN32
  59. #include <stdio.h>
  60. #include <sys/stat.h>
  61. #include <stdarg.h>
  62. #include <windows.h>
  63. #endif
  64. #ifdef DEBUG
  65. #include <assert.h>
  66. #endif
  67. #include <stdlib.h>
  68. #include <stdio.h>
  69. namespace juce
  70. {
  71. namespace FlacNamespace
  72. {
  73. #if JUCE_INCLUDE_FLAC_CODE || ! defined (JUCE_INCLUDE_FLAC_CODE)
  74. #undef VERSION
  75. #define VERSION "1.3.1"
  76. #define FLAC__NO_DLL 1
  77. #if JUCE_MSVC
  78. #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312 4505 4365 4005 4334 181 111)
  79. #else
  80. #define HAVE_LROUND 1
  81. #endif
  82. #if JUCE_MAC
  83. #define FLAC__SYS_DARWIN 1
  84. #endif
  85. #ifndef SIZE_MAX
  86. #define SIZE_MAX 0xffffffff
  87. #endif
  88. #if JUCE_CLANG
  89. #pragma clang diagnostic push
  90. #pragma clang diagnostic ignored "-Wconversion"
  91. #pragma clang diagnostic ignored "-Wshadow"
  92. #pragma clang diagnostic ignored "-Wdeprecated-register"
  93. #elif JUCE_GCC && (__GNUC__ >= 7)
  94. #pragma GCC diagnostic push
  95. #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
  96. #endif
  97. #if JUCE_INTEL
  98. #if JUCE_32BIT
  99. #define FLAC__CPU_IA32 1
  100. #endif
  101. #if JUCE_64BIT
  102. #define FLAC__CPU_X86_64 1
  103. #endif
  104. #define FLAC__HAS_X86INTRIN 1
  105. #endif
  106. #undef __STDC_LIMIT_MACROS
  107. #define __STDC_LIMIT_MACROS 1
  108. #define flac_max jmax
  109. #define flac_min jmin
  110. #undef DEBUG // (some flac code dumps debug trace if the app defines this macro)
  111. #include "flac/all.h"
  112. #include "flac/libFLAC/bitmath.c"
  113. #include "flac/libFLAC/bitreader.c"
  114. #include "flac/libFLAC/bitwriter.c"
  115. #include "flac/libFLAC/cpu.c"
  116. #include "flac/libFLAC/crc.c"
  117. #include "flac/libFLAC/fixed.c"
  118. #include "flac/libFLAC/float.c"
  119. #include "flac/libFLAC/format.c"
  120. #include "flac/libFLAC/lpc_flac.c"
  121. #include "flac/libFLAC/md5.c"
  122. #include "flac/libFLAC/memory.c"
  123. #include "flac/libFLAC/stream_decoder.c"
  124. #include "flac/libFLAC/stream_encoder.c"
  125. #include "flac/libFLAC/stream_encoder_framing.c"
  126. #include "flac/libFLAC/window_flac.c"
  127. #undef VERSION
  128. #else
  129. #include <FLAC/all.h>
  130. #endif
  131. #if JUCE_CLANG
  132. #pragma clang diagnostic pop
  133. #elif JUCE_GCC && (__GNUC__ >= 7)
  134. #pragma GCC diagnostic pop
  135. #endif
  136. }
  137. #undef max
  138. #undef min
  139. //==============================================================================
  140. static const char* const flacFormatName = "FLAC file";
  141. //==============================================================================
  142. class FlacReader : public AudioFormatReader
  143. {
  144. public:
  145. FlacReader (InputStream* const in)
  146. : AudioFormatReader (in, flacFormatName),
  147. reservoirStart (0),
  148. samplesInReservoir (0),
  149. scanningForLength (false)
  150. {
  151. using namespace FlacNamespace;
  152. lengthInSamples = 0;
  153. decoder = FLAC__stream_decoder_new();
  154. ok = FLAC__stream_decoder_init_stream (decoder,
  155. readCallback_, seekCallback_, tellCallback_, lengthCallback_,
  156. eofCallback_, writeCallback_, metadataCallback_, errorCallback_,
  157. this) == FLAC__STREAM_DECODER_INIT_STATUS_OK;
  158. if (ok)
  159. {
  160. FLAC__stream_decoder_process_until_end_of_metadata (decoder);
  161. if (lengthInSamples == 0 && sampleRate > 0)
  162. {
  163. // the length hasn't been stored in the metadata, so we'll need to
  164. // work it out the length the hard way, by scanning the whole file..
  165. scanningForLength = true;
  166. FLAC__stream_decoder_process_until_end_of_stream (decoder);
  167. scanningForLength = false;
  168. const int64 tempLength = lengthInSamples;
  169. FLAC__stream_decoder_reset (decoder);
  170. FLAC__stream_decoder_process_until_end_of_metadata (decoder);
  171. lengthInSamples = tempLength;
  172. }
  173. }
  174. }
  175. ~FlacReader()
  176. {
  177. FlacNamespace::FLAC__stream_decoder_delete (decoder);
  178. }
  179. void useMetadata (const FlacNamespace::FLAC__StreamMetadata_StreamInfo& info)
  180. {
  181. sampleRate = info.sample_rate;
  182. bitsPerSample = info.bits_per_sample;
  183. lengthInSamples = (unsigned int) info.total_samples;
  184. numChannels = info.channels;
  185. reservoir.setSize ((int) numChannels, 2 * (int) info.max_blocksize, false, false, true);
  186. }
  187. // returns the number of samples read
  188. bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
  189. int64 startSampleInFile, int numSamples) override
  190. {
  191. using namespace FlacNamespace;
  192. if (! ok)
  193. return false;
  194. while (numSamples > 0)
  195. {
  196. if (startSampleInFile >= reservoirStart
  197. && startSampleInFile < reservoirStart + samplesInReservoir)
  198. {
  199. const int num = (int) jmin ((int64) numSamples,
  200. reservoirStart + samplesInReservoir - startSampleInFile);
  201. jassert (num > 0);
  202. for (int i = jmin (numDestChannels, reservoir.getNumChannels()); --i >= 0;)
  203. if (destSamples[i] != nullptr)
  204. memcpy (destSamples[i] + startOffsetInDestBuffer,
  205. reservoir.getReadPointer (i, (int) (startSampleInFile - reservoirStart)),
  206. sizeof (int) * (size_t) num);
  207. startOffsetInDestBuffer += num;
  208. startSampleInFile += num;
  209. numSamples -= num;
  210. }
  211. else
  212. {
  213. if (startSampleInFile >= (int) lengthInSamples)
  214. {
  215. samplesInReservoir = 0;
  216. }
  217. else if (startSampleInFile < reservoirStart
  218. || startSampleInFile > reservoirStart + jmax (samplesInReservoir, 511))
  219. {
  220. // had some problems with flac crashing if the read pos is aligned more
  221. // accurately than this. Probably fixed in newer versions of the library, though.
  222. reservoirStart = (int) (startSampleInFile & ~511);
  223. samplesInReservoir = 0;
  224. FLAC__stream_decoder_seek_absolute (decoder, (FLAC__uint64) reservoirStart);
  225. }
  226. else
  227. {
  228. reservoirStart += samplesInReservoir;
  229. samplesInReservoir = 0;
  230. FLAC__stream_decoder_process_single (decoder);
  231. }
  232. if (samplesInReservoir == 0)
  233. break;
  234. }
  235. }
  236. if (numSamples > 0)
  237. {
  238. for (int i = numDestChannels; --i >= 0;)
  239. if (destSamples[i] != nullptr)
  240. zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (int) * (size_t) numSamples);
  241. }
  242. return true;
  243. }
  244. void useSamples (const FlacNamespace::FLAC__int32* const buffer[], int numSamples)
  245. {
  246. if (scanningForLength)
  247. {
  248. lengthInSamples += numSamples;
  249. }
  250. else
  251. {
  252. if (numSamples > reservoir.getNumSamples())
  253. reservoir.setSize ((int) numChannels, numSamples, false, false, true);
  254. const unsigned int bitsToShift = 32 - bitsPerSample;
  255. for (int i = 0; i < (int) numChannels; ++i)
  256. {
  257. const FlacNamespace::FLAC__int32* src = buffer[i];
  258. int n = i;
  259. while (src == 0 && n > 0)
  260. src = buffer [--n];
  261. if (src != nullptr)
  262. {
  263. int* const dest = reinterpret_cast<int*> (reservoir.getWritePointer(i));
  264. for (int j = 0; j < numSamples; ++j)
  265. dest[j] = src[j] << bitsToShift;
  266. }
  267. }
  268. samplesInReservoir = numSamples;
  269. }
  270. }
  271. //==============================================================================
  272. static FlacNamespace::FLAC__StreamDecoderReadStatus readCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__byte buffer[], size_t* bytes, void* client_data)
  273. {
  274. using namespace FlacNamespace;
  275. *bytes = (size_t) static_cast<const FlacReader*> (client_data)->input->read (buffer, (int) *bytes);
  276. return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
  277. }
  278. static FlacNamespace::FLAC__StreamDecoderSeekStatus seekCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64 absolute_byte_offset, void* client_data)
  279. {
  280. using namespace FlacNamespace;
  281. static_cast<const FlacReader*> (client_data)->input->setPosition ((int) absolute_byte_offset);
  282. return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
  283. }
  284. static FlacNamespace::FLAC__StreamDecoderTellStatus tellCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* absolute_byte_offset, void* client_data)
  285. {
  286. using namespace FlacNamespace;
  287. *absolute_byte_offset = (uint64) static_cast<const FlacReader*> (client_data)->input->getPosition();
  288. return FLAC__STREAM_DECODER_TELL_STATUS_OK;
  289. }
  290. static FlacNamespace::FLAC__StreamDecoderLengthStatus lengthCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* stream_length, void* client_data)
  291. {
  292. using namespace FlacNamespace;
  293. *stream_length = (uint64) static_cast<const FlacReader*> (client_data)->input->getTotalLength();
  294. return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
  295. }
  296. static FlacNamespace::FLAC__bool eofCallback_ (const FlacNamespace::FLAC__StreamDecoder*, void* client_data)
  297. {
  298. return static_cast<const FlacReader*> (client_data)->input->isExhausted();
  299. }
  300. static FlacNamespace::FLAC__StreamDecoderWriteStatus writeCallback_ (const FlacNamespace::FLAC__StreamDecoder*,
  301. const FlacNamespace::FLAC__Frame* frame,
  302. const FlacNamespace::FLAC__int32* const buffer[],
  303. void* client_data)
  304. {
  305. using namespace FlacNamespace;
  306. static_cast<FlacReader*> (client_data)->useSamples (buffer, (int) frame->header.blocksize);
  307. return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
  308. }
  309. static void metadataCallback_ (const FlacNamespace::FLAC__StreamDecoder*,
  310. const FlacNamespace::FLAC__StreamMetadata* metadata,
  311. void* client_data)
  312. {
  313. static_cast<FlacReader*> (client_data)->useMetadata (metadata->data.stream_info);
  314. }
  315. static void errorCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__StreamDecoderErrorStatus, void*)
  316. {
  317. }
  318. private:
  319. FlacNamespace::FLAC__StreamDecoder* decoder;
  320. AudioSampleBuffer reservoir;
  321. int reservoirStart, samplesInReservoir;
  322. bool ok, scanningForLength;
  323. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlacReader)
  324. };
  325. //==============================================================================
  326. class FlacWriter : public AudioFormatWriter
  327. {
  328. public:
  329. FlacWriter (OutputStream* const out, double rate, uint32 numChans, uint32 bits, int qualityOptionIndex)
  330. : AudioFormatWriter (out, flacFormatName, rate, numChans, bits),
  331. streamStartPos (output != nullptr ? jmax (output->getPosition(), 0ll) : 0ll)
  332. {
  333. using namespace FlacNamespace;
  334. encoder = FLAC__stream_encoder_new();
  335. if (qualityOptionIndex > 0)
  336. FLAC__stream_encoder_set_compression_level (encoder, (uint32) jmin (8, qualityOptionIndex));
  337. FLAC__stream_encoder_set_do_mid_side_stereo (encoder, numChannels == 2);
  338. FLAC__stream_encoder_set_loose_mid_side_stereo (encoder, numChannels == 2);
  339. FLAC__stream_encoder_set_channels (encoder, numChannels);
  340. FLAC__stream_encoder_set_bits_per_sample (encoder, jmin ((unsigned int) 24, bitsPerSample));
  341. FLAC__stream_encoder_set_sample_rate (encoder, (unsigned int) sampleRate);
  342. FLAC__stream_encoder_set_blocksize (encoder, 0);
  343. FLAC__stream_encoder_set_do_escape_coding (encoder, true);
  344. ok = FLAC__stream_encoder_init_stream (encoder,
  345. encodeWriteCallback, encodeSeekCallback,
  346. encodeTellCallback, encodeMetadataCallback,
  347. this) == FLAC__STREAM_ENCODER_INIT_STATUS_OK;
  348. }
  349. ~FlacWriter()
  350. {
  351. if (ok)
  352. {
  353. FlacNamespace::FLAC__stream_encoder_finish (encoder);
  354. output->flush();
  355. }
  356. else
  357. {
  358. output = nullptr; // to stop the base class deleting this, as it needs to be returned
  359. // to the caller of createWriter()
  360. }
  361. FlacNamespace::FLAC__stream_encoder_delete (encoder);
  362. }
  363. //==============================================================================
  364. bool write (const int** samplesToWrite, int numSamples) override
  365. {
  366. using namespace FlacNamespace;
  367. if (! ok)
  368. return false;
  369. HeapBlock<int*> channels;
  370. HeapBlock<int> temp;
  371. const int bitsToShift = 32 - (int) bitsPerSample;
  372. if (bitsToShift > 0)
  373. {
  374. temp.malloc (numChannels * (size_t) numSamples);
  375. channels.calloc (numChannels + 1);
  376. for (unsigned int i = 0; i < numChannels; ++i)
  377. {
  378. if (samplesToWrite[i] == nullptr)
  379. break;
  380. int* const destData = temp.get() + i * (size_t) numSamples;
  381. channels[i] = destData;
  382. for (int j = 0; j < numSamples; ++j)
  383. destData[j] = (samplesToWrite[i][j] >> bitsToShift);
  384. }
  385. samplesToWrite = const_cast<const int**> (channels.get());
  386. }
  387. return FLAC__stream_encoder_process (encoder, (const FLAC__int32**) samplesToWrite, (unsigned) numSamples) != 0;
  388. }
  389. bool writeData (const void* const data, const int size) const
  390. {
  391. return output->write (data, (size_t) size);
  392. }
  393. static void packUint32 (FlacNamespace::FLAC__uint32 val, FlacNamespace::FLAC__byte* b, const int bytes)
  394. {
  395. b += bytes;
  396. for (int i = 0; i < bytes; ++i)
  397. {
  398. *(--b) = (FlacNamespace::FLAC__byte) (val & 0xff);
  399. val >>= 8;
  400. }
  401. }
  402. void writeMetaData (const FlacNamespace::FLAC__StreamMetadata* metadata)
  403. {
  404. using namespace FlacNamespace;
  405. const FLAC__StreamMetadata_StreamInfo& info = metadata->data.stream_info;
  406. unsigned char buffer [FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
  407. const unsigned int channelsMinus1 = info.channels - 1;
  408. const unsigned int bitsMinus1 = info.bits_per_sample - 1;
  409. packUint32 (info.min_blocksize, buffer, 2);
  410. packUint32 (info.max_blocksize, buffer + 2, 2);
  411. packUint32 (info.min_framesize, buffer + 4, 3);
  412. packUint32 (info.max_framesize, buffer + 7, 3);
  413. buffer[10] = (uint8) ((info.sample_rate >> 12) & 0xff);
  414. buffer[11] = (uint8) ((info.sample_rate >> 4) & 0xff);
  415. buffer[12] = (uint8) (((info.sample_rate & 0x0f) << 4) | (channelsMinus1 << 1) | (bitsMinus1 >> 4));
  416. buffer[13] = (FLAC__byte) (((bitsMinus1 & 0x0f) << 4) | (unsigned int) ((info.total_samples >> 32) & 0x0f));
  417. packUint32 ((FLAC__uint32) info.total_samples, buffer + 14, 4);
  418. memcpy (buffer + 18, info.md5sum, 16);
  419. const bool seekOk = output->setPosition (streamStartPos + 4);
  420. ignoreUnused (seekOk);
  421. // if this fails, you've given it an output stream that can't seek! It needs
  422. // to be able to seek back to write the header
  423. jassert (seekOk);
  424. output->writeIntBigEndian (FLAC__STREAM_METADATA_STREAMINFO_LENGTH);
  425. output->write (buffer, FLAC__STREAM_METADATA_STREAMINFO_LENGTH);
  426. }
  427. //==============================================================================
  428. static FlacNamespace::FLAC__StreamEncoderWriteStatus encodeWriteCallback (const FlacNamespace::FLAC__StreamEncoder*,
  429. const FlacNamespace::FLAC__byte buffer[],
  430. size_t bytes,
  431. unsigned int /*samples*/,
  432. unsigned int /*current_frame*/,
  433. void* client_data)
  434. {
  435. using namespace FlacNamespace;
  436. return static_cast<FlacWriter*> (client_data)->writeData (buffer, (int) bytes)
  437. ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK
  438. : FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
  439. }
  440. static FlacNamespace::FLAC__StreamEncoderSeekStatus encodeSeekCallback (const FlacNamespace::FLAC__StreamEncoder*, FlacNamespace::FLAC__uint64, void*)
  441. {
  442. using namespace FlacNamespace;
  443. return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
  444. }
  445. static FlacNamespace::FLAC__StreamEncoderTellStatus encodeTellCallback (const FlacNamespace::FLAC__StreamEncoder*, FlacNamespace::FLAC__uint64* absolute_byte_offset, void* client_data)
  446. {
  447. using namespace FlacNamespace;
  448. if (client_data == nullptr)
  449. return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
  450. *absolute_byte_offset = (FLAC__uint64) static_cast<FlacWriter*> (client_data)->output->getPosition();
  451. return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
  452. }
  453. static void encodeMetadataCallback (const FlacNamespace::FLAC__StreamEncoder*, const FlacNamespace::FLAC__StreamMetadata* metadata, void* client_data)
  454. {
  455. static_cast<FlacWriter*> (client_data)->writeMetaData (metadata);
  456. }
  457. bool ok;
  458. private:
  459. FlacNamespace::FLAC__StreamEncoder* encoder;
  460. int64 streamStartPos;
  461. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlacWriter)
  462. };
  463. //==============================================================================
  464. FlacAudioFormat::FlacAudioFormat()
  465. : AudioFormat (flacFormatName, ".flac")
  466. {
  467. }
  468. FlacAudioFormat::~FlacAudioFormat()
  469. {
  470. }
  471. Array<int> FlacAudioFormat::getPossibleSampleRates()
  472. {
  473. const int rates[] = { 8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000,
  474. 88200, 96000, 176400, 192000, 352800, 384000 };
  475. return Array<int> (rates, numElementsInArray (rates));
  476. }
  477. Array<int> FlacAudioFormat::getPossibleBitDepths()
  478. {
  479. const int depths[] = { 16, 24 };
  480. return Array<int> (depths, numElementsInArray (depths));
  481. }
  482. bool FlacAudioFormat::canDoStereo() { return true; }
  483. bool FlacAudioFormat::canDoMono() { return true; }
  484. bool FlacAudioFormat::isCompressed() { return true; }
  485. AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in, const bool deleteStreamIfOpeningFails)
  486. {
  487. ScopedPointer<FlacReader> r (new FlacReader (in));
  488. if (r->sampleRate > 0)
  489. return r.release();
  490. if (! deleteStreamIfOpeningFails)
  491. r->input = nullptr;
  492. return nullptr;
  493. }
  494. AudioFormatWriter* FlacAudioFormat::createWriterFor (OutputStream* out,
  495. double sampleRate,
  496. unsigned int numberOfChannels,
  497. int bitsPerSample,
  498. const StringPairArray& /*metadataValues*/,
  499. int qualityOptionIndex)
  500. {
  501. if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
  502. {
  503. ScopedPointer<FlacWriter> w (new FlacWriter (out, sampleRate, numberOfChannels,
  504. (uint32) bitsPerSample, qualityOptionIndex));
  505. if (w->ok)
  506. return w.release();
  507. }
  508. return nullptr;
  509. }
  510. StringArray FlacAudioFormat::getQualityOptions()
  511. {
  512. static const char* options[] = { "0 (Fastest)", "1", "2", "3", "4", "5 (Default)","6", "7", "8 (Highest quality)", 0 };
  513. return StringArray (options);
  514. }
  515. #endif
  516. } // namespace juce