Skip to content

Commit

Permalink
allow us to remove multiple items from the encode queue in one go: do…
Browse files Browse the repository at this point in the history
…n't wait to clear cancelled ones and free their memory

git-svn-id: https://xpra.org/svn/Xpra/trunk@14306 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 28, 2016
1 parent 2f80c2b commit b67237b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,35 +804,40 @@ def encode_from_queue(self):
av_delay = 0 #we must free some space!
now = time.time()
still_due = []
pop = None
remove = []
index = 0
item = None
sequence = None
done_packet = False
try:
for index,item in enumerate(eq):
#item = (w, h, damage_time, now, image, coding, sequence, options, flush)
sequence = item[6]
if self.is_cancelled(sequence):
self.free_image_wrapper(item[4])
remove.append(index)
continue
ts = item[3]
due = ts + av_delay
if due<now and pop is None:
if due<=now and not done_packet:
#found an item which is due
pop = index
remove.append(index)
avsynclog("encode_from_queue: processing item %s/%s (overdue by %ims)", index+1, len(self.encode_queue), int(1000*(now-due)))
self.make_data_packet_cb(*item)
done_packet = True
else:
#we only process only one item per call
#we only process only one item per call (see "done_packet")
#and just keep track of extra ones:
still_due.append(due)
except Exception:
if not self.is_cancelled(sequence):
avsynclog.error("error processing encode queue at index %i", index)
avsynclog.error("item=%s", item, exc_info=True)
if pop is not None:
eq.pop(pop)
return
#remove the items we've dealt with:
#(in reverse order since we pop them by increasing index)
if remove:
for x in reversed(remove):
eq.pop(x)
#README: encode_from_queue is scheduled to run every time we add an item
#to the encode_queue, but since the av_delay can change it is possible
#for us to not pop() any items from the list sometimes, and therefore we must ensure
Expand Down

0 comments on commit b67237b

Please sign in to comment.