def _cdata_io(self, action, data, ctype, frames):
        """Call one of libsndfile's read/write functions."""
        if ctype not in _ffi_types.values():
            raise ValueError("Unsupported data type: {0!r}".format(ctype))
        self._check_if_closed()
        if self.seekable():
            curr = self.tell()
        func = getattr(_snd, 'sf_' + action + 'f_' + ctype)
        frames = func(self._file, data, frames)
        _error_check(self._errorcode)
        if self.seekable():
            self.seek(curr + frames, SEEK_SET)  # Update read & write position
        return frames
dataset/ETHPy150Open bastibe/PySoundFile/soundfile.py/SoundFile._cdata_io/original