Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return null without setting an error #1

Open
Starxyz opened this issue Jun 4, 2019 · 5 comments
Open

return null without setting an error #1

Starxyz opened this issue Jun 4, 2019 · 5 comments

Comments

@Starxyz
Copy link

Starxyz commented Jun 4, 2019

image
hello~
I got this error when i use window 7 x64 , but everything is OK in win10.
How can I fix it?

@Barmaley13
Copy link

That needs to be fixed in C but you can wrap your code into
try - except guards for now in Python like so

try:
    device_list = device.getDeviceList()
except:
    pass

@alex-ong
Copy link

I managed to get a fix:

static PyObject *
getDeviceList(PyObject *self, PyObject *args)
{
	PyObject* pyList = NULL; 
	
	HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
	
	//backup; run it without multithreading.
	if (!SUCCEEDED(hr))
	{				
		hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
	}
	
	if (SUCCEEDED(hr))
	{
		IEnumMoniker *pEnum;

		hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);
		if (SUCCEEDED(hr))
		{
			pyList = DisplayDeviceInformation(pEnum);
			pEnum->Release();
		}
		CoUninitialize();
	} else {
		PyErr_SetString(PyExc_TypeError, "Could not call CoInitializeEx");		
	}

    return pyList;
}

SmartAudioTools added a commit to SmartAudioTools/python-capture-device-list that referenced this issue May 8, 2022
fix with alex-ong solution (yushulx#1 (comment))
@Avasam
Copy link

Avasam commented Jun 21, 2023

Related, possibly duplicate: #5

@suhren
Copy link

suhren commented Jul 23, 2023

In case anyone stumbles onto this, I am still getting this error in windows-capture-device-list==1.1.0 on Windows 11.

@emoto-yasushi
Copy link

I am using Windows 11. Just a few code changes and this error appears. I don't know what the cause is.

In my environment, the following code gives me an error.

from distutils.dir_util import copy_tree

import device
device_list = device.getDeviceList()
print(device_list)

The following code does not produce an error.

import device
device_list = device.getDeviceList()
print(device_list)

However, it seems that not only "distutils.dir_util" is affected, but also other libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants