Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion av/container/core.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ctypedef struct timeout_info:


cdef class Container:

cdef readonly bint writeable
cdef lib.AVFormatContext *ptr

Expand Down
2 changes: 0 additions & 2 deletions av/container/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ class Container:
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None: ...
def set_timeout(self, timeout: Real | None) -> None: ...
def start_timeout(self) -> None: ...
def chapters(self) -> list[Chapter]: ...
def set_chapters(self, chapters: list[Chapter]) -> None: ...

Expand Down
12 changes: 3 additions & 9 deletions av/container/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ from av.logging import Capture as LogCapture

cdef object _cinit_sentinel = object()


# We want to use the monotonic clock if it is available.
cdef object clock = getattr(time, "monotonic", time.time)

cdef int interrupt_cb (void *p) noexcept nogil:
cdef int interrupt_cb(void *p) noexcept nogil:
cdef timeout_info info = dereference(<timeout_info*> p)
if info.timeout < 0: # timeout < 0 means no timeout
return 0

cdef double current_time
with gil:
current_time = clock()

# Check if the clock has been changed.
current_time = time.monotonic()
if current_time < info.start_time:
# Raise this when we get back to Python.
stash_exception((RuntimeError, RuntimeError("Clock has been changed to before timeout start"), None))
Expand Down Expand Up @@ -330,7 +324,7 @@ cdef class Container:
self.interrupt_callback_info.timeout = timeout

cdef start_timeout(self):
self.interrupt_callback_info.start_time = clock()
self.interrupt_callback_info.start_time = time.monotonic()

cdef _assert_open(self):
if self.ptr == NULL:
Expand Down
Loading