Synchronize call statistics update with the LinphoneCore to prevent concurrent access to the statistics structures.

This commit is contained in:
Ghislain MARY 2012-10-09 17:22:52 +02:00
parent 48690086d5
commit 17093d9be5

View file

@ -485,42 +485,39 @@ public class StatusFragment extends Fragment {
return; return;
} }
final LinphoneCallParams params = call.getCurrentParamsCopy(); mHandler.post(new Runnable() {
if (params.getVideoEnabled()) { @Override
final LinphoneCallStats videoStats = call.getVideoStats(); public void run() {
if (videoStats != null) { synchronized(LinphoneManager.getLc()) {
mHandler.post(new Runnable() { final LinphoneCallParams params = call.getCurrentParamsCopy();
@Override if (params.getVideoEnabled()) {
public void run() { final LinphoneCallStats videoStats = call.getVideoStats();
title.setText("Video"); if (videoStats != null) {
PayloadType payload = params.getUsedVideoCodec(); title.setText("Video");
if (payload != null) { PayloadType payload = params.getUsedVideoCodec();
codec.setText(payload.getMime()); if (payload != null) {
codec.setText(payload.getMime());
}
dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) videoStats.getUploadBandwidth()) + " kbits/s");
ice.setText(videoStats.getIceState().toString());
} }
dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " kbits/s"); } else {
ul.setText(String.valueOf((int) videoStats.getUploadBandwidth()) + " kbits/s"); final LinphoneCallStats audioStats = call.getAudioStats();
ice.setText(videoStats.getIceState().toString()); if (audioStats != null) {
} title.setText("Audio");
}); PayloadType payload = params.getUsedAudioCodec();
} if (payload != null) {
} else { codec.setText(payload.getMime());
final LinphoneCallStats audioStats = call.getAudioStats(); }
if (audioStats != null) { dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
mHandler.post(new Runnable() { ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
@Override ice.setText(audioStats.getIceState().toString());
public void run() {
title.setText("Audio");
PayloadType payload = params.getUsedAudioCodec();
if (payload != null) {
codec.setText(payload.getMime());
} }
dl.setText(String.valueOf((int) audioStats.getDownloadBandwidth()) + " kbits/s");
ul.setText(String.valueOf((int) audioStats.getUploadBandwidth()) + " kbits/s");
ice.setText(audioStats.getIceState().toString());
} }
}); }
} }
} });
} }
}; };
mTimer.scheduleAtFixedRate(mTask, 0, 1500); mTimer.scheduleAtFixedRate(mTask, 0, 1500);