Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTK progress optimizations and properly closing gst.pipeline #41

Merged
merged 4 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gtk optimizations
  • Loading branch information
sezanzeb committed Sep 3, 2020
commit 49c2c94b52659511ae0d72c76195a0ee59f8be97
22 changes: 13 additions & 9 deletions soundconverter/gstreamer/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,19 @@ def _query_position(self):
def get_progress(self):
"""Fraction of how much of the task is completed."""
duration = self.sound_file.duration
if not self.done:
position = self._query_position()
if duration is None:
return 0
progress = position / duration
progress = min(max(progress, 0.0), 1.0)
return progress, duration

return 1, duration

# don't waste time querying gstreamer if possible
if self.done:
return 1, duration
if not self.pipeline:
return 0, duration

position = self._query_position()
if duration is None:
return 0
progress = position / duration
progress = min(max(progress, 0.0), 1.0)
return progress, duration

def cancel(self):
"""Cancel execution of the task."""
Expand Down
4 changes: 3 additions & 1 deletion soundconverter/interface/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ def format_cell(self, sound_file):
def set_row_progress(self, number, progress):
"""Update the progress bar of a single row/file."""
self.progress_column.set_visible(True)
if self.model[number][2] == 1.0:
if abs(self.model[number][2] - progress * 100) < 1:
# only do the expensive gtk update when the delta progress
# is larger than 1%
return

self.model[number][2] = progress * 100.0
Expand Down