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:
fischman@webrtc.org
2012-11-29 23:00:41 +00:00
parent be5b5ba490
commit d814d71d92
3 changed files with 0 additions and 68 deletions

View File

@ -61,12 +61,6 @@
android:id="@+id/LinearLayout03"
android:layout_height="wrap_content"
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
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View File

@ -10,7 +10,6 @@
<string name="remoteIp">Remote IP address</string>
<string name="loopback">Loopback</string>
<string name="stats">Stats</string>
<string name="cpuload">CPULoad</string>
<string name="startListen">Start Listen</string>
<string name="startSend">Start Send</string>
<string name="startBoth">Start Both</string>

View File

@ -122,8 +122,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
private boolean loopbackMode = true;
private CheckBox cbStats;
private boolean isStatsOn = true;
private CheckBox cbCPULoad;
private boolean isCPULoadOn = true;
private boolean useOpenGLRender = true;
// Video settings
@ -178,9 +176,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
"352x288", "640x480" };
private String[] mVoiceCodecsStrings = null;
private Thread mBackgroundLoad = null;
private boolean mIsBackgroudLoadRunning = false;
private OrientationEventListener orientationListener;
int currentOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
int currentCameraOrientation = 0;
@ -391,8 +386,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
if (vieAndroidAPI != null) {
stopCPULoad();
if (voERunning) {
voERunning = false;
stopVoiceEngine();
@ -521,9 +514,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
cbStats = (CheckBox) findViewById(R.id.cbStats);
cbStats.setChecked(isStatsOn);
cbCPULoad = (CheckBox) findViewById(R.id.cbCPULoad);
cbCPULoad.setChecked(isCPULoadOn);
cbVoice = (CheckBox) findViewById(R.id.cbVoice);
cbVoice.setChecked(enableVoice);
@ -568,7 +558,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
etRemoteIp.setOnClickListener(this);
cbLoopback.setOnClickListener(this);
cbStats.setOnClickListener(this);
cbCPULoad.setOnClickListener(this);
cbEnableNack.setOnClickListener(this);
cbEnableSpeaker.setOnClickListener(this);
cbEnableAECM.setOnClickListener(this);
@ -677,13 +666,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
removeStatusView();
}
isCPULoadOn = cbCPULoad.isChecked();
if (isCPULoadOn) {
startCPULoad();
} else {
stopCPULoad();
}
viERunning = true;
}
}
@ -858,14 +840,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
removeStatusView();
}
break;
case R.id.cbCPULoad:
isCPULoadOn = cbCPULoad.isChecked();
if (isCPULoadOn) {
startCPULoad();
} else {
stopCPULoad();
}
break;
case R.id.radio_surface:
useOpenGLRender = false;
break;
@ -1036,39 +1010,4 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
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");
}
}
}
}