зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1318619 - Update libcubeb to 13f167c2.
This commit is contained in:
Родитель
c60e149356
Коммит
9905c5e828
|
@ -5,4 +5,4 @@ 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 b6315bb8863ed50a7f00ee4361e044c48e19bd34.
|
||||
The git commit ID used was 13f167c23954527d693508d11dd7706b2b774729.
|
||||
|
|
|
@ -158,6 +158,10 @@ private:
|
|||
HRESULT result;
|
||||
};
|
||||
|
||||
typedef HANDLE (WINAPI *set_mm_thread_characteristics_function)(
|
||||
const char * TaskName, LPDWORD TaskIndex);
|
||||
typedef BOOL (WINAPI *revert_mm_thread_characteristics_function)(HANDLE handle);
|
||||
|
||||
extern cubeb_ops const wasapi_ops;
|
||||
|
||||
int wasapi_stream_stop(cubeb_stream * stm);
|
||||
|
@ -171,6 +175,11 @@ static std::unique_ptr<wchar_t const []> utf8_to_wstr(char const * str);
|
|||
|
||||
struct cubeb {
|
||||
cubeb_ops const * ops = &wasapi_ops;
|
||||
/* Library dynamically opened to increase the render thread priority, and
|
||||
the two function pointers we need. */
|
||||
HMODULE mmcss_module = nullptr;
|
||||
set_mm_thread_characteristics_function set_mm_thread_characteristics = nullptr;
|
||||
revert_mm_thread_characteristics_function revert_mm_thread_characteristics = nullptr;
|
||||
};
|
||||
|
||||
class wasapi_endpoint_notification_client;
|
||||
|
@ -844,7 +853,8 @@ wasapi_stream_render_loop(LPVOID stream)
|
|||
|
||||
/* We could consider using "Pro Audio" here for WebAudio and
|
||||
maybe WebRTC. */
|
||||
mmcss_handle = AvSetMmThreadCharacteristicsA("Audio", &mmcss_task_index);
|
||||
mmcss_handle =
|
||||
stm->context->set_mm_thread_characteristics("Audio", &mmcss_task_index);
|
||||
if (!mmcss_handle) {
|
||||
/* This is not fatal, but we might glitch under heavy load. */
|
||||
LOG("Unable to use mmcss to bump the render thread priority: %lx", GetLastError());
|
||||
|
@ -947,7 +957,7 @@ wasapi_stream_render_loop(LPVOID stream)
|
|||
}
|
||||
|
||||
if (mmcss_handle) {
|
||||
AvRevertMmThreadCharacteristics(mmcss_handle);
|
||||
stm->context->revert_mm_thread_characteristics(mmcss_handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -955,6 +965,16 @@ wasapi_stream_render_loop(LPVOID stream)
|
|||
|
||||
void wasapi_destroy(cubeb * context);
|
||||
|
||||
HANDLE WINAPI set_mm_thread_characteristics_noop(const char *, LPDWORD mmcss_task_index)
|
||||
{
|
||||
return (HANDLE)1;
|
||||
}
|
||||
|
||||
BOOL WINAPI revert_mm_thread_characteristics_noop(HANDLE mmcss_handle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
HRESULT register_notification_client(cubeb_stream * stm)
|
||||
{
|
||||
HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
|
||||
|
@ -1132,6 +1152,27 @@ int wasapi_init(cubeb ** context, char const * context_name)
|
|||
|
||||
ctx->ops = &wasapi_ops;
|
||||
|
||||
ctx->mmcss_module = LoadLibraryA("Avrt.dll");
|
||||
|
||||
if (ctx->mmcss_module) {
|
||||
ctx->set_mm_thread_characteristics =
|
||||
(set_mm_thread_characteristics_function) GetProcAddress(
|
||||
ctx->mmcss_module, "AvSetMmThreadCharacteristicsA");
|
||||
ctx->revert_mm_thread_characteristics =
|
||||
(revert_mm_thread_characteristics_function) GetProcAddress(
|
||||
ctx->mmcss_module, "AvRevertMmThreadCharacteristics");
|
||||
if (!(ctx->set_mm_thread_characteristics && ctx->revert_mm_thread_characteristics)) {
|
||||
LOG("Could not load AvSetMmThreadCharacteristics or AvRevertMmThreadCharacteristics: %x", GetLastError());
|
||||
FreeLibrary(ctx->mmcss_module);
|
||||
}
|
||||
} else {
|
||||
// This is not a fatal error, but we might end up glitching when
|
||||
// the system is under high load.
|
||||
LOG("Could not load Avrt.dll");
|
||||
ctx->set_mm_thread_characteristics = &set_mm_thread_characteristics_noop;
|
||||
ctx->revert_mm_thread_characteristics = &revert_mm_thread_characteristics_noop;
|
||||
}
|
||||
|
||||
*context = ctx;
|
||||
|
||||
return CUBEB_OK;
|
||||
|
@ -1183,6 +1224,9 @@ bool stop_and_join_render_thread(cubeb_stream * stm)
|
|||
|
||||
void wasapi_destroy(cubeb * context)
|
||||
{
|
||||
if (context->mmcss_module) {
|
||||
FreeLibrary(context->mmcss_module);
|
||||
}
|
||||
delete context;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче