Skip to content

Commit 1ce3545

Browse files
committed
Deprecate the old AudioFormat::createWriterFor functions
1 parent eb7de7f commit 1ce3545

18 files changed

Lines changed: 47 additions & 189 deletions

BREAKING_CHANGES.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# JUCE breaking changes
22

3+
# develop
4+
5+
## Change
6+
7+
The AudioFormat class now only has one virtual createWriterFor member function:
8+
`createWriterFor (std::unique_ptr<OutputStream>&, const AudioFormatWriterOptions&)`.
9+
10+
The older createWriterFor overloads are now non-virtual and deprecated.
11+
12+
**Possible Issues**
13+
14+
Classes overriding the old AudioFormat::createWriterFor functions will fail to
15+
compile.
16+
17+
Additionally, code calling the old functions will emit a deprecation warning.
18+
19+
**Workaround**
20+
21+
Classes inheriting from AudioFormat should override the new createWriterFor
22+
function that takes an AudioFormatWriterOptions parameter.
23+
24+
**Rationale**
25+
26+
Adding support for writing wav files in 32-bit PCM format required the addition
27+
of another parameter to the AudioFormat::createWriterFor interface. This
28+
function already had many parameters, some of them already superfluous for some
29+
of the formats that share this interface. The introduction of a new options type
30+
makes it easier to extend this interface now and in the future. The old
31+
functions are marked deprecated, as allowing to override them would have made
32+
the implementation more complicated. The new signature better communicates
33+
resource ownership, helping to avoid bugs due to misuse.
34+
35+
336
## Change
437

538
Some functions and types have been moved from the VST3ClientExtentions class

modules/juce_audio_formats/codecs/juce_AiffAudioFormat.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,20 +1017,6 @@ MemoryMappedAudioFormatReader* AiffAudioFormat::createMemoryMappedReader (FileIn
10171017
return nullptr;
10181018
}
10191019

1020-
AudioFormatWriter* AiffAudioFormat::createWriterFor (OutputStream* out,
1021-
double sampleRate,
1022-
unsigned int numberOfChannels,
1023-
int bitsPerSample,
1024-
const StringPairArray& metadataValues,
1025-
int /*qualityOptionIndex*/)
1026-
{
1027-
if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
1028-
return new AiffAudioFormatWriter (out, sampleRate, numberOfChannels,
1029-
(unsigned int) bitsPerSample, metadataValues);
1030-
1031-
return nullptr;
1032-
}
1033-
10341020
std::unique_ptr<AudioFormatWriter> AiffAudioFormat::createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
10351021
const AudioFormatWriterOptions& options)
10361022
{

modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ class JUCE_API AiffAudioFormat : public AudioFormat
8888
MemoryMappedAudioFormatReader* createMemoryMappedReader (const File&) override;
8989
MemoryMappedAudioFormatReader* createMemoryMappedReader (FileInputStream*) override;
9090

91-
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
92-
double sampleRateToUse,
93-
unsigned int numberOfChannels,
94-
int bitsPerSample,
95-
const StringPairArray& metadataValues,
96-
int qualityOptionIndex) override;
97-
9891
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
9992
const AudioFormatWriterOptions& options) override;
10093

modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -654,17 +654,6 @@ AudioFormatReader* CoreAudioFormat::createReaderFor (InputStream* sourceStream,
654654
return nullptr;
655655
}
656656

657-
AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream*,
658-
double /*sampleRateToUse*/,
659-
unsigned int /*numberOfChannels*/,
660-
int /*bitsPerSample*/,
661-
const StringPairArray& /*metadataValues*/,
662-
int /*qualityOptionIndex*/)
663-
{
664-
jassertfalse; // not yet implemented!
665-
return nullptr;
666-
}
667-
668657
std::unique_ptr<AudioFormatWriter> CoreAudioFormat::createWriterFor (std::unique_ptr<OutputStream>&,
669658
const AudioFormatWriterOptions&)
670659
{

modules/juce_audio_formats/codecs/juce_CoreAudioFormat.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,6 @@ class JUCE_API CoreAudioFormat : public AudioFormat
106106
AudioFormatReader* createReaderFor (InputStream*,
107107
bool deleteStreamIfOpeningFails) override;
108108

109-
AudioFormatWriter* createWriterFor (OutputStream*,
110-
double sampleRateToUse,
111-
unsigned int numberOfChannels,
112-
int bitsPerSample,
113-
const StringPairArray& metadataValues,
114-
int qualityOptionIndex) override;
115-
116109
std::unique_ptr<AudioFormatWriter> createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
117110
const AudioFormatWriterOptions& options) override;
118111

modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -600,24 +600,6 @@ AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in, const bool
600600
return nullptr;
601601
}
602602

603-
AudioFormatWriter* FlacAudioFormat::createWriterFor (OutputStream* out,
604-
double sampleRate,
605-
unsigned int numberOfChannels,
606-
int bitsPerSample,
607-
const StringPairArray& /*metadataValues*/,
608-
int qualityOptionIndex)
609-
{
610-
if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
611-
{
612-
std::unique_ptr<FlacWriter> w (new FlacWriter (out, sampleRate, numberOfChannels,
613-
(uint32) bitsPerSample, qualityOptionIndex));
614-
if (w->ok)
615-
return w.release();
616-
}
617-
618-
return nullptr;
619-
}
620-
621603
std::unique_ptr<AudioFormatWriter> FlacAudioFormat::createWriterFor (std::unique_ptr<OutputStream>& streamToWriteTo,
622604
const AudioFormatWriterOptions& options)
623605
{

modules/juce_audio_formats/codecs/juce_FlacAudioFormat.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ class JUCE_API FlacAudioFormat : public AudioFormat
6969
AudioFormatReader* createReaderFor (InputStream* sourceStream,
7070
bool deleteStreamIfOpeningFails) override;
7171

72-
AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo,
73-
double sampleRateToUse,
74-
unsigned int numberOfChannels,
75-
int bitsPerSample,
76-
const StringPairArray& metadataValues,
77-
int qualityOptionIndex) override;
78-
7972
using AudioFormat::createWriterFor;
8073

8174
private:

modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,30 +234,6 @@ std::unique_ptr<AudioFormatWriter> LAMEEncoderAudioFormat::createWriterFor (std:
234234
options.getMetadataValues());
235235
}
236236

237-
AudioFormatWriter* LAMEEncoderAudioFormat::createWriterFor (OutputStream* streamToWriteTo,
238-
double sampleRateToUse,
239-
unsigned int numberOfChannels,
240-
int bitsPerSample,
241-
const StringPairArray& metadataValues,
242-
int qualityOptionIndex)
243-
{
244-
if (streamToWriteTo == nullptr)
245-
return nullptr;
246-
247-
int vbr = 4;
248-
int cbr = 0;
249-
250-
const String qual (getQualityOptions() [qualityOptionIndex]);
251-
252-
if (qual.contains ("VBR"))
253-
vbr = qual.retainCharacters ("0123456789").getIntValue();
254-
else
255-
cbr = qual.getIntValue();
256-
257-
return new Writer (streamToWriteTo, getFormatName(), lameApp, vbr, cbr,
258-
sampleRateToUse, numberOfChannels, bitsPerSample, metadataValues);
259-
}
260-
261237
#endif
262238

263239
} // namespace juce

modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ class JUCE_API LAMEEncoderAudioFormat : public AudioFormat
7474

7575
AudioFormatReader* createReaderFor (InputStream*, bool deleteStreamIfOpeningFails) override;
7676

77-
AudioFormatWriter* createWriterFor (OutputStream*, double sampleRateToUse,
78-
unsigned int numberOfChannels, int bitsPerSample,
79-
const StringPairArray& metadataValues, int qualityOptionIndex);
80-
8177
using AudioFormat::createWriterFor;
8278

8379
private:

modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,14 +3180,6 @@ std::unique_ptr<AudioFormatWriter> MP3AudioFormat::createWriterFor (std::unique_
31803180
return nullptr;
31813181
}
31823182

3183-
AudioFormatWriter* MP3AudioFormat::createWriterFor (OutputStream*, double /*sampleRateToUse*/,
3184-
unsigned int /*numberOfChannels*/, int /*bitsPerSample*/,
3185-
const StringPairArray& /*metadataValues*/, int /*qualityOptionIndex*/)
3186-
{
3187-
jassertfalse; // not yet implemented!
3188-
return nullptr;
3189-
}
3190-
31913183
#endif
31923184

31933185
} // namespace juce

0 commit comments

Comments
 (0)