mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 04:09:18 +01:00
Pausing should mute audio for looped music
Also adds pausing the surface in onPause and restoring it in onResume to avoid wasting resources when the activity is legitimately in the background.
This commit is contained in:
parent
df96d74ca1
commit
69e322b76b
@ -346,13 +346,24 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
executeApplication(intent!!)
|
executeApplication(intent!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun pauseEmulator() {
|
||||||
|
setSurface(null)
|
||||||
|
changeAudioStatus(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun resumeEmulator() {
|
||||||
|
gameSurface?.let { setSurface(it) }
|
||||||
|
if (!emulationSettings.isAudioOutputDisabled)
|
||||||
|
changeAudioStatus(true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
||||||
if (emulationSettings.forceMaxGpuClocks)
|
if (emulationSettings.forceMaxGpuClocks)
|
||||||
GpuDriverHelper.forceMaxGpuClocks(false)
|
GpuDriverHelper.forceMaxGpuClocks(false)
|
||||||
|
|
||||||
changeAudioStatus(false)
|
pauseEmulator()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
@ -368,7 +379,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
changeAudioStatus(true)
|
resumeEmulator()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@ -387,7 +398,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
pictureInPictureReceiver = object : BroadcastReceiver() {
|
pictureInPictureReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context : Context?, intent : Intent) {
|
override fun onReceive(context : Context?, intent : Intent) {
|
||||||
if (intent.action == pauseIntentAction)
|
if (intent.action == pauseIntentAction)
|
||||||
setSurface(null)
|
pauseEmulator()
|
||||||
else if (intent.action == muteIntentAction)
|
else if (intent.action == muteIntentAction)
|
||||||
changeAudioStatus(false)
|
changeAudioStatus(false)
|
||||||
}
|
}
|
||||||
@ -411,10 +422,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
// Perfectly acceptable and should be ignored
|
// Perfectly acceptable and should be ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
gameSurface?.let { setSurface(it) }
|
resumeEmulator()
|
||||||
|
|
||||||
if (!emulationSettings.isAudioOutputDisabled)
|
|
||||||
changeAudioStatus(true)
|
|
||||||
|
|
||||||
binding.onScreenControllerView.apply {
|
binding.onScreenControllerView.apply {
|
||||||
controllerType = inputHandler.getFirstControllerType()
|
controllerType = inputHandler.getFirstControllerType()
|
||||||
|
Loading…
Reference in New Issue
Block a user