jdxi_editor.utils.macos_activity ================================ .. py:module:: jdxi_editor.utils.macos_activity .. autoapi-nested-parse:: macOS: tell the system that the app is doing latency-critical work. macOS throttles the timers of an app it thinks is idle (App Nap, timer coalescing): a timed wait ends late, by tens of milliseconds — notes of a MIDI file or a pattern off their beat, a reading's timeouts reached early. While playing, the editor holds an NSProcessInfo activity "user initiated, latency critical", as audio and MIDI applications do; Windows has timeBeginPeriod for the same purpose. Elsewhere, and if anything goes wrong, nothing happens. Done through the Objective-C runtime with ctypes (no PyObjC needed). objc_msgSend is called with the exact prototype of each method: on Apple silicon it must not be called as a variadic function. Attributes ---------- .. autoapisummary:: jdxi_editor.utils.macos_activity.USER_INITIATED jdxi_editor.utils.macos_activity.LATENCY_CRITICAL jdxi_editor.utils.macos_activity.OPTIONS jdxi_editor.utils.macos_activity._runtime Functions --------- .. autoapisummary:: jdxi_editor.utils.macos_activity._objc jdxi_editor.utils.macos_activity._send jdxi_editor.utils.macos_activity._sel jdxi_editor.utils.macos_activity.begin jdxi_editor.utils.macos_activity.end Module Contents --------------- .. py:data:: USER_INITIATED :value: 16777215 .. py:data:: LATENCY_CRITICAL :value: 1095216660480 .. py:data:: OPTIONS :value: 1095233437695 .. py:data:: _runtime :value: None .. py:function:: _objc() .. py:function:: _send(restype, *argtypes) objc_msgSend with this prototype: (receiver, selector, *argtypes) -> restype. .. py:function:: _sel(name: str) .. py:function:: begin(reason: str) -> Optional[int] Start the activity; its token (to give to end()), or None if not on macOS or not possible. .. py:function:: end(token: Optional[int]) -> None End the activity begun with begin().