use lock with thread only
This commit is contained in:
parent
e7878a82a6
commit
0703333a32
2 changed files with 7 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ import android.media.MediaRecorder;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.media.session.MediaButtonReceiver;
|
||||
|
|
@ -861,6 +862,10 @@ public class RecordingActivity extends AppCompatThemeActivity {
|
|||
}
|
||||
}
|
||||
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wlcpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RecordingService.class.getCanonicalName() + "_cpulock");
|
||||
wlcpu.acquire();
|
||||
|
||||
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_AUDIO);
|
||||
|
||||
try {
|
||||
|
|
@ -947,6 +952,8 @@ public class RecordingActivity extends AppCompatThemeActivity {
|
|||
} catch (final RuntimeException e) {
|
||||
Post(e);
|
||||
} finally {
|
||||
wlcpu.release();
|
||||
|
||||
// redraw view, we may add one last pich which is not been drawen because draw tread already interrupted.
|
||||
// to prevent resume recording jump - draw last added pitch here.
|
||||
handler.post(new Runnable() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
|
|
@ -41,7 +40,6 @@ public class RecordingService extends Service {
|
|||
|
||||
Storage storage; // for storage path
|
||||
Notification notification;
|
||||
PowerManager.WakeLock wlcpu;
|
||||
|
||||
public static void startIfEnabled(Context context) {
|
||||
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
|
@ -110,10 +108,6 @@ public class RecordingService extends Service {
|
|||
storage = new Storage(this);
|
||||
|
||||
showNotification(true, new Intent());
|
||||
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wlcpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, RecordingService.class.getCanonicalName() + "_cpulock");
|
||||
wlcpu.acquire();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue