Bug 1131788 - cubeb: Unable to use InterlockedAdd64 on MSVC2010 (and mingw). r=padenot, a=sledru
authorMatthew Gregan <kinetik@flim.org>
Tue, 10 Feb 2015 17:45:00 +1300
changeset 243767 57f79302248f
parent 243766 95d83f3422fc
child 243768 101d05cb5635
child 243770 694d627b4786
push id4468
push userryanvm@gmail.com
push date2015-02-12 16:23 +0000
treeherdermozilla-beta@57f79302248f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, sledru
bugs1131788
milestone36.0
Bug 1131788 - cubeb: Unable to use InterlockedAdd64 on MSVC2010 (and mingw). r=padenot, a=sledru
media/libcubeb/src/cubeb_wasapi.cpp
--- a/media/libcubeb/src/cubeb_wasapi.cpp
+++ b/media/libcubeb/src/cubeb_wasapi.cpp
@@ -372,16 +372,26 @@ private:
   /* refcount for this instance, necessary to implement MSCOM semantics. */
   LONG ref_count;
   /* Pointer to the stream. It is guaranteed that this pointer is
    * always valid. */
   cubeb_stream * stm;
 };
 
 namespace {
+void clock_add(cubeb_stream * stm, LONG64 value)
+{
+  InterlockedExchangeAdd64(&stm->clock, value);
+}
+
+LONG64 clock_get(cubeb_stream * stm)
+{
+  return InterlockedExchangeAdd64(&stm->clock, 0);
+}
+
 bool should_upmix(cubeb_stream * stream)
 {
   return stream->mix_params.channels > stream->stream_params.channels;
 }
 
 bool should_downmix(cubeb_stream * stream)
 {
   return stream->mix_params.channels < stream->stream_params.channels;
@@ -463,17 +473,17 @@ refill(cubeb_stream * stm, float * data,
   if (should_upmix(stm) || should_downmix(stm)) {
     dest = stm->mix_buffer;
   } else {
     dest = data;
   }
 
   long out_frames = cubeb_resampler_fill(stm->resampler, dest, frames_needed);
 
-  stm->clock = InterlockedAdd64(&stm->clock, frames_needed * stream_to_mix_samplerate_ratio(stm));
+  clock_add(stm, frames_needed * stream_to_mix_samplerate_ratio(stm));
 
   /* XXX: Handle this error. */
   if (out_frames < 0) {
     assert(false);
   }
 
   /* Go in draining mode if we got fewer frames than requested. */
   if (out_frames < frames_needed) {
@@ -1215,17 +1225,17 @@ int wasapi_stream_stop(cubeb_stream * st
 
   return CUBEB_OK;
 }
 
 int wasapi_stream_get_position(cubeb_stream * stm, uint64_t * position)
 {
   assert(stm && position);
 
-  *position = InterlockedAdd64(&stm->clock, 0);
+  *position = clock_get(stm);
 
   return CUBEB_OK;
 }
 
 int wasapi_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
 {
   assert(stm && latency);