mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Move setMixMode to love.audio
This commit is contained in:
+10
-12
@@ -349,25 +349,23 @@ void setAudioMixWithOthers(bool mixMode, bool playMuted)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
NSError* err;
|
||||
NSString *category = AVAudioSessionCategoryPlayback;
|
||||
AVAudioSessionCategoryOptions options = 0;
|
||||
NSError *err = nil;
|
||||
|
||||
if (mixMode)
|
||||
{
|
||||
if (playMuted)
|
||||
{
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&err];
|
||||
}
|
||||
options = AVAudioSessionCategoryOptionMixWithOthers;
|
||||
else
|
||||
{
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&err];
|
||||
}
|
||||
category = AVAudioSessionCategoryAmbient;
|
||||
}
|
||||
else
|
||||
else if (!playMuted)
|
||||
{
|
||||
if (playMuted)
|
||||
{
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&err];
|
||||
}
|
||||
category = AVAudioSessionCategorySoloAmbient;
|
||||
}
|
||||
|
||||
[[AVAudioSession sharedInstance] setCategory:category withOptions:options error:&err];
|
||||
if (err != nil)
|
||||
NSLog(@"Error in AVAudioSession setCategory: %@", [err localizedDescription]);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include "null/Audio.h"
|
||||
|
||||
#include "common/runtime.h"
|
||||
#ifdef LOVE_IOS
|
||||
#include "common/ios.h"
|
||||
#endif
|
||||
|
||||
// C++
|
||||
#include <iostream>
|
||||
@@ -294,6 +296,17 @@ int w_getDistanceModel(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef LOVE_IOS
|
||||
int w_setMixMode(lua_State *L)
|
||||
{
|
||||
love::ios::setAudioMixWithOthers(lua_toboolean(L, 1), lua_toboolean(L, 2));
|
||||
#else
|
||||
int w_setMixMode(lua_State *)
|
||||
{
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_getShouldBeSilenced(lua_State *L)
|
||||
{
|
||||
#ifdef LOVE_IOS
|
||||
@@ -329,6 +342,7 @@ static const luaL_Reg functions[] =
|
||||
{ "stopRecording", w_stopRecording },*/
|
||||
{ "setDistanceModel", w_setDistanceModel },
|
||||
{ "getDistanceModel", w_getDistanceModel },
|
||||
{ "setMixMode", w_setMixMode },
|
||||
{ "getShouldBeSilenced", w_getShouldBeSilenced },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "common/version.h"
|
||||
#include "common/runtime.h"
|
||||
#include "common/wrap_Data.h"
|
||||
#include "common/ios.h"
|
||||
|
||||
#include "love.h"
|
||||
|
||||
@@ -259,14 +258,6 @@ static int w__setGammaCorrect(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef LOVE_IOS
|
||||
static int w__setAudioMixMode(lua_State *L)
|
||||
{
|
||||
love::ios::setAudioMixWithOthers(lua_toboolean(L, 1), lua_toboolean(L, 2));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int luaopen_love(lua_State *L)
|
||||
{
|
||||
love::luax_insistpinnedthread(L);
|
||||
@@ -300,11 +291,6 @@ int luaopen_love(lua_State *L)
|
||||
lua_pushcfunction(L, w__setGammaCorrect);
|
||||
lua_setfield(L, -2, "_setGammaCorrect");
|
||||
|
||||
#ifdef LOVE_IOS
|
||||
lua_pushcfunction(L, w__setAudioMixMode);
|
||||
lua_setfield(L, -2, "_setAudioMixMode");
|
||||
#endif
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for (int i = 0; love::VERSION_COMPATIBILITY[i] != nullptr; i++)
|
||||
|
||||
@@ -420,10 +420,6 @@ function love.init()
|
||||
love._setGammaCorrect(c.gammacorrect)
|
||||
end
|
||||
|
||||
if love._setAudioMixMode then
|
||||
love._setAudioMixMode(c.audio.mixmode, c.audio.playmuted)
|
||||
end
|
||||
|
||||
-- Gets desired modules.
|
||||
for k,v in ipairs{
|
||||
"thread",
|
||||
@@ -498,6 +494,10 @@ function love.init()
|
||||
end
|
||||
end
|
||||
|
||||
if love.audio then
|
||||
love.audio.setMixMode(c.audio.mixmode, c.audio.playmuted)
|
||||
end
|
||||
|
||||
-- Our first timestep, because window creation can take some time
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
|
||||
@@ -781,13 +781,6 @@ const unsigned char boot_lua[] =
|
||||
0x72, 0x72, 0x65, 0x63, 0x74, 0x28, 0x63, 0x2e, 0x67, 0x61, 0x6d, 0x6d, 0x61, 0x63, 0x6f, 0x72, 0x72, 0x65,
|
||||
0x63, 0x74, 0x29, 0x0a,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x73, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f,
|
||||
0x4d, 0x69, 0x78, 0x4d, 0x6f, 0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x5f, 0x73, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 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,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x09, 0x2d, 0x2d, 0x20, 0x47, 0x65, 0x74, 0x73, 0x20, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x20, 0x6d,
|
||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2e, 0x0a,
|
||||
0x09, 0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x76, 0x20, 0x69, 0x6e, 0x20, 0x69, 0x70, 0x61, 0x69, 0x72, 0x73,
|
||||
@@ -918,6 +911,13 @@ const unsigned char boot_lua[] =
|
||||
0x77, 0x2e, 0x69, 0x63, 0x6f, 0x6e, 0x29, 0x29, 0x0a,
|
||||
0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x0a,
|
||||
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,
|
||||
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,
|
||||
0x6f, 0x77, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x74, 0x61,
|
||||
|
||||
Reference in New Issue
Block a user