Skip to content

Commit 02af39d

Browse files
Checking if multicastLock isHeld before trying to release it, avoiding stopServiceDiscovery call if discovery failed to start
1 parent eff5773 commit 02af39d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/NsdDiscoveryListener.java

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public void onStartDiscoveryFailed(String serviceType, int errorCode) {
111111
failureCallback.handle(
112112
new MatterError(
113113
3, "NsdDiscoveryListener Discovery failed to start: Nsd Error code:" + errorCode));
114-
nsdManager.stopServiceDiscovery(this);
115114
}
116115

117116
@Override
@@ -123,6 +122,5 @@ public void onStopDiscoveryFailed(String serviceType, int errorCode) {
123122
failureCallback.handle(
124123
new MatterError(
125124
3, "NsdDiscoveryListener Discovery failed to stop: Nsd Error code:" + errorCode));
126-
nsdManager.stopServiceDiscovery(this);
127125
}
128126
}

examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ public void discoverVideoPlayerCommissioners(
137137
public void run() {
138138
Log.d(TAG, "TvCastingApp stopping Video Player commissioner discovery");
139139
nsdManager.stopServiceDiscovery(nsdDiscoveryListener);
140-
multicastLock.release();
140+
if (multicastLock.isHeld()) {
141+
multicastLock.release();
142+
}
141143
}
142144
},
143145
discoveryDurationSeconds,

0 commit comments

Comments
 (0)