Ticket #849: sound-show-queue-graph.patch
File sound-show-queue-graph.patch, 7.2 KB (added by , 6 years ago) |
---|
-
xpra/sound/sink.py
189 189 info = SoundPipeline.get_info(self) 190 190 if QUEUE_TIME>0: 191 191 clt = self.queue.get_property("current-level-time") 192 qmax = self.queue.get_property("max-size-time") 193 qmin = self.queue.get_property("min-threshold-time") 192 194 updict(info, "queue", { 193 " time" : QUEUE_TIME//MS_TO_NS,194 "m in_time" : QUEUE_MIN_TIME//MS_TO_NS,195 " used_pct" : min(QUEUE_TIME, clt)*100//QUEUE_TIME,196 " used" : clt//MS_TO_NS,195 "min" : qmin//MS_TO_NS, 196 "max" : qmax//MS_TO_NS, 197 "cur" : clt//MS_TO_NS, 198 "pct" : min(QUEUE_TIME, clt)*100//qmax, 197 199 "overruns" : self.overruns, 198 200 "state" : self.queue_state}) 199 201 return info -
xpra/client/gtk_base/session_info.py
14 14 import datetime 15 15 16 16 from xpra.os_util import os_info, bytestostr 17 from xpra.util import prettify_plug_name 17 from xpra.util import prettify_plug_name, typedict 18 18 from xpra.gtk_common.graph import make_graph_pixmap 19 19 from collections import deque 20 20 from xpra.simple_stats import values_to_scaled_values, values_to_diff_scaled_values, to_std_unit, std_unit_dec … … 373 373 if SHOW_PIXEL_STATS: 374 374 bandwidth_label += ",\nand number of pixels rendered" 375 375 self.bandwidth_graph = self.add_graph_button(bandwidth_label, self.save_graphs) 376 self.latency_graph = self.add_graph_button(None, self.save_graphs) 377 self.sound_queue_graph = self.add_graph_button(None, self.save_graphs) 376 378 self.connect("realize", self.populate_graphs) 377 self.latency_graph = self.add_graph_button(None, self.save_graphs)378 379 self.pixel_in_data = deque(maxlen=N_SAMPLES+4) 379 380 self.net_in_bytecount = deque(maxlen=N_SAMPLES+4) 380 381 self.net_out_bytecount = deque(maxlen=N_SAMPLES+4) 381 382 self.sound_in_bytecount = deque(maxlen=N_SAMPLES+4) 382 383 self.sound_out_bytecount = deque(maxlen=N_SAMPLES+4) 384 self.sound_out_queue_min = deque(maxlen=N_SAMPLES+4) 385 self.sound_out_queue_max = deque(maxlen=N_SAMPLES+4) 386 self.sound_out_queue_cur = deque(maxlen=N_SAMPLES+4) 383 387 384 388 self.set_border_width(15) 385 389 self.add(self.tab_box) … … 507 511 self.sound_in_bytecount.append(self.client.sound_in_bytecount) 508 512 if self.client.sound_out_bytecount>0: 509 513 self.sound_out_bytecount.append(self.client.sound_out_bytecount) 514 ss = self.client.sound_sink 515 if ss: 516 info = ss.get_info() 517 if info: 518 info = typedict(info) 519 self.sound_out_queue_cur.append(info.intget("queue.cur")) 520 self.sound_out_queue_min.append(info.intget("queue.min")) 521 self.sound_out_queue_max.append(info.intget("queue.max")) 510 522 511 523 #count pixels in the last second: 512 524 since = time.time()-1 … … 912 924 return True 913 925 start_x_offset = min(1.0, (time.time()-self.last_populate_time)*0.95) 914 926 rect = box.get_allocation() 915 h = max(200, h-bh-20, rect.height-bh-20) 916 w = max(360, rect.width-20) 927 maxw, maxh = self.client.get_root_size() 928 h = min(maxh, max(200, h-bh-20, rect.height-bh-20)) 929 w = min(maxw, max(360, rect.width-20)) 917 930 #bandwidth graph: 918 931 labels, datasets = [], [] 919 932 if self.net_in_bytecount and self.net_out_bytecount: … … 944 957 945 958 if labels and datasets: 946 959 pixmap = make_graph_pixmap(datasets, labels=labels, 947 width=w, height=h/ 2,960 width=w, height=h//3, 948 961 title="Bandwidth", min_y_scale=10, rounding=10, 949 962 start_x_offset=start_x_offset) 950 963 self.bandwidth_graph.set_size_request(*pixmap.get_size()) 951 964 self.bandwidth_graph.set_from_pixmap(pixmap, None) 952 if self.client.server_info_request: 953 pass 965 966 def norm_lists(items): 967 #ensures we always have exactly 20 values, 968 #(and skip if we don't have any) 969 values, labels = [], [] 970 for l, name in items: 971 if len(l)==0: 972 continue 973 l = list(l) 974 if len(l)<20: 975 for _ in range(20-len(l)): 976 l.insert(0, None) 977 values.append(l) 978 labels.append(name) 979 return values, labels 980 954 981 #latency graph: 955 latency_ graph_items =(982 latency_values, latency_labels = norm_lists(( 956 983 (self.avg_ping_latency, "network"), 957 984 (self.avg_batch_delay, "batch delay"), 958 985 (self.avg_damage_out_latency, "encode&send"), 959 986 (self.avg_decoding_latency, "decoding"), 960 987 (self.avg_total, "frame total"), 961 ) 962 latency_graph_values = [] 963 labels = [] 964 for l, name in latency_graph_items: 965 if len(l)==0: 966 continue 967 l = list(l) 968 if len(l)<20: 969 for _ in range(20-len(l)): 970 l.insert(0, None) 971 latency_graph_values.append(l) 972 labels.append(name) 973 pixmap = make_graph_pixmap(latency_graph_values, labels=labels, 974 width=w, height=h/2, 988 )) 989 pixmap = make_graph_pixmap(latency_values, labels=latency_labels, 990 width=w, height=h//3, 975 991 title="Latency (ms)", min_y_scale=10, rounding=25, 976 992 start_x_offset=start_x_offset) 977 993 self.latency_graph.set_size_request(*pixmap.get_size()) 978 994 self.latency_graph.set_from_pixmap(pixmap, None) 995 #sound queue graph: 996 queue_values, queue_labels = norm_lists(( 997 (self.sound_out_queue_max, "Max"), 998 (self.sound_out_queue_cur, "Level"), 999 (self.sound_out_queue_min, "Min"), 1000 )) 1001 pixmap = make_graph_pixmap(queue_values, labels=queue_labels, 1002 width=w, height=h//3, 1003 title="Sound Buffer (ms)", min_y_scale=10, rounding=25, 1004 start_x_offset=start_x_offset) 1005 self.sound_queue_graph.set_size_request(*pixmap.get_size()) 1006 self.sound_queue_graph.set_from_pixmap(pixmap, None) 979 1007 return True 980 1008 981 1009 def save_graphs(self, *args):