Repository navigation
Add transport_query() method on Client - #10
Vampouille wants to merge 7 commits into
Conversation
|
Thanks a lot for this PR! Can you please:
|
There was a problem hiding this comment.
It's a good idea to allocate the memory during initialization, but the attribute shouldn't be public, you should probably call it self._position or similar.
It would probably be in better company a few lines further down, e.g. after self._keepalive?
There was a problem hiding this comment.
I change attribute name to '_position' and move initialization at the
end of constructor.
Le 13/04/2015 20:16, Matthias Geier a écrit :
In jack.py
#10 (comment):@@ -276,6 +355,7 @@ def init(self, name, use_exact_name=False, no_start_server=False,
""" status = _ffi.new("jack_status_t*")
self.position = _ffi.new("jack_position_t*")It's a good idea to allocate the memory during initialization, but the
attribute shouldn't be public, you should probably call it
|self._position| or similar.It would probably be in better company a few lines further down, e.g.
after |self._keepalive|?—
Reply to this email directly or view it on GitHub
https://github.com/spatialaudio/jackclient-python/pull/10/files#r28263559.
|
What about returning something more Pythonic by default (e.g. a The former could also do the consistency check |
|
Le 13/04/2015 20:22, Matthias Geier a écrit :
About dealing with CFFI struct for realtime usage : My first idea was to hide CFFI struct with a class suitable for realtime class Position(): constructor only store reference to the CFFI struct so it should be ok As you suggest, I will add a method to return a complete dict with all
Should I send you another pull request or can you check my fork ? I Best, |
|
First of all, Python isn't really reliable for realtime stuff. I made these Python bindings mainly to be able to do the non-realtime stuff (connecting ports and so on). If you want a more reliable system, you should use C or C++. That said, I still want to try to make the library as useful, reliable and efficient as is possible.
class Position():
def __init__(self,cffi_data):
self._data = cffi_data
def get_bar_beat_tick(self):
return (self._data.bar, self._data.beat, self._data.tick)
def get_frame(self):
return self._data.frame
...Getter methods are un-Pythonic, you would use properties here: @property
def bar_beat_tick(self):
return self._data.bar, self._data.beat, self._data.tick
It doesn't really make a difference if you create a class instance or a So no, a class isn't better than a OTOH, Python uses some kind of memory pool for small objects, but I don't really know any details and I don't know if we should count on this.
I think this would be good, since that's what those strange fields are there for. But if you make two different options - one for efficiency and one for Pythonicity - you should probably do this only on the latter.
You can make another pull request if you want, but normally you would just add more commits to your branch "add_transport_query". |
|
BTW, you'll probably have to put some of the structs into a separate |
|
I think the What about creating a Or probably it's better to make a much simpler function (similar to what you had before) right now that only returns the CFFI struct (and the integer representing the transport state) and later, in a separate PR we try to make this more Pythonic? |
|
I just make a new commit without Transport class. Le 18/04/2015 20:10, Matthias Geier a écrit :
|
There was a problem hiding this comment.
Please add the declarations in the same order as in the original header files.
This avoids repeated declarations, like for example jack_nframes_t.
|
What about #10 (comment)? I think we should use the |
There was a problem hiding this comment.
I would prefer a single space around the equals sign and a comma at the end of the last line.
|
I add another cdef() with packed argument. |
|
I squashed your commits into f8a21a8 and a pushed a few follow-up commits. Thanks a lot for this PR! |
Hello,
I added transport_query() method in order to get current transport position and BPM.
I added several C types from /usr/include/jack/types.h
package : libjack-jackd2-dev 1.9.9.5+201306 (Linux Mint 17.1 64bit)
I also added a new attribute to Client class : 'position' to avoid malloc() in transport_query() method