@@ -123,10 +123,12 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
123123 ChannelFormatConverterStream () = default ;
124124 ChannelFormatConverterStream (Stream &stream) { setStream (stream); }
125125 ChannelFormatConverterStream (Print &print) { setOutput (print); }
126- ChannelFormatConverterStream (ChannelFormatConverterStream const &) = delete ;
126+ ChannelFormatConverterStream (ChannelFormatConverterStream &from) { copy (from);} ;
127127 virtual ~ChannelFormatConverterStream () { end (); }
128- ChannelFormatConverterStream &operator =(
129- ChannelFormatConverterStream const &) = delete ;
128+ ChannelFormatConverterStream &operator =(ChannelFormatConverterStream &from) {
129+ copy (from);
130+ return *this ;
131+ }
130132
131133 void setAudioInfo (AudioInfo cfg) override {
132134 TRACED ();
@@ -175,8 +177,8 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
175177
176178 bool begin () override { return begin (audioInfo (), to_channels); }
177179
178- void end () override {
179- cleanupConverter ();
180+ void end () override {
181+ cleanupConverter ();
180182 is_active = false ;
181183 }
182184
@@ -257,6 +259,17 @@ class ChannelFormatConverterStream : public ReformatBaseStream {
257259 int from_channels = 0 ;
258260 bool is_active = false ;
259261
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+
260273 template <typename T>
261274 ChannelFormatConverterStreamT<T> *getConverter () {
262275 return (ChannelFormatConverterStreamT<T> *)converter;
@@ -779,7 +792,6 @@ class FormatConverterStream : public ReformatBaseStream {
779792 ReformatBaseStream::setAudioInfo (info);
780793 // ChannelFormatConverter -> NumberFormatConverter -> SampleRateCoverter
781794 channelFormatConverter.setAudioInfo (info);
782-
783795 }
784796
785797 void setAudioInfoOut (AudioInfo to) { to_cfg = to; }
@@ -850,13 +862,12 @@ class FormatConverterStream : public ReformatBaseStream {
850862 }
851863
852864 protected:
853- AudioInfo& from_cfg = info;
865+ AudioInfo & from_cfg = info;
854866 AudioInfo to_cfg;
855867 NumberFormatConverterStream numberFormatConverter;
856868 ChannelFormatConverterStream channelFormatConverter;
857869 ResampleStream sampleRateConverter;
858870 bool is_buffered = true ;
859-
860871};
861872
862873} // namespace audio_tools
0 commit comments