Bug 947431 - Be more robust when getting the preferred sample rate when using the OpenSL backend. r=kinetik, a=1.3+
authorPaul Adenot <paul@paul.cx>
Thu, 12 Dec 2013 18:35:39 +0100
changeset 174282 1421a38232f6c4a339747ec4eba1a3f362ad9651
parent 174281 f80174c5dfcedcd6c8825a552e701d1f5ab96212
child 174283 f1529e29e80587693c33097659bf6150b2923747
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, 1
bugs947431
milestone28.0a2
Bug 947431 - Be more robust when getting the preferred sample rate when using the OpenSL backend. r=kinetik, a=1.3+
media/libcubeb/src/cubeb_opensl.c
--- a/media/libcubeb/src/cubeb_opensl.c
+++ b/media/libcubeb/src/cubeb_opensl.c
@@ -270,16 +270,24 @@ opensl_get_preferred_sample_rate(cubeb *
     if (rv) {
       dlclose(libmedia);
       return CUBEB_ERROR;
     }
   }
 
   dlclose(libmedia);
 
+  /* Depending on which method we called above, we can get a zero back, yet have
+   * a non-error return value, especially if the audio system is not
+   * ready/shutting down (i.e. when we can't get our hand on the AudioFlinger
+   * thread). */
+  if (rate == 0) {
+    return CUBEB_ERROR;
+  }
+
   return CUBEB_OK;
 }
 
 static int
 opensl_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_ms)
 {
   /* https://android.googlesource.com/platform/ndk.git/+/master/docs/opensles/index.html
    * We don't want to deal with JNI here (and we don't have Java on b2g anyways),