@@ -123,10 +123,12 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
123
123
ChannelFormatConverterStream () = default ;
124
124
ChannelFormatConverterStream (Stream &stream) { setStream (stream); }
125
125
ChannelFormatConverterStream (Print &print) { setOutput (print); }
126
- ChannelFormatConverterStream (ChannelFormatConverterStream const &) = delete ;
126
+ ChannelFormatConverterStream (ChannelFormatConverterStream &from) { copy (from);} ;
127
127
virtual ~ChannelFormatConverterStream () { end (); }
128
- ChannelFormatConverterStream &operator =(
129
- ChannelFormatConverterStream const &) = delete ;
128
+ ChannelFormatConverterStream &operator =(ChannelFormatConverterStream &from) {
129
+ copy (from);
130
+ return *this ;
131
+ }
130
132
131
133
void setAudioInfo (AudioInfo cfg) override {
132
134
TRACED ();
@@ -175,8 +177,8 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
175
177
176
178
bool begin () override { return begin (audioInfo (), to_channels); }
177
179
178
- void end () override {
179
- cleanupConverter ();
180
+ void end () override {
181
+ cleanupConverter ();
180
182
is_active = false ;
181
183
}
182
184
@@ -257,6 +259,17 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
257
259
int from_channels = 0 ;
258
260
bool is_active = false ;
259
261
262
+ void copy (ChannelFormatConverterStream &from) {
263
+ converter = nullptr ;
264
+ if (from.converter != nullptr ) {
265
+ setupConverter (from.from_channels , from.to_channels );
266
+ }
267
+ bits_per_sample = from.bits_per_sample ;
268
+ to_channels = from.to_channels ;
269
+ from_channels = from.from_channels ;
270
+ is_active = from.is_active ;
271
+ };
272
+
260
273
template <typename T>
261
274
ChannelFormatConverterStreamT<T> *getConverter () {
262
275
return (ChannelFormatConverterStreamT<T> *)converter;
@@ -779,7 +792,6 @@ class FormatConverterStream : public ReformatBaseStream {
779
792
ReformatBaseStream::setAudioInfo (info);
780
793
// ChannelFormatConverter -> NumberFormatConverter -> SampleRateCoverter
781
794
channelFormatConverter.setAudioInfo (info);
782
-
783
795
}
784
796
785
797
void setAudioInfoOut (AudioInfo to) { to_cfg = to; }
@@ -850,13 +862,12 @@ class FormatConverterStream : public ReformatBaseStream {
850
862
}
851
863
852
864
protected:
853
- AudioInfo& from_cfg = info;
865
+ AudioInfo & from_cfg = info;
854
866
AudioInfo to_cfg;
855
867
NumberFormatConverterStream numberFormatConverter;
856
868
ChannelFormatConverterStream channelFormatConverter;
857
869
ResampleStream sampleRateConverter;
858
870
bool is_buffered = true ;
859
-
860
871
};
861
872
862
873
} // namespace audio_tools
0 commit comments