Bug 962346 - Pass STACK_SIZE_PARAM_IS_A_RESERVATION to _beginthreadex in Windows cubeb backends to save address space. r=padenot
authorMatthew Gregan <kinetik@flim.org>
Wed, 22 Jan 2014 13:52:46 +1300
changeset 166845 f28aaa1b3df5f7c14176c9992ff09a65646569f9
parent 166844 ed9194eec73b51ed39670ad6740dd3eb06e97f1f
child 166846 0880728975f7a7db09ec2be54185bb83ce4fa5b0
push id39308
push usermgregan@mozilla.com
push dateWed, 05 Feb 2014 02:47:59 +0000
treeherdermozilla-inbound@f28aaa1b3df5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs962346
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 962346 - Pass STACK_SIZE_PARAM_IS_A_RESERVATION to _beginthreadex in Windows cubeb backends to save address space. r=padenot
media/libcubeb/README_MOZILLA
media/libcubeb/include/cubeb.h
media/libcubeb/src/cubeb.c
media/libcubeb/src/cubeb_alsa.c
media/libcubeb/src/cubeb_audiounit.c
media/libcubeb/src/cubeb_opensl.c
media/libcubeb/src/cubeb_sndio.c
media/libcubeb/src/cubeb_wasapi.cpp
media/libcubeb/src/cubeb_winmm.c
--- a/media/libcubeb/README_MOZILLA
+++ b/media/libcubeb/README_MOZILLA
@@ -1,8 +1,8 @@
 The source from this directory was copied from the cubeb 
 git repository using the update.sh script.  The only changes
 made were those applied by update.sh and the addition of
 Makefile.in build files for the Mozilla build system.
 
 The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
 
-The git commit ID used was a137c78c4ba1a6b0ebde5548664bdf6390ef5437.
+The git commit ID used was e8df12d770c6299640540e91cec13dc81efc9bbe.
--- a/media/libcubeb/include/cubeb.h
+++ b/media/libcubeb/include/cubeb.h
@@ -66,17 +66,16 @@ extern "C" {
     @code
     void state_cb(cubeb_stream * stm, void * user, cubeb_state state)
     {
       printf("state=%d\n", state);
     }
     @endcode
 */
 
-
 /** @file
     The <tt>libcubeb</tt> C API. */
 
 typedef struct cubeb cubeb;               /**< Opaque handle referencing the application state. */
 typedef struct cubeb_stream cubeb_stream; /**< Opaque handle referencing the stream state. */
 
 /** Sample format enumeration. */
 typedef enum {
--- a/media/libcubeb/src/cubeb.c
+++ b/media/libcubeb/src/cubeb.c
@@ -53,17 +53,17 @@ int opensl_init(cubeb ** context, char c
 #endif
 #if defined(USE_AUDIOTRACK)
 int audiotrack_init(cubeb ** context, char const * context_name);
 #endif
 
 int
 validate_stream_params(cubeb_stream_params stream_params)
 {
-  if (stream_params.rate < 1 || stream_params.rate > 192000 ||
+  if (stream_params.rate < 1000 || stream_params.rate > 192000 ||
       stream_params.channels < 1 || stream_params.channels > 8) {
     return CUBEB_ERROR_INVALID_FORMAT;
   }
 
   switch (stream_params.format) {
   case CUBEB_SAMPLE_S16LE:
   case CUBEB_SAMPLE_S16BE:
   case CUBEB_SAMPLE_FLOAT32LE:
--- a/media/libcubeb/src/cubeb_alsa.c
+++ b/media/libcubeb/src/cubeb_alsa.c
@@ -565,17 +565,16 @@ init_local_config_with_workaround(char c
     return lconf;
   } while (0);
 
   snd_config_delete(lconf);
 
   return NULL;
 }
 
-
 static int
 alsa_locked_pcm_open(snd_pcm_t ** pcm, snd_pcm_stream_t stream, snd_config_t * local_config)
 {
   int r;
 
   pthread_mutex_lock(&cubeb_alsa_mutex);
   if (local_config) {
     r = snd_pcm_open_lconf(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK, local_config);
@@ -976,17 +975,16 @@ alsa_get_min_latency(cubeb * ctx, cubeb_
 {
   /* This is found to be an acceptable minimum, even on a super low-end
   * machine. */
   *latency_ms = 40;
 
   return CUBEB_OK;
 }
 
-
 static int
 alsa_stream_start(cubeb_stream * stm)
 {
   cubeb * ctx;
 
   assert(stm);
   ctx = stm->context;
 
--- a/media/libcubeb/src/cubeb_audiounit.c
+++ b/media/libcubeb/src/cubeb_audiounit.c
@@ -183,17 +183,16 @@ audiounit_get_acceptable_latency_range(A
                                  latency_range);
   if (r != noErr) {
     return CUBEB_ERROR;
   }
 
   return CUBEB_OK;
 }
 
-
 int
 audiounit_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
 {
   UInt32 size;
   OSStatus r;
   AudioDeviceID output_device_id;
   AudioStreamBasicDescription stream_format;
   AudioObjectPropertyAddress stream_format_address = {
@@ -268,17 +267,16 @@ audiounit_get_preferred_sample_rate(cube
     return CUBEB_ERROR;
   }
 
   *rate = (uint32_t)fsamplerate;
 
   return CUBEB_OK;
 }
 
-
 static void
 audiounit_destroy(cubeb * ctx)
 {
   free(ctx);
 }
 
 static void audiounit_stream_destroy(cubeb_stream * stm);
 
@@ -299,17 +297,16 @@ audiounit_stream_init(cubeb * context, c
   cubeb_stream * stm;
   AURenderCallbackStruct input;
   unsigned int buffer_size, default_buffer_size;
   OSStatus r;
   UInt32 size;
   AudioDeviceID output_device_id;
   AudioValueRange latency_range;
 
-
   assert(context);
   *stream = NULL;
 
   memset(&ss, 0, sizeof(ss));
   ss.mFormatFlags = 0;
 
   switch (stream_params.format) {
   case CUBEB_SAMPLE_S16LE:
--- a/media/libcubeb/src/cubeb_opensl.c
+++ b/media/libcubeb/src/cubeb_opensl.c
@@ -162,17 +162,16 @@ opensl_init(cubeb ** context, char const
 #if defined(__ANDROID__)
       !ctx->SL_IID_ANDROIDCONFIGURATION ||
 #endif
       !ctx->SL_IID_PLAY) {
     opensl_destroy(ctx);
     return CUBEB_ERROR;
   }
 
-
   const SLEngineOption opt[] = {{SL_ENGINEOPTION_THREADSAFE, SL_BOOLEAN_TRUE}};
 
   SLresult res;
   res = f_slCreateEngine(&ctx->engObj, 1, opt, 0, NULL, NULL);
   if (res != SL_RESULT_SUCCESS) {
     opensl_destroy(ctx);
     return CUBEB_ERROR;
   }
--- a/media/libcubeb/src/cubeb_sndio.c
+++ b/media/libcubeb/src/cubeb_sndio.c
@@ -148,17 +148,16 @@ sndio_init(cubeb **context, char const *
 }
 
 static char const *
 sndio_get_backend_id(cubeb *context)
 {
   return "sndio";
 }
 
-
 static void
 sndio_destroy(cubeb *context)
 {
   DPR("sndio_destroy()\n");
   free(context);
 }
 
 static int
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -90,17 +90,16 @@ struct cubeb
   cubeb_ops const * ops;
   /* Library dynamically opened to increase the render
    * thread priority, and the two function pointers we need. */
   HMODULE mmcss_module;
   set_mm_thread_characteristics_function set_mm_thread_characteristics;
   revert_mm_thread_characteristics_function revert_mm_thread_characteristics;
 };
 
-
 struct cubeb_stream
 {
   cubeb * context;
   /* Mixer pameters. We need to convert the input
    * stream to this samplerate/channel layout, as WASAPI
    * does not resample nor upmix itself. */
   cubeb_stream_params mix_params;
   cubeb_stream_params stream_params;
@@ -727,17 +726,16 @@ wasapi_stream_init(cubeb * context, cube
   stm->refill_event = CreateEvent(NULL, 0, 0, NULL);
 
   if (!stm->shutdown_event) {
     LOG("Can't create the shutdown event, error: %d.", GetLastError());
     wasapi_stream_destroy(stm);
     return CUBEB_ERROR;
   }
 
-
   if (!stm->refill_event) {
     SafeRelease(stm->shutdown_event);
     LOG("Can't create the refill event, error: %d.", GetLastError());
     wasapi_stream_destroy(stm);
     return CUBEB_ERROR;
   }
 
   IMMDevice * device;
@@ -775,17 +773,16 @@ wasapi_stream_init(cubeb * context, cube
   stm->mix_params.format = CUBEB_SAMPLE_FLOAT32NE;
 
   stm->mix_params.rate = mix_format->nSamplesPerSec;
   stm->mix_params.channels = mix_format->nChannels;
 
   float resampling_rate = static_cast<float>(stm->stream_params.rate) /
                           stm->mix_params.rate;
 
-
   if (resampling_rate != 1.0) {
     /* If we are playing a mono stream, we only resample one channel,
      * and copy it over, so we are always resampling the number
      * of channels of the stream, not the number of channels
      * that WASAPI wants. */
     stm->resampler = speex_resampler_init(stm->stream_params.channels,
                                           stm->stream_params.rate,
                                           stm->mix_params.rate,
@@ -908,17 +905,17 @@ void wasapi_stream_destroy(cubeb_stream 
 }
 
 int wasapi_stream_start(cubeb_stream * stm)
 {
   HRESULT hr;
 
   assert(stm);
 
-  stm->thread = (HANDLE) _beginthreadex(NULL, 64 * 1024, wasapi_stream_render_loop, stm, 0, NULL);
+  stm->thread = (HANDLE) _beginthreadex(NULL, 64 * 1024, wasapi_stream_render_loop, stm, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
   if (stm->thread == NULL) {
     LOG("could not create WASAPI render thread.");
     return CUBEB_ERROR;
   }
 
   hr = stm->client->Start();
   if (FAILED(hr)) {
     LOG("could not start the stream.");
--- a/media/libcubeb/src/cubeb_winmm.c
+++ b/media/libcubeb/src/cubeb_winmm.c
@@ -260,17 +260,17 @@ winmm_init(cubeb ** context, char const 
   InitializeSListHead(ctx->work);
 
   ctx->event = CreateEvent(NULL, FALSE, FALSE, NULL);
   if (!ctx->event) {
     winmm_destroy(ctx);
     return CUBEB_ERROR;
   }
 
-  ctx->thread = (HANDLE) _beginthreadex(NULL, 64 * 1024, winmm_buffer_thread, ctx, 0, NULL);
+  ctx->thread = (HANDLE) _beginthreadex(NULL, 64 * 1024, winmm_buffer_thread, ctx, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
   if (!ctx->thread) {
     winmm_destroy(ctx);
     return CUBEB_ERROR;
   }
 
   SetThreadPriority(ctx->thread, THREAD_PRIORITY_TIME_CRITICAL);
 
   InitializeCriticalSection(&ctx->lock);