Author: ayoung
Date: Fri Jan 21 23:42:37 2011
New Revision: 9296
URL: http://svn.slimdevices.com/jive?rev=9296&view=rev
Log:
Fixed bug 16658: alarm can sometimes not be silenced due to OOM error when
checking if headphones are connected
Avoid use of external amixer command for manipulating audio endpoint by
extending facilities already available in SqueezeboxBabyApplet.
Generalize code and comments so that mechanism is not specific to Baby.
Modified:
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyMeta.lua
Modified:
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua?rev=9296&r1=9295&r2=9296&view=diff
==============================================================================
---
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
(original)
+++
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/AlarmSnooze/AlarmSnoozeApplet.lua
Fri Jan 21 23:42:37 2011
@@ -409,7 +409,7 @@
if self.alarmWindow then
self.alarmWindow:hide()
self.alarmWindow = nil
- self:_babyRevertHeadphones()
+ self:_revertAudioEndpointOverride()
end
end
@@ -486,9 +486,9 @@
log:warn('openAlarmWindow()', caller, ' ',
self.localPlayer:isConnected())
- self:_babyAlarmThroughSpeakers()
-
- -- if radio is controlling a different player, switch to the local
player
+ self:_alarmThroughSpeakers()
+
+ -- if UI is controlling a different player, switch to the local player
-- if notify_playerLoaded needs invocation prior to player change
taking effect then refire openAlarmWindow() at that time
local currentPlayer = Player:getCurrentPlayer()
@@ -849,33 +849,20 @@
return false
end
--- On Radio guarantee that alarm audio comes through speakers even even
Headphones are plugged in
-function _babyAlarmThroughSpeakers(self)
- if System:getMachine()=='baby' then
- -- if headphones are (un)plugged while alarm is playing mixer
gets reverted automatically
- os.execute("amixer -q sset Endpoint Speaker")
- end
-end
-
--- On Radio alarm was routed through the speaker. When alarm is turned off we
need to
--- revert the audio to the headphone out (if headphones are plugged in)
+-- On player with multiple audio output endpoints guarantee that alarm audio
+-- comes through speakers even even Headphones (or some other output) is
enabled
+function _alarmThroughSpeakers(self)
+ appletManager:callService("overrideAudioEndpoint", 'Speaker')
+end
+
+-- If alarm was overridden to the speaker then, when alarm is turned off, we
need to
+-- revert the audio endpoint
--
-- note: this method is called from the _hideAlarmWindow() method, so if at
some future date
-- there are options added to allow a user to have an alarm with no
notification window,
-- where the revert method is called needs rethinking
-function _babyRevertHeadphones(self)
- if System:getMachine()=='baby' then
- -- check if headphones are plugged in
- -- (code taken from TestAudioRoutingApplet who can show the
Headphones status in the factory test)
- local fh = _assert(io.popen("amixer cget name=\"Headphone
Switch\" | grep : | sed 's/^.*=\\([^,]*\\).*$/\\1/'"))
- local state = fh:read("*a")
- fh:close()
-
- -- revert to headphones if needed
- if state and state:sub(1,1) == "1" then
- os.execute("amixer -q sset Endpoint Headphone")
- end
- end
+function _revertAudioEndpointOverride(self)
+ appletManager:callService("overrideAudioEndpoint", nil)
end
--[[
Modified:
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua?rev=9296&r1=9295&r2=9296&view=diff
==============================================================================
---
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
(original)
+++
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
Fri Jan 21 23:42:37 2011
@@ -284,6 +284,10 @@
return bsp:getMixer("Line In Switch")
end
+function overrideAudioEndpoint(self, override) -- 'Speaker' | 'Headphone' |
nil => default
+ self:_setEndpoint(override)
+end
+
-----------------------------
-- Ambient Light Stuff Start
-----------------------------
@@ -601,14 +605,23 @@
end
-function _setEndpoint(self)
+function _setEndpoint(self, override)
if self.isHeadphone == nil then
-- don't change state during initialization
return
end
local endpoint
- if self.isHeadphone then
+ if override then
+ if override == "Speaker" then
+ endpoint = "Speaker"
+ elseif override == "Headphone" then
+ endpoint = "Headphone"
+ else
+ log:warn("Invalid audio endpoint override ignored: ",
override)
+ endpoint = self.endpoint
+ end
+ elseif self.isHeadphone then
endpoint = "Headphone"
elseif self.powerState == "ACTIVE" or self.powerState == "IDLE" then
endpoint = "Speaker"
Modified:
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyMeta.lua
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyMeta.lua?rev=9296&r1=9295&r2=9296&view=diff
==============================================================================
---
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyMeta.lua
(original)
+++
7.6/trunk/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyMeta.lua
Fri Jan 21 23:42:37 2011
@@ -100,6 +100,7 @@
meta:registerService("reboot")
meta:registerService("wasLastShutdownUnclean")
meta:registerService("isLineInConnected")
+ meta:registerService("overrideAudioEndpoint") -- 'Speaker' |
'Headphone' | nil => default
end
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins