Skip to content

Commit 54290f4

Browse files
committed
I2SStream: initialize mute pin
1 parent 776f8d6 commit 54290f4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/AudioTools/CoreAudio/AudioI2S/I2SStream.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class I2SStream : public AudioStream {
3434
public:
3535
I2SStream() = default;
3636
~I2SStream() { end(); }
37-
37+
3838
#ifdef ARDUINO
3939
I2SStream(int mute_pin) {
4040
TRACED();
@@ -83,10 +83,12 @@ class I2SStream : public AudioStream {
8383

8484
/// Stops the I2S interface
8585
void end() {
86-
TRACEI();
87-
is_active = false;
88-
mute(true);
89-
i2s.end();
86+
if (is_active) {
87+
TRACEI();
88+
is_active = false;
89+
mute(true);
90+
i2s.end();
91+
}
9092
}
9193

9294
/// updates the sample rate dynamically
@@ -143,7 +145,7 @@ class I2SStream : public AudioStream {
143145

144146
protected:
145147
I2SDriver i2s;
146-
int mute_pin;
148+
int mute_pin = -1;
147149
bool is_active = false;
148150

149151
/// set mute pin on or off

0 commit comments

Comments
 (0)