Skip to content

Commit

Permalink
#669:
Browse files Browse the repository at this point in the history
* don't create an OSX dock icon for the sound process: use a nested app, don't exec, don't probe the display
* if the sound sink fails to start, tell the server immediately!
* only log changes in sound pipeline "duration" with an actual value

git-svn-id: https://xpra.org/svn/Xpra/trunk@8822 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 23, 2015
1 parent 5ddd3dd commit d4e0ed0
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 27 deletions.
4 changes: 2 additions & 2 deletions osx/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleName</key>
<string>Xpra</string>
<key>CFBundleGetInfoString</key>
<string>0.15.0, (c) 2013-2014 http://xpra.org/</string>
<string>0.15.0, (c) 2013-2015 http://xpra.org/</string>
<key>CFBundleIconFile</key>
<string>xpra.icns</string>
<key>CFBundleIdentifier</key>
Expand All @@ -27,7 +27,7 @@
<key>CFBundleVersion</key>
<string>0.15.0</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2012-2014 Antoine Martin antoine@devloop.org.uk, GNU General Public License.</string>
<string>Copyright 2012-2015 Antoine Martin antoine@devloop.org.uk, GNU General Public License.</string>
<key>LSMinimumSystemVersion</key>
<string>10.5</string>
<key>LSUIElement</key>
Expand Down
39 changes: 39 additions & 0 deletions osx/Xpra_NoDock.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Xpra</string>
<key>CFBundleDisplayName</key>
<string>Xpra</string>
<key>CFBundleName</key>
<string>Xpra Without Tray</string>
<key>CFBundleGetInfoString</key>
<string>0.15.0, (c) 2013-2015 http://xpra.org/</string>
<key>CFBundleIconFile</key>
<string>xpra.icns</string>
<key>CFBundleIdentifier</key>
<string>xpra_notray</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.15</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.15</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2012-2014 Antoine Martin antoine@devloop.org.uk, GNU General Public License.</string>
<key>LSMinimumSystemVersion</key>
<string>10.5</string>
<key>LSUIElement</key>
<string>1</string>
<key>CFBundleDisplayName</key>
<string>Xpra</string>
<key>CFBundleName</key>
<string>Xpra</string>
</dict>
12 changes: 12 additions & 0 deletions osx/make-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ echo "Ship a default xpra.conf"
cp ../src/build/xpra.conf ${RSCDIR}/etc/


echo
echo "*******************************************************************************"
echo "Xpra without a tray..."
for app in Xpra_NoDock.app; do
SUB_APP="${IMAGE_DIR}/Contents/${app}"
rsync -rplvtog ${app} ${IMAGE_DIR}/Contents/
ln -sf ../../Resources ${SUB_APP}/Contents/Resources
ln -sf ../../MacOS ${SUB_APP}/Contents/MacOS
ln -sf ../../Helpers ${SUB_APP}/Contents/Helpers
done


echo
echo "*******************************************************************************"
echo "Hacks"
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,9 @@ def start_sound_sink(self, codec):
self.sound_sink.start()
soundlog("%s sound sink started", codec)
return True
except:
except Exception as e:
log.error("failed to start sound sink", exc_info=True)
self.sound_sink_error(self.sound_sink, e)
return False

def new_sound_buffer(self, sound_source, data, metadata):
Expand Down
9 changes: 6 additions & 3 deletions src/xpra/net/subprocess_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,15 @@ def make_protocol(self):


def exec_subprocess(self):
kwargs = {}
if os.name=="posix":
kwargs["close_fds"] = True
kwargs = self.exec_kwargs()
log("exec_subprocess() command=%s, kwargs=%s", self.command, kwargs)
return subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=sys.stderr.fileno(), **kwargs)

def exec_kwargs(self):
if os.name=="posix":
return {"close_fds" : True}
return {}


def cleanup(self):
self.stop()
Expand Down
42 changes: 28 additions & 14 deletions src/xpra/platform/darwin/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,30 @@ def debug(*msg):
def get_resources_dir():
rsc = None
RESOURCES = "/Resources/"
try:
import gtkosx_application #@UnresolvedImport
#FUGLY warning: importing gtkosx_application causes the dock to appear,
#and in some cases we don't want that.. so use the env var XPRA_SKIP_UI as workaround for such cases:
if os.environ.get("XPRA_SKIP_UI", "0")=="0":
try:
rsc = gtkosx_application.gtkosx_application_get_resource_path()
debug("get_resources_dir() gtkosx_application_get_resource_path=%s", rsc)
if rsc:
i = rsc.rfind(RESOURCES)
if i<=0:
rsc = None
import gtkosx_application #@UnresolvedImport
try:
rsc = gtkosx_application.gtkosx_application_get_resource_path()
debug("get_resources_dir() gtkosx_application_get_resource_path=%s", rsc)
except:
#maybe we're not running from an app bundle?
pass
except:
#maybe we're not running from an app bundle?
pass
except:
print("ERROR: gtkosx_application module is missing - trying to continue anyway")
if not rsc:
#delayed import to prevent cycles:
from xpra.log import Logger
log = Logger("util")
log.error("ERROR: gtkosx_application module is missing - trying to continue anyway")
else:
debug("XPRA_SKIP_UI is set, not importing gtkosx_application")
if rsc is None:
#try using the path to this file to find the resource path:
rsc = __file__
i = rsc.rfind(RESOURCES)
if i<=0:
#last fallback: try the default app dir
from xpra.platform.paths import default_get_app_dir
rsc = default_get_app_dir()
debug("get_resources_dir() default_get_app_dir()=%s", rsc)
Expand Down Expand Up @@ -70,5 +79,10 @@ def get_system_conf_dir():


def get_sound_executable():
helper = os.path.join(get_app_dir(), "MacOS", "Xpra")
#try to use the subapp:
base = get_app_dir()
subapp = os.path.join(base, "Xpra_NoDock.app", "Contents")
if os.path.exists(subapp) and os.path.isdir(subapp):
base = subapp
helper = os.path.join(subapp, "MacOS", "Xpra")
return os.environ.get("XPRA_SOUND_EXECUTABLE", helper)
8 changes: 3 additions & 5 deletions src/xpra/sound/pulseaudio_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def pactl_output(log_errors=True, *pactl_args):
return -1, None

def get_x11_property(atom_name):
if sys.platform.startswith("win"):
if sys.platform.startswith("darwin") or sys.platform.startswith("win"):
return ""
try:
from gtk import gdk
root = gdk.get_default_root_window()
pulse_server_atom = gdk.atom_intern(atom_name)
p = root.property_get(pulse_server_atom)
atom = gdk.atom_intern(atom_name)
p = root.property_get(atom)
if p is None:
return ""
v = p[2]
Expand All @@ -78,8 +78,6 @@ def get_x11_property(atom_name):
return ""

def has_pa_x11_property():
if os.name!="posix":
return False
#try root window property (faster)
ps = get_x11_property("PULSE_SERVER")
return len(ps)>0
Expand Down
4 changes: 3 additions & 1 deletion src/xpra/sound/sound_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def on_message(self, bus, message):
elif t == gst.MESSAGE_DURATION:
d = message.parse_duration()
try:
log("duration changed: %s", d[1])
v = d[1]
if v>0:
log("duration changed: %s", v)
except:
log("duration changed: %s", d)
elif t == gst.MESSAGE_LATENCY:
Expand Down
10 changes: 9 additions & 1 deletion src/xpra/sound/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,15 @@ def __init__(self):
#hook some default packet handlers:
self.connect("state-changed", self.state_changed)
self.connect("info", self.info_update)


def exec_kwargs(self):
#override so we can add the skip-ui flag needed for OSX to behave properly
kwargs = subprocess_caller.exec_kwargs(self)
env = os.environ.copy()
env["XPRA_SKIP_UI"] = "1"
kwargs["env"] = env
return kwargs


def state_changed(self, sink, new_state):
self.state = new_state
Expand Down

0 comments on commit d4e0ed0

Please sign in to comment.