Bug 1236977 - Default initialize IMMDevice temporary to avoid potential garbage CloseHandle on error. r=padenot
authorMatthew Gregan <kinetik@flim.org>
Thu, 07 Jan 2016 17:53:55 +1300
changeset 278921 dd7c4f457433d5a9f65a4a6007dbfe389081c248
parent 278920 f2fefee9f84e2bf7603ca39dd12f34a8b25d7106
child 278922 5fe7d4e2fd2c30be2a60d201e9325f25fb59aeb8
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1236977
milestone46.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 1236977 - Default initialize IMMDevice temporary to avoid potential garbage CloseHandle on error. r=padenot
media/libcubeb/README_MOZILLA
media/libcubeb/src/cubeb_alsa.c
media/libcubeb/src/cubeb_wasapi.cpp
--- 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 eb30ecdf0c6b02e463a91ac93887ac08e31b360a.
+The git commit ID used was 23a17cb4f9ed2de78a0df5ecdfefbbe47dc83c35.
--- a/media/libcubeb/src/cubeb_alsa.c
+++ b/media/libcubeb/src/cubeb_alsa.c
@@ -80,17 +80,16 @@ struct cubeb_stream {
   pthread_mutex_t mutex;
   snd_pcm_t * pcm;
   cubeb_data_callback data_callback;
   cubeb_state_callback state_callback;
   void * user_ptr;
   snd_pcm_uframes_t write_position;
   snd_pcm_uframes_t last_position;
   snd_pcm_uframes_t buffer_size;
-  snd_pcm_uframes_t period_size;
   cubeb_stream_params params;
 
   /* Every member after this comment is protected by the owning context's
      mutex rather than the stream's mutex, or is only used on the context's
      run thread. */
   pthread_cond_t cond; /* Signaled when the stream's state is changed. */
 
   enum stream_state state;
@@ -784,16 +783,17 @@ static int
 alsa_stream_init(cubeb * ctx, cubeb_stream ** stream, char const * stream_name,
                  cubeb_stream_params stream_params, unsigned int latency,
                  cubeb_data_callback data_callback, cubeb_state_callback state_callback,
                  void * user_ptr)
 {
   cubeb_stream * stm;
   int r;
   snd_pcm_format_t format;
+  snd_pcm_uframes_t period_size;
 
   assert(ctx && stream);
 
   *stream = NULL;
 
   switch (stream_params.format) {
   case CUBEB_SAMPLE_S16LE:
     format = SND_PCM_FORMAT_S16_LE;
@@ -852,17 +852,17 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
   r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
                          stm->params.channels, stm->params.rate, 1,
                          latency * 1000);
   if (r < 0) {
     alsa_stream_destroy(stm);
     return CUBEB_ERROR_INVALID_FORMAT;
   }
 
-  r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &stm->period_size);
+  r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size);
   assert(r == 0);
 
   stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm);
   assert(stm->nfds > 0);
 
   stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd));
   assert(stm->saved_fds);
   r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds);
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -1515,17 +1515,17 @@ wasapi_is_default_device(EDataFlow flow,
 
   return ret;
 }
 
 static cubeb_device_info *
 wasapi_create_device(IMMDeviceEnumerator * enumerator, IMMDevice * dev)
 {
   IMMEndpoint * endpoint = NULL;
-  IMMDevice * devnode;
+  IMMDevice * devnode = NULL;
   IAudioClient * client = NULL;
   cubeb_device_info * ret = NULL;
   EDataFlow flow;
   LPWSTR device_id = NULL;
   DWORD state = DEVICE_STATE_NOTPRESENT;
   IPropertyStore * propstore = NULL;
   PROPVARIANT propvar;
   REFERENCE_TIME def_period, min_period;