Browse Source

Fixed audio on android to properly pause when the app is inactive, and resume when the app becomes active again.

Alex Szpakowski 9 years ago
parent
commit
c2de8dbb6a
1 changed files with 15 additions and 16 deletions
  1. 15 16
      src/modules/event/sdl/Event.cpp

+ 15 - 16
src/modules/event/sdl/Event.cpp

@@ -510,22 +510,6 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
 			msg = new Message("joystickremoved", vargs);
 		}
 		break;
-#ifdef LOVE_ANDROID
-	case SDL_WINDOWEVENT_MINIMIZED:
-		{
-			auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
-			if (audio)
-				audio->pause();
-		}
-		break;
-	case SDL_WINDOWEVENT_RESTORED:
-		{
-			auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
-			if (audio)
-				audio->resume();
-		}
-		break;
-#endif
 	default:
 		break;
 	}
@@ -590,6 +574,21 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
 		if (win)
 			win->onSizeChanged(e.window.data1, e.window.data2);
 		break;
+	case SDL_WINDOWEVENT_MINIMIZED:
+	case SDL_WINDOWEVENT_RESTORED:
+#ifdef LOVE_ANDROID
+	{
+		auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
+		if (audio)
+		{
+			if (e.window.event == SDL_WINDOWEVENT_MINIMIZED)
+				audio->pause();
+			else if (e.window.event == SDL_WINDOWEVENT_RESTORED)
+				audio->resume();
+		}
+	}
+#endif
+		break;
 	}
 
 	// We gave +1 refs to the StrongRef list, so we should release them.