Skip to content

java.lang.Error: MMF: Create device enumerator failed CoInitialize has not been called #43

Closed
@nanguantong

Description

@nanguantong

And then when use maven project, it's ok to run this jar, but error happened while running
List<AudioDevice> captureDevices = MediaDevices.getAudioCaptureDevices();

the native code not called when WindowsAudioDeviceManager inited as following

ComInitializer::ComInitializer() : initialized(false)
	{
		HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

		if (hr != RPC_E_CHANGED_MODE) {
			THROW_IF_FAILED(hr, "Initialize COM failed");

			initialized = true;
		}
	}

in WebRTCContext::initialize
void WebRTCContext::initDeviceManagers()
{
#ifdef _WIN32
audioDevManager = std::make_uniqueavdev::WindowsAudioDeviceManager();
videoDevManager = std::make_uniqueavdev::WindowsVideoDeviceManager();
#endif
......
}

in WindowsAudioDeviceManager

WindowsAudioDeviceManager::WindowsAudioDeviceManager() :
			deviceEnumerator()
		{
                       //////////////////////////////////////// not call ComInitializer /////////////////////////////////////////////
			HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&deviceEnumerator);
			THROW_IF_FAILED(hr, "MMF: Create device enumerator failed");

			enumerateDevices(eAll);

			deviceEnumerator->RegisterEndpointNotificationCallback(this);
		}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions