Skip to content

Ringbuffer class - #3

Closed
amstan wants to merge 1 commit into
spatialaudio:masterfrom
amstan:ringbuffer
Closed

amstan wants to merge 1 commit into
spatialaudio:masterfrom
amstan:ringbuffer

Conversation

@amstan

@amstan amstan commented Jan 17, 2015

Copy link
Copy Markdown
Contributor

Old discussion: amstan@9002ac9

There's still some more stuff to do (from_buffer and documentation). But I followed some of the comments.

Comment thread jack.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an empty line here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mgeier

mgeier commented Mar 3, 2015

Copy link
Copy Markdown
Member

Good news everyone!
CFFI 0.9 was just released: https://pypi.python.org/pypi/cffi/0.9.0
Now ffi.from_buffer() should be officially available.

@amstan

amstan commented Mar 8, 2015

Copy link
Copy Markdown
Contributor Author

The new api is nice, but it still doesn't let me do things quickly without pain:

>>> jack._ffi.from_buffer(b"123")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/cffi/api.py", line 281, in from_buffer
    return self._backend.from_buffer(self.BCharA, python_buffer)
TypeError: from_buffer() cannot return the address of the raw string within a bytes or unicode or bytearray object

One needs this workaround:

>>> jack._ffi.from_buffer(array.array("B",b"123"))
<cdata 'char[]' buffer len 3 from 'array.array' object>

It's not a big deal, I'll use it anyway.

@amstan
amstan force-pushed the ringbuffer branch 2 times, most recently from 6ad08d8 to 25a7d24 Compare March 8, 2015 04:33
mgeier referenced this pull request in amstan/jackclient-python Mar 9, 2015
@mgeier

mgeier commented Mar 9, 2015

Copy link
Copy Markdown
Member

I think that from_buffer() cannot be used with bytes isn't a problem.

bytes should be directly passed to the function, as well as (other) iterables of int.

I think it's best to wrap from_buffer() into a try block, then everything works.

See my comment at https://bitbucket.org/cffi/cffi/issue/47/creating-a-cdata-from-a-buffer#comment-15153192 and my implementation of write_midi_event().

Your work-around shouldn't be necessary at all.

@mgeier

mgeier commented Mar 9, 2015

Copy link
Copy Markdown
Member

In addition, you should change the cdef() to const unsigned char* src and change _ffi.sizeof() to len(), see amstan@9002ac9#commitcomment-9207146.

@mgeier

mgeier commented Mar 9, 2015

Copy link
Copy Markdown
Member

Thanks a lot for the updated PR, that's great!

I made a few comments, it would be nice if you could have a look at them.
Once those are resolved, I think we're ready to merge!

@amstan

amstan commented May 11, 2015

Copy link
Copy Markdown
Contributor Author

I think it's best to wrap from_buffer() into a try block, then everything works.
In addition, you should change the cdef() to const unsigned char* src and change _ffi.sizeof() to len(), see amstan/jackclient-python@9002ac9#commitcomment-9207146.

Done

Will send a new version shortly.

@amstan

amstan commented May 11, 2015

Copy link
Copy Markdown
Contributor Author

Uploaded.

Sorry for taking so long by the way.

mgeier pushed a commit that referenced this pull request May 20, 2015
@mgeier

mgeier commented May 20, 2015

Copy link
Copy Markdown
Member

I rebased the commit (7def7df) and merged it into master.

Thanks a lot @amstan!

@mgeier mgeier closed this May 20, 2015
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

Successfully merging this pull request may close these issues.

3 participants