Bug 1458020 - 5. Return default sample rate / frames per buffer; r?esawin
We apparently fail to get these properties when running in an emulator,
so we should just return default values.
MozReview-Commit-ID: IZVYIG9INaq
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -299,23 +299,23 @@ cubeb* GetCubebContext()
}
bool InitPreferredSampleRate()
{
StaticMutexAutoLock lock(sMutex);
if (sPreferredSampleRate != 0) {
return true;
}
+#ifdef MOZ_WIDGET_ANDROID
+ sPreferredSampleRate = AndroidGetAudioOutputSampleRate();
+#else
cubeb* context = GetCubebContextUnlocked();
if (!context) {
return false;
}
-#ifdef MOZ_WIDGET_ANDROID
- sPreferredSampleRate = AndroidGetAudioOutputSampleRate();
-#else
if (cubeb_get_preferred_sample_rate(context,
&sPreferredSampleRate) != CUBEB_OK) {
return false;
}
#endif
MOZ_ASSERT(sPreferredSampleRate);
return true;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1846,44 +1846,48 @@ public class GeckoAppShell
final Display disp = wm.getDefaultDisplay();
sScreenSize = new Rect(0, 0, disp.getWidth(), disp.getHeight());
}
return sScreenSize;
}
@WrapForJNI(calledFrom = "any")
public static int getAudioOutputFramesPerBuffer() {
+ final int DEFAULT = 512;
+
if (SysInfo.getVersion() < 17) {
- return 0;
+ return DEFAULT;
}
final AudioManager am = (AudioManager)getApplicationContext()
.getSystemService(Context.AUDIO_SERVICE);
if (am == null) {
- return 0;
+ return DEFAULT;
}
final String prop = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
if (prop == null) {
- return 0;
+ return DEFAULT;
}
return Integer.parseInt(prop);
}
@WrapForJNI(calledFrom = "any")
public static int getAudioOutputSampleRate() {
+ final int DEFAULT = 44100;
+
if (SysInfo.getVersion() < 17) {
- return 0;
+ return DEFAULT;
}
final AudioManager am = (AudioManager)getApplicationContext()
.getSystemService(Context.AUDIO_SERVICE);
if (am == null) {
- return 0;
+ return DEFAULT;
}
final String prop = am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
if (prop == null) {
- return 0;
+ return DEFAULT;
}
return Integer.parseInt(prop);
}
@WrapForJNI
public static String getDefaultLocale() {
final Locale locale = Locale.getDefault();
if (Build.VERSION.SDK_INT >= 21) {