Delete {start,stop}CPULoad() since they're broken.
- stopCPULoad is incorrect; since mIsBackgroudLoadRunning isn't declared volatile, the empty while loop in the background thread isn't required to do a memory read (as opposed to reading the value just once and caching it). The result is that stopCPULoad() may never return as the .join() waits forever. - startCPULoad isn't guaranteed to tax the CPU; the JVM is free to replace the while loop in startCPULoad() with a thread pause since it can prove it'll never exit the loop once entered (b/c of the previous item). It's not clear what correct behavior here would be so I'm deleting the code rather than trying to make it work. This was responsible for at least most if not all of the hanginess of start/stop'ing multiple calls in series. BUG=1162 Review URL: https://webrtc-codereview.appspot.com/972008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3202 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -61,12 +61,6 @@
|
|||||||
android:id="@+id/LinearLayout03"
|
android:id="@+id/LinearLayout03"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent">
|
android:layout_width="fill_parent">
|
||||||
<CheckBox android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/cbCPULoad"
|
|
||||||
android:text="@string/cpuload">
|
|
||||||
</CheckBox>
|
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
<string name="remoteIp">Remote IP address</string>
|
<string name="remoteIp">Remote IP address</string>
|
||||||
<string name="loopback">Loopback</string>
|
<string name="loopback">Loopback</string>
|
||||||
<string name="stats">Stats</string>
|
<string name="stats">Stats</string>
|
||||||
<string name="cpuload">CPULoad</string>
|
|
||||||
<string name="startListen">Start Listen</string>
|
<string name="startListen">Start Listen</string>
|
||||||
<string name="startSend">Start Send</string>
|
<string name="startSend">Start Send</string>
|
||||||
<string name="startBoth">Start Both</string>
|
<string name="startBoth">Start Both</string>
|
||||||
|
@ -122,8 +122,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private boolean loopbackMode = true;
|
private boolean loopbackMode = true;
|
||||||
private CheckBox cbStats;
|
private CheckBox cbStats;
|
||||||
private boolean isStatsOn = true;
|
private boolean isStatsOn = true;
|
||||||
private CheckBox cbCPULoad;
|
|
||||||
private boolean isCPULoadOn = true;
|
|
||||||
private boolean useOpenGLRender = true;
|
private boolean useOpenGLRender = true;
|
||||||
|
|
||||||
// Video settings
|
// Video settings
|
||||||
@ -178,9 +176,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
"352x288", "640x480" };
|
"352x288", "640x480" };
|
||||||
private String[] mVoiceCodecsStrings = null;
|
private String[] mVoiceCodecsStrings = null;
|
||||||
|
|
||||||
private Thread mBackgroundLoad = null;
|
|
||||||
private boolean mIsBackgroudLoadRunning = false;
|
|
||||||
|
|
||||||
private OrientationEventListener orientationListener;
|
private OrientationEventListener orientationListener;
|
||||||
int currentOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
|
int currentOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
|
||||||
int currentCameraOrientation = 0;
|
int currentCameraOrientation = 0;
|
||||||
@ -391,8 +386,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
if (vieAndroidAPI != null) {
|
if (vieAndroidAPI != null) {
|
||||||
|
|
||||||
stopCPULoad();
|
|
||||||
|
|
||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
voERunning = false;
|
voERunning = false;
|
||||||
stopVoiceEngine();
|
stopVoiceEngine();
|
||||||
@ -521,9 +514,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
cbStats = (CheckBox) findViewById(R.id.cbStats);
|
cbStats = (CheckBox) findViewById(R.id.cbStats);
|
||||||
cbStats.setChecked(isStatsOn);
|
cbStats.setChecked(isStatsOn);
|
||||||
|
|
||||||
cbCPULoad = (CheckBox) findViewById(R.id.cbCPULoad);
|
|
||||||
cbCPULoad.setChecked(isCPULoadOn);
|
|
||||||
|
|
||||||
cbVoice = (CheckBox) findViewById(R.id.cbVoice);
|
cbVoice = (CheckBox) findViewById(R.id.cbVoice);
|
||||||
cbVoice.setChecked(enableVoice);
|
cbVoice.setChecked(enableVoice);
|
||||||
|
|
||||||
@ -568,7 +558,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
etRemoteIp.setOnClickListener(this);
|
etRemoteIp.setOnClickListener(this);
|
||||||
cbLoopback.setOnClickListener(this);
|
cbLoopback.setOnClickListener(this);
|
||||||
cbStats.setOnClickListener(this);
|
cbStats.setOnClickListener(this);
|
||||||
cbCPULoad.setOnClickListener(this);
|
|
||||||
cbEnableNack.setOnClickListener(this);
|
cbEnableNack.setOnClickListener(this);
|
||||||
cbEnableSpeaker.setOnClickListener(this);
|
cbEnableSpeaker.setOnClickListener(this);
|
||||||
cbEnableAECM.setOnClickListener(this);
|
cbEnableAECM.setOnClickListener(this);
|
||||||
@ -677,13 +666,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
removeStatusView();
|
removeStatusView();
|
||||||
}
|
}
|
||||||
|
|
||||||
isCPULoadOn = cbCPULoad.isChecked();
|
|
||||||
if (isCPULoadOn) {
|
|
||||||
startCPULoad();
|
|
||||||
} else {
|
|
||||||
stopCPULoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
viERunning = true;
|
viERunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -858,14 +840,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
removeStatusView();
|
removeStatusView();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbCPULoad:
|
|
||||||
isCPULoadOn = cbCPULoad.isChecked();
|
|
||||||
if (isCPULoadOn) {
|
|
||||||
startCPULoad();
|
|
||||||
} else {
|
|
||||||
stopCPULoad();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.radio_surface:
|
case R.id.radio_surface:
|
||||||
useOpenGLRender = false;
|
useOpenGLRender = false;
|
||||||
break;
|
break;
|
||||||
@ -1036,39 +1010,4 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
statsView = null;
|
statsView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCPULoad() {
|
|
||||||
if (null == mBackgroundLoad) {
|
|
||||||
mBackgroundLoad = new Thread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Log.v(TAG, "Background load started");
|
|
||||||
mIsBackgroudLoadRunning = true;
|
|
||||||
try {
|
|
||||||
while (mIsBackgroudLoadRunning) {
|
|
||||||
// This while loop simulates cpu load.
|
|
||||||
// Log.v(TAG, "Runnable!!!");
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
Log.v(TAG, "startCPULoad failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mBackgroundLoad.start();
|
|
||||||
} else {
|
|
||||||
if (mBackgroundLoad.getState() == Thread.State.TERMINATED) {
|
|
||||||
mBackgroundLoad.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopCPULoad() {
|
|
||||||
if (null != mBackgroundLoad) {
|
|
||||||
mIsBackgroudLoadRunning = false;
|
|
||||||
try {
|
|
||||||
mBackgroundLoad.join();
|
|
||||||
mBackgroundLoad = null;
|
|
||||||
} catch (Throwable t) {
|
|
||||||
Log.v(TAG, "stopCPULoad failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user