forked from auracaster/pyalsaaudio
fix deprecation warning about PyUnicode_AsUnicode()
converting to ascii for the purpose of comparison is inefficient.
This commit is contained in:
@@ -179,11 +179,18 @@ get_pcmtype(PyObject *obj)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (PyUnicode_Check(obj)) {
|
if (PyUnicode_Check(obj)) {
|
||||||
|
#if PY_MAJOR_VERSION > 2
|
||||||
|
if (PyUnicode_CompareWithASCIIString(obj, "playback") == 0)
|
||||||
|
return SND_PCM_STREAM_PLAYBACK;
|
||||||
|
else if (PyUnicode_CompareWithASCIIString(obj, "capture") == 0)
|
||||||
|
return SND_PCM_STREAM_CAPTURE;
|
||||||
|
#else
|
||||||
const char *dirstr = PyUnicode_AS_DATA(obj);
|
const char *dirstr = PyUnicode_AS_DATA(obj);
|
||||||
if (strcasecmp(dirstr, "playback")==0)
|
if (strcasecmp(dirstr, "playback")==0)
|
||||||
return SND_PCM_STREAM_PLAYBACK;
|
return SND_PCM_STREAM_PLAYBACK;
|
||||||
else if (strcasecmp(dirstr, "capture")==0)
|
else if (strcasecmp(dirstr, "capture")==0)
|
||||||
return SND_PCM_STREAM_CAPTURE;
|
return SND_PCM_STREAM_CAPTURE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PyErr_SetString(ALSAAudioError, "PCM type must be PCM_PLAYBACK (0) "
|
PyErr_SetString(ALSAAudioError, "PCM type must be PCM_PLAYBACK (0) "
|
||||||
|
|||||||
Reference in New Issue
Block a user