@@ -102,17 +102,30 @@ bool OSSMixerControl::updateValue() {
102102 }
103103
104104 auto value = 0 ;
105+ auto changed = false ;
105106
106107 if (ioctl (fd, MIXER_READ (this ->mMixerId ), &value) < 0 ) { // NOLINT
107108 close (fd);
109+ qCWarning (logOSS) << " Failed to read mixer" ;
108110 return false ;
109111 }
110112
111- close (fd);
112-
113113 auto newLeft = value & 0xFF ;
114114 auto newRight = (value >> 8 ) & 0xFF ;
115- auto changed = false ;
115+ auto muteValue = 0 ;
116+ bool newMuted = false ;
117+
118+ if (ioctl (fd, SOUND_MIXER_READ_MUTE, &muteValue) >= 0 ) { // NOLINT
119+ newMuted = (muteValue & (1 << this ->mMixerId )) != 0 ;
120+ }
121+
122+ close (fd);
123+
124+ if (this ->mMuted != newMuted) {
125+ this ->mMuted = newMuted;
126+ emit this ->mutedChanged ();
127+ changed = true ;
128+ }
116129
117130 if (this ->mLeft != newLeft) {
118131 this ->mLeft = newLeft;
@@ -141,8 +154,8 @@ bool OSSMixerControl::writeValue() {
141154 return false ;
142155 }
143156
144- auto left = this ->mMuted ? 0 : this -> mLeft ;
145- auto right = this ->mMuted ? 0 : ( this -> mStereo ? this ->mRight : this ->mLeft ) ;
157+ auto left = this ->mLeft ;
158+ auto right = this ->mStereo ? this ->mRight : this ->mLeft ;
146159 auto value = (right << 8 ) | left;
147160
148161 if (ioctl (fd, MIXER_WRITE (this ->mMixerId ), &value) < 0 ) { // NOLINT
@@ -151,6 +164,20 @@ bool OSSMixerControl::writeValue() {
151164 return false ;
152165 }
153166
167+ auto muteValue = 0 ;
168+
169+ if (ioctl (fd, SOUND_MIXER_READ_MUTE, &muteValue) >= 0 ) { // NOLINT
170+ if (this ->mMuted ) {
171+ muteValue |= (1 << this ->mMixerId );
172+ } else {
173+ muteValue &= ~(1 << this ->mMixerId );
174+ }
175+
176+ if (ioctl (fd, SOUND_MIXER_WRITE_MUTE, &muteValue) < 0 ) {
177+ qCWarning (logOSS) << " Failed to write mute state for control:" << this ->mName ;
178+ }
179+ }
180+
154181 close (fd);
155182 return true ;
156183}
0 commit comments