diff options
author | Matthew Gregan <[email protected]> | 2012-11-13 15:58:43 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2012-11-13 15:58:43 +1300 |
commit | 8da7b2a4410f8d3ba9d2922be8760a7b24e957d3 (patch) | |
tree | ae244743a89eede47ecce3e86b8ea2fe18238754 | |
parent | 1bc23c6e2e4920f38f7aa56ec56ef5e379e18cf7 (diff) | |
download | cubeb-8da7b2a4410f8d3ba9d2922be8760a7b24e957d3.tar.gz cubeb-8da7b2a4410f8d3ba9d2922be8760a7b24e957d3.zip |
winmm: let high latency mode use different minimums depending on the environment.
-rw-r--r-- | src/cubeb_winmm.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c index 49c6127..245359c 100644 --- a/src/cubeb_winmm.c +++ b/src/cubeb_winmm.c @@ -33,7 +33,7 @@ struct cubeb { PSLIST_HEADER work; CRITICAL_SECTION lock; unsigned int active_streams; - int high_latency; + int minimum_latency; }; struct cubeb_stream { @@ -192,12 +192,12 @@ cubeb_buffer_callback(HWAVEOUT waveout, UINT msg, DWORD_PTR user_ptr, DWORD_PTR } static int -high_latency_winmm(void) +calculate_minimum_latency(void) { OSVERSIONINFOEX osvi; DWORDLONG mask; - /* Vista's WinMM implementation underruns when less than 150ms of audio is buffered. */ + /* Vista's WinMM implementation underruns when less than 200ms of audio is buffered. */ memset(&osvi, 0, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvi.dwMajorVersion = 6; @@ -208,12 +208,12 @@ high_latency_winmm(void) VER_SET_CONDITION(mask, VER_MINORVERSION, VER_EQUAL); if (VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, mask) != 0) { - return 1; + return 200; } /* Running under Terminal Services results in underruns with low latency. */ if (GetSystemMetrics(SM_REMOTESESSION) == TRUE) { - return 1; + return 500; } return 0; @@ -251,7 +251,7 @@ cubeb_init(cubeb ** context, char const * context_name) InitializeCriticalSection(&ctx->lock); ctx->active_streams = 0; - ctx->high_latency = high_latency_winmm(); + ctx->minimum_latency = calculate_minimum_latency(); *context = ctx; @@ -373,8 +373,8 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n stm->state_callback = state_callback; stm->user_ptr = user_ptr; - if (context->high_latency) { - latency = latency < 200 ? 200 : latency; + if (latency < context->minimum_latency) { + latency = context->minimum_latency; } bufsz = (size_t) (stm->params.rate / 1000.0 * latency * bytes_per_frame(stm->params) / NBUFS); |