Remove playmuted audio configuration

This commit is contained in:
Tiago Koji Castro Shibata
2017-07-18 15:15:04 -03:00
parent 4e9212b152
commit 3dfe3808c6
7 changed files with 24 additions and 41 deletions
+2 -2
View File
@@ -67,12 +67,12 @@ void vibrate();
/**
* Enable mix mode (e.g. with background music apps) and playback with a muted device.
**/
void setAudioMixWithOthers(bool mixMode, bool playMuted);
void setAudioMixWithOthers(bool mixEnabled);
/**
* Returns whether another application is playing audio.
**/
bool audioShouldBeSilenced();
bool hasBackgroundMusic();
} // ios
} // love
+10 -19
View File
@@ -345,35 +345,26 @@ void vibrate()
}
}
void setAudioMixWithOthers(bool mixMode, bool playMuted)
void setAudioMixWithOthers(bool mixEnabled)
{
@autoreleasepool
{
NSString *category = AVAudioSessionCategoryPlayback;
AVAudioSessionCategoryOptions options = 0;
NSError *err = nil;
NSString *category = AVAudioSessionCategorySoloAmbient;
NSError *err;
if (mixMode)
{
if (playMuted)
options = AVAudioSessionCategoryOptionMixWithOthers;
else
category = AVAudioSessionCategoryAmbient;
}
else if (!playMuted)
{
category = AVAudioSessionCategorySoloAmbient;
}
if (mixEnabled)
category = AVAudioSessionCategoryAmbient;
[[AVAudioSession sharedInstance] setCategory:category withOptions:options error:&err];
if (err != nil)
if (![[AVAudioSession sharedInstance] setCategory:category error:&err])
NSLog(@"Error in AVAudioSession setCategory: %@", [err localizedDescription]);
}
}
bool audioShouldBeSilenced()
bool hasBackgroundMusic()
{
return [[AVAudioSession sharedInstance] secondaryAudioShouldBeSilencedHint];
if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(secondaryAudioShouldBeSilencedHint)])
return [[AVAudioSession sharedInstance] secondaryAudioShouldBeSilencedHint];
return false;
}
} // ios
+1 -1
View File
@@ -299,7 +299,7 @@ int w_getDistanceModel(lua_State *L)
#ifdef LOVE_IOS
int w_setMixMode(lua_State *L)
{
love::ios::setAudioMixWithOthers(lua_toboolean(L, 1), lua_toboolean(L, 2));
love::ios::setAudioMixWithOthers(lua_toboolean(L, 1));
#else
int w_setMixMode(lua_State *)
{
+2 -2
View File
@@ -189,9 +189,9 @@ bool System::hasBackgroundMusic() const
#if defined(LOVE_ANDROID)
return love::android::hasBackgroundMusic();
#elif defined(LOVE_IOS)
return love::ios::audioShouldBeSilenced();
return love::ios::hasBackgroundMusic();
#else
throw love::Exception("Unsupported platform.");
return false;
#endif
}
+1 -8
View File
@@ -95,14 +95,7 @@ int w_vibrate(lua_State *L)
int w_hasBackgroundMusic(lua_State *L)
{
try
{
lua_pushboolean(L, instance()->hasBackgroundMusic());
}
catch (love::Exception &)
{
lua_pushnil(L);
}
lua_pushboolean(L, instance()->hasBackgroundMusic());
return 1;
}
+2 -3
View File
@@ -374,8 +374,7 @@ function love.init()
video = true,
},
audio = {
mixmode = true,
playmuted = false,
mixwithsystem = true, -- Only relevant for Android / iOS.
},
console = false, -- Only relevant for windows.
identity = false,
@@ -495,7 +494,7 @@ function love.init()
end
if love.audio then
love.audio.setMixMode(c.audio.mixmode, c.audio.playmuted)
love.audio.setMixMode(c.audio.mixwithsystem)
end
-- Our first timestep, because window creation can take some time
+6 -6
View File
@@ -683,9 +683,10 @@ const unsigned char boot_lua[] =
0x09, 0x09, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x7d, 0x2c, 0x0a,
0x09, 0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x3d, 0x20, 0x7b, 0x0a,
0x09, 0x09, 0x09, 0x6d, 0x69, 0x78, 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x70, 0x6c, 0x61, 0x79, 0x6d, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
0x73, 0x65, 0x2c, 0x0a,
0x09, 0x09, 0x09, 0x6d, 0x69, 0x78, 0x77, 0x69, 0x74, 0x68, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x3d,
0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x20, 0x2d, 0x2d, 0x20, 0x4f, 0x6e, 0x6c, 0x79, 0x20, 0x72, 0x65, 0x6c,
0x65, 0x76, 0x61, 0x6e, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x41, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x20,
0x2f, 0x20, 0x69, 0x4f, 0x53, 0x2e, 0x0a,
0x09, 0x09, 0x7d, 0x2c, 0x0a,
0x09, 0x09, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c,
0x20, 0x2d, 0x2d, 0x20, 0x4f, 0x6e, 0x6c, 0x79, 0x20, 0x72, 0x65, 0x6c, 0x65, 0x76, 0x61, 0x6e, 0x74, 0x20,
@@ -914,9 +915,8 @@ const unsigned char boot_lua[] =
0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x20, 0x74, 0x68, 0x65,
0x6e, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x2e, 0x73, 0x65, 0x74, 0x4d, 0x69,
0x78, 0x4d, 0x6f, 0x64, 0x65, 0x28, 0x63, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x2e, 0x6d, 0x69, 0x78, 0x6d,
0x6f, 0x64, 0x65, 0x2c, 0x20, 0x63, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x2e, 0x70, 0x6c, 0x61, 0x79, 0x6d,
0x75, 0x74, 0x65, 0x64, 0x29, 0x0a,
0x78, 0x4d, 0x6f, 0x64, 0x65, 0x28, 0x63, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x2e, 0x6d, 0x69, 0x78, 0x77,
0x69, 0x74, 0x68, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x29, 0x0a,
0x09, 0x65, 0x6e, 0x64, 0x0a,
0x09, 0x2d, 0x2d, 0x20, 0x4f, 0x75, 0x72, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x74, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x65, 0x70, 0x2c, 0x20, 0x62, 0x65, 0x63, 0x61, 0x75, 0x73, 0x65, 0x20, 0x77, 0x69, 0x6e, 0x64,