from cffi import FFI ffibuilder = FFI() ffibuilder.set_source("selfsample", r""" #include #include #include #include snd_pcm_t *out_handle; snd_pcm_t *in_handle; snd_pcm_stream_t out_stream = SND_PCM_STREAM_PLAYBACK; snd_pcm_stream_t in_stream = SND_PCM_STREAM_CAPTURE; snd_pcm_hw_params_t *out_params; snd_pcm_hw_params_t *in_params; char *pcm_out_name; char *pcm_in_name; #define PERIOD_SIZE 8192 #define SAMPLE_RATE 48000 snd_pcm_t *open_output_stream(); """, libraries=[]) ffibuilder.cdef(r""" typedef int... snd_pcm_uframes_t; struct snd_pcm_t * open_output_stream() { int rate = 48000; /* Sample rate */ int exact_rate; /* Sample rate returned by */ /* snd_pcm_hw_params_set_rate_near */ int dir; /* exact_rate == rate --> dir = 0 */ /* exact_rate < rate --> dir = -1 */ /* exact_rate > rate --> dir = 1 */ int periods = 2; /* Number of periods */ snd_pcm_uframes_t periodsize = PERIOD_SIZE; /* Periodsize (bytes) */ snd_pcm_t *handle; if (snd_pcm_open(&handle, pcm_out_name, out_stream, SND_PCM_NONBLOCK) < 0) { fprintf(stderr, "Error opening PCM device %s\n", pcm_out_name); return(NULL); } if (snd_pcm_set_params(handle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 1, 48000, 1, 50000) < 0) { /* 0.5sec */ return(NULL); } return handle; } """) Traceback (most recent call last): File "selfsample_build.py", line 86, in """) File "/usr/lib64/python3.6/site-packages/cffi/api.py", line 106, in cdef self._cdef(csource, override=override, packed=packed) File "/usr/lib64/python3.6/site-packages/cffi/api.py", line 120, in _cdef self._parser.parse(csource, override=override, **options) File "/usr/lib64/python3.6/site-packages/cffi/cparser.py", line 308, in parse self._internal_parse(csource) File "/usr/lib64/python3.6/site-packages/cffi/cparser.py", line 351, in _internal_parse raise CDefError("unrecognized construct", decl) cffi.error.CDefError: line 5: unrecognized construct