From 670653d955d45c2491d51ee873bf27f44341eaa3 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Tue, 10 Feb 2015 17:45:00 +1300 Subject: [PATCH] Bug 1131788 - cubeb: Unable to use InterlockedAdd64 on MSVC2010 (and mingw). r=padenot --- media/libcubeb/src/cubeb_wasapi.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp index 4e222f7dae0d..d769ab1570ed 100644 --- a/media/libcubeb/src/cubeb_wasapi.cpp +++ b/media/libcubeb/src/cubeb_wasapi.cpp @@ -378,6 +378,16 @@ private: }; 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; @@ -469,7 +479,7 @@ refill(cubeb_stream * stm, float * data, long frames_needed) 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) { @@ -1221,7 +1231,7 @@ 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; }