Skip to content

Commit

Permalink
#3592 remove legacy flat audio caps
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 26, 2023
1 parent 990c902 commit 494daf2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 61 deletions.
29 changes: 11 additions & 18 deletions xpra/client/mixins/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,10 @@ def get_info(self) -> dict[str,Any]:


def get_caps(self) -> dict[str,Any]:
d : dict[str,Any] = {}
avcaps = self.get_avsync_capabilities()
acaps = self.get_audio_capabilities()
d["av-sync"] = avcaps
d["audio"] = acaps
return d
return {
"av-sync" : self.get_avsync_capabilities(),
"audio" : self.get_audio_capabilities(),
}

def get_audio_capabilities(self) -> dict[str,Any]:
if not self.audio_properties:
Expand Down Expand Up @@ -229,18 +227,13 @@ def get_avsync_capabilities(self) -> dict[str,Any]:
def parse_server_capabilities(self, c : typedict) -> bool:
self.server_av_sync = c.boolget("av-sync.enabled")
avsynclog("av-sync: server=%s, client=%s", self.server_av_sync, self.av_sync)
audio = c.get("audio")
if audio and isinstance(audio, dict):
c = typedict(audio)
prefix = ""
else:
prefix = "sound."
self.server_pulseaudio_id = c.strget(f"{prefix}pulseaudio.id")
self.server_pulseaudio_server = c.strget(f"{prefix}pulseaudio.server")
self.server_audio_decoders = c.strtupleget(f"{prefix}decoders")
self.server_audio_encoders = c.strtupleget(f"{prefix}encoders")
self.server_audio_receive = c.boolget(f"{prefix}receive")
self.server_audio_send = c.boolget(f"{prefix}send")
audio = typedict(c.dictget("audio") or {})
self.server_pulseaudio_id = audio.strget("pulseaudio.id")
self.server_pulseaudio_server = audio.strget("pulseaudio.server")
self.server_audio_decoders = audio.strtupleget("decoders")
self.server_audio_encoders = audio.strtupleget("encoders")
self.server_audio_receive = audio.boolget("receive")
self.server_audio_send = audio.boolget("send")
log("pulseaudio id=%s, server=%s, audio decoders=%s, audio encoders=%s, receive=%s, send=%s",
self.server_pulseaudio_id, self.server_pulseaudio_server,
csv(self.server_audio_decoders), csv(self.server_audio_encoders),
Expand Down
34 changes: 6 additions & 28 deletions xpra/client/mixins/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ def get_caps(self) -> dict[str,Any]:
monitors = self.get_monitors_info()
caps["monitors"] = adjust_monitor_refresh_rate(self.refresh_rate, monitors)
caps.update(self.get_screen_caps())
dpi_caps = self.get_dpi_caps()
caps["dpi"] = dpi_caps
scaling_caps = self.get_scaling_caps()
caps["screen-scaling"] = scaling_caps
caps.update(flatten_dict({
"dpi" : self.get_dpi_caps(),
"screen-scaling" : self.get_scaling_caps(),
"dpi" : dpi_caps,
"screen-scaling" : scaling_caps,
}))
return caps

Expand Down Expand Up @@ -201,32 +205,6 @@ def get_screen_caps(self) -> dict[str,Any]:
caps["antialias"] = aa
return caps

#this is the format we should be moving towards
#with proper namespace:
#def get_info(self) -> dict:
# sinfo = self.get_screen_caps()
# sinfo["scaling"] = self.get_scaling_caps()
# sinfo["dpi"] = self.get_dpi_caps()
# return {
# "desktop" : self.get_desktop_caps(),
# "screen" : sinfo,
# }

#def get_desktop_info(self):
# caps = {
# "show" : True,
# }
# wm_name = get_wm_name()
# if wm_name:
# caps["wm_name"] = wm_name
# _, _, sss, ndesktops, desktop_names, u_root_w, u_root_h, xdpi, ydpi = self._last_screen_settings
# caps["unscaled-size"] = u_root_w, u_root_h
# caps["size"] = self.cp(u_root_w, u_root_h)
# caps["dpi"] = (xdpi, ydpi)
# caps["count"] = ndesktops
# caps["names"] = desktop_names
# caps["screens"] = len(sss)


def parse_server_capabilities(self, c : typedict) -> bool:
self.server_display = c.strget("display")
Expand Down
18 changes: 3 additions & 15 deletions xpra/server/source/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from xpra.server.source.stub_source_mixin import StubSourceMixin
from xpra.common import FULL_INFO
from xpra.os_util import get_machine_id, get_user_uuid, bytestostr
from xpra.util import csv, envbool, envint, flatten_dict, typedict, first_time, NotificationID
from xpra.util import csv, envbool, envint, typedict, first_time, NotificationID
from xpra.log import Logger

log = Logger("audio")
Expand Down Expand Up @@ -110,25 +110,15 @@ def stop_new_stream_notification(self, proc) -> None:

def parse_client_caps(self, c:typedict) -> None:
self.wants_audio = "audio" in c.strtupleget("wants")
audio = c.dictget("audio")
audio = typedict(c.dictget("audio") or {})
if audio:
audio = typedict(audio)
self.pulseaudio_id = audio.strget("pulseaudio.id", "")
self.pulseaudio_cookie_hash = audio.strget("pulseaudio.cookie-hash", "")
self.pulseaudio_server = audio.strget("pulseaudio.server", "")
self.audio_decoders = audio.strtupleget("decoders", ())
self.audio_encoders = audio.strtupleget("encoders", ())
self.audio_receive = audio.boolget("receive")
self.audio_send = audio.boolget("send")
else:
#pre v4.4:
self.pulseaudio_id = c.strget("sound.pulseaudio.id", "")
self.pulseaudio_cookie_hash = c.strget("sound.pulseaudio.cookie-hash", "")
self.pulseaudio_server = c.strget("sound.pulseaudio.server", "")
self.audio_decoders = c.strtupleget("sound.decoders", ())
self.audio_encoders = c.strtupleget("sound.encoders", ())
self.audio_receive = c.boolget("sound.receive")
self.audio_send = c.boolget("sound.send")
log("pulseaudio id=%s, cookie-hash=%s, server=%s, audio decoders=%s, audio encoders=%s, receive=%s, send=%s",
self.pulseaudio_id, self.pulseaudio_cookie_hash, self.pulseaudio_server,
self.audio_decoders, self.audio_encoders, self.audio_receive, self.audio_send)
Expand All @@ -149,9 +139,7 @@ def get_caps(self) -> dict[str,Any]:
"send" : self.supports_speaker and len(self.speaker_codecs)>0,
"receive" : self.supports_microphone and len(self.microphone_codecs)>0,
})
caps = flatten_dict({"sound" : audio_props})
caps["audio"] = audio_props
return caps
return {"audio" : audio_props}


def audio_loop_check(self, mode:str="speaker") -> bool:
Expand Down

0 comments on commit 494daf2

Please sign in to comment.