Change summary
src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java | 14
src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java | 4
src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java | 11
3 files changed, 19 insertions(+), 10 deletions(-)
Detailed changes
@@ -910,15 +910,17 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
}
private void disableMicrophone(View view) {
- JingleRtpConnection rtpConnection = requireRtpConnection();
- rtpConnection.setMicrophoneEnabled(false);
- updateInCallButtonConfiguration();
+ final JingleRtpConnection rtpConnection = requireRtpConnection();
+ if (rtpConnection.setMicrophoneEnabled(false)) {
+ updateInCallButtonConfiguration();
+ }
}
private void enableMicrophone(View view) {
- JingleRtpConnection rtpConnection = requireRtpConnection();
- rtpConnection.setMicrophoneEnabled(true);
- updateInCallButtonConfiguration();
+ final JingleRtpConnection rtpConnection = requireRtpConnection();
+ if (rtpConnection.setMicrophoneEnabled(true)) {
+ updateInCallButtonConfiguration();
+ }
}
private void switchToEarpiece(View view) {
@@ -1085,8 +1085,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return webRTCWrapper.isMicrophoneEnabled();
}
- public void setMicrophoneEnabled(final boolean enabled) {
- webRTCWrapper.setMicrophoneEnabled(enabled);
+ public boolean setMicrophoneEnabled(final boolean enabled) {
+ return webRTCWrapper.setMicrophoneEnabled(enabled);
}
public boolean isVideoEnabled() {
@@ -370,12 +370,19 @@ public class WebRTCWrapper {
}
}
- void setMicrophoneEnabled(final boolean enabled) {
+ boolean setMicrophoneEnabled(final boolean enabled) {
final AudioTrack audioTrack = this.localAudioTrack;
if (audioTrack == null) {
throw new IllegalStateException("Local audio track does not exist (yet)");
}
- audioTrack.setEnabled(enabled);
+ try {
+ audioTrack.setEnabled(enabled);
+ return true;
+ } catch (final IllegalStateException e) {
+ Log.d(Config.LOGTAG, "unable to toggle microphone", e);
+ //ignoring race condition in case MediaStreamTrack has been disposed
+ return false;
+ }
}
boolean isVideoEnabled() {