зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1316934 - [3.1] Add JNI for AudioManager properties. r=snorp
This commit is contained in:
Родитель
e6065804c9
Коммит
f2591d27c0
|
@ -30,6 +30,7 @@ import org.mozilla.gecko.annotation.WrapForJNI;
|
|||
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||
import org.mozilla.gecko.permissions.Permissions;
|
||||
import org.mozilla.gecko.process.GeckoProcessManager;
|
||||
import org.mozilla.gecko.SysInfo;
|
||||
import org.mozilla.gecko.util.HardwareCodecCapabilityUtils;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
import org.mozilla.gecko.util.IOUtils;
|
||||
|
@ -69,6 +70,7 @@ import android.location.Criteria;
|
|||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
|
@ -1812,4 +1814,38 @@ public class GeckoAppShell
|
|||
private static int startGeckoServiceChildProcess(String type, String[] args, int crashFd, int ipcFd) {
|
||||
return GeckoProcessManager.getInstance().start(type, args, crashFd, ipcFd);
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static int getAudioOutputFramesPerBuffer() {
|
||||
if (SysInfo.getVersion() < 17) {
|
||||
return 0;
|
||||
}
|
||||
final AudioManager am = (AudioManager)getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (am == null) {
|
||||
return 0;
|
||||
}
|
||||
final String prop = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
|
||||
if (prop == null) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(prop);
|
||||
}
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public static int getAudioOutputSampleRate() {
|
||||
if (SysInfo.getVersion() < 17) {
|
||||
return 0;
|
||||
}
|
||||
final AudioManager am = (AudioManager)getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (am == null) {
|
||||
return 0;
|
||||
}
|
||||
final String prop = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
|
||||
if (prop == null) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(prop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,6 +235,22 @@ auto GeckoAppShell::GetApplicationContext() -> mozilla::jni::Object::LocalRef
|
|||
return mozilla::jni::Method<GetApplicationContext_t>::Call(GeckoAppShell::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::GetAudioOutputFramesPerBuffer_t::name[];
|
||||
constexpr char GeckoAppShell::GetAudioOutputFramesPerBuffer_t::signature[];
|
||||
|
||||
auto GeckoAppShell::GetAudioOutputFramesPerBuffer() -> int32_t
|
||||
{
|
||||
return mozilla::jni::Method<GetAudioOutputFramesPerBuffer_t>::Call(GeckoAppShell::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::GetAudioOutputSampleRate_t::name[];
|
||||
constexpr char GeckoAppShell::GetAudioOutputSampleRate_t::signature[];
|
||||
|
||||
auto GeckoAppShell::GetAudioOutputSampleRate() -> int32_t
|
||||
{
|
||||
return mozilla::jni::Method<GetAudioOutputSampleRate_t>::Call(GeckoAppShell::Context(), nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::GetConnection_t::name[];
|
||||
constexpr char GeckoAppShell::GetConnection_t::signature[];
|
||||
|
||||
|
|
|
@ -688,6 +688,44 @@ public:
|
|||
|
||||
static auto GetApplicationContext() -> mozilla::jni::Object::LocalRef;
|
||||
|
||||
struct GetAudioOutputFramesPerBuffer_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef int32_t ReturnType;
|
||||
typedef int32_t SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getAudioOutputFramesPerBuffer";
|
||||
static constexpr char signature[] =
|
||||
"()I";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto GetAudioOutputFramesPerBuffer() -> int32_t;
|
||||
|
||||
struct GetAudioOutputSampleRate_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef int32_t ReturnType;
|
||||
typedef int32_t SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getAudioOutputSampleRate";
|
||||
static constexpr char signature[] =
|
||||
"()I";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::GECKO;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::CURRENT;
|
||||
};
|
||||
|
||||
static auto GetAudioOutputSampleRate() -> int32_t;
|
||||
|
||||
struct GetConnection_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef mozilla::jni::Object::LocalRef ReturnType;
|
||||
|
|
Загрузка…
Ссылка в новой задаче