Permalink
Browse files

Refactored to removed Sage.EMBEDDED

This is a First pass.  All references to code usages of EMBEDDED have been removed and IF/ELSE conditions have hopefully been updated correctly.
  • Loading branch information...
stuckless committed Jun 25, 2017
1 parent 0df342e commit 0aa76ce872b383c3bc218ac4865b9f2cb329260a
Showing with 1,700 additions and 5,129 deletions.
  1. +23 −48 java/sage/AWTThreadWatcher.java
  2. +1 −1 java/sage/Agent.java
  3. +3 −17 java/sage/BGResourceLoader.java
  4. +28 −37 java/sage/BasicVideoFrame.java
  5. +5 −5 java/sage/BigBrother.java
  6. +0 −16 java/sage/CVMUtils.java
  7. +1 −1 java/sage/CaptureDeviceInput.java
  8. +9 −15 java/sage/Carny.java
  9. +7 −8 java/sage/Catbert.java
  10. +0 −1 java/sage/DirectX9SageRenderer.java
  11. +3 −5 java/sage/EPG.java
  12. +40 −48 java/sage/EventRouter.java
  13. +16 −106 java/sage/FSManager.java
  14. +2 −2 java/sage/FastMpeg2Reader.java
  15. +36 −55 java/sage/FastRandomFile.java
  16. +1 −1 java/sage/FileDownloader.java
  17. +1 −1 java/sage/FileTransfer.java
  18. +3 −8 java/sage/FreetypeFont.java
  19. +53 −197 java/sage/IOUtils.java
  20. +3 −20 java/sage/LinuxDVBCaptureManager.java
  21. +0 −507 java/sage/LinuxUtils.java
  22. +0 −6 java/sage/MMC.java
  23. +53 −140 java/sage/MediaFile.java
  24. +23 −29 java/sage/MediaServer.java
  25. +1 −13 java/sage/MetaFont.java
  26. +188 −509 java/sage/MetaImage.java
  27. +292 −748 java/sage/MiniClientSageRenderer.java
  28. +0 −2 java/sage/MiniDVDPlayer.java
  29. +28 −109 java/sage/MiniPlayer.java
  30. +44 −53 java/sage/Ministry.java
  31. +7 −10 java/sage/NetworkCaptureDevice.java
  32. +19 −117 java/sage/NetworkClient.java
  33. +32 −292 java/sage/NewStorageDeviceDetector.java
  34. +1 −1 java/sage/PVR150Input.java
  35. +1 −4 java/sage/Pooler.java
  36. +5 −10 java/sage/PseudoMenu.java
  37. +80 −147 java/sage/Sage.java
  38. +2 −20 java/sage/SageProperties.java
  39. +123 −299 java/sage/SageTV.java
  40. +39 −116 java/sage/SageTVConnection.java
  41. +6 −6 java/sage/Scheduler.java
  42. +54 −136 java/sage/Seeker.java
  43. +2 −8 java/sage/ThreadMonitor.java
  44. +145 −286 java/sage/UIManager.java
  45. +60 −100 java/sage/VideoFrame.java
  46. +2 −7 java/sage/WarlockRipper.java
  47. +31 −116 java/sage/Wizard.java
  48. +2 −2 java/sage/ZComp.java
  49. +5 −5 java/sage/ZDataTable.java
  50. +4 −4 java/sage/ZImage.java
  51. +4 −4 java/sage/ZLabel.java
  52. +20 −20 java/sage/ZPseudoComp.java
  53. +20 −31 java/sage/ZRoot.java
  54. +3 −6 java/sage/api/ChannelAPI.java
  55. +1 −3 java/sage/api/Configuration.java
  56. +1 −1 java/sage/api/Database.java
  57. +15 −88 java/sage/api/Global.java
  58. +2 −2 java/sage/api/MediaFileAPI.java
  59. +1 −2 java/sage/api/MediaPlayerAPI.java
  60. +0 −38 java/sage/api/ShowAPI.java
  61. +6 −189 java/sage/api/Utility.java
  62. +2 −7 java/sage/api/WidgetAPI.java
  63. +36 −55 java/sage/io/SageDataFile.java
  64. +2 −9 java/sage/media/bluray/BluRayParser.java
  65. +15 −45 java/sage/media/format/FormatParser.java
  66. +5 −28 java/sage/media/image/ImageLoader.java
  67. +3 −13 java/sage/media/image/RawImage.java
  68. +17 −33 java/sage/msg/MsgManager.java
  69. +29 −32 java/sage/plugin/CorePluginManager.java
  70. +0 −21 java/tv/sage/ModuleGroup.java
  71. +0 −1 java/tv/sage/mod/Module.java
  72. +1 −1 java/tv/sage/mod/STVReader.java
  73. +1 −1 java/tv/sage/mod/Translator.java
  74. +6 −20 java/tv/sage/weather/WeatherDotCom.java
  75. +0 −1 test/java/sage/TestUtils.java
  76. +25 −83 third_party/RSSLIB4J/java/sage/media/rss/RSSParser.java
  77. +1 −1 third_party/SingularSys/java/sage/jep/JEP.java
@@ -75,19 +75,9 @@ public void run()
" Hang Detected - hang time = " + (Sage.eventTime() - lastCheckSubmitTime) + " UILocker=" +
uiMgr.getUILockHolder());
if((stackDumperMeth != null || Sage.EMBEDDED) && delayToDumpAllThreads > 0 && (Sage.eventTime() - lastCheckSubmitTime) > delayToDumpAllThreads)
if(stackDumperMeth != null && delayToDumpAllThreads > 0 && (Sage.eventTime() - lastCheckSubmitTime) > delayToDumpAllThreads)
{
if (Sage.EMBEDDED)
{
if (!dumpedThreadStates)
{
// Avoid doing this repeatedly on embedded since it's much more heavyweight
dumpThreadStates();
dumpedThreadStates = true;
}
}
else
dumpThreadStates();
dumpThreadStates();
}
}
}
@@ -148,50 +138,35 @@ public void kill()
public static void dumpThreadStates()
{
if (Sage.EMBEDDED)
if (stackDumperMeth == null)
{
IOUtils.exec(new String[] { "sh", "-c", "kill -3 `pidof java`"});
if (Sage.client)
{
if (Sage.DBG) System.out.println("SageTV client sending command to server to dump its thread states since we were hung and it may be the cause...");
try
{
SageTV.api("DumpServerThreadStates", null);
}catch (Throwable t){}
}
}
else
{
if (stackDumperMeth == null)
{
try
{
stackDumperMeth = Thread.class.getDeclaredMethod("getAllStackTraces", new Class[0]);
}
catch (Throwable thr)
{
System.out.println("Stack dumping disabled because we can't reflect the dump method!:" + thr);
}
}
if (stackDumperMeth == null) return;
try
{
java.util.Map mappy = (java.util.Map)stackDumperMeth.invoke(null, (Object[])null);//Thread.getAllStackTraces();
java.util.Iterator walker = mappy.entrySet().iterator();
while (walker.hasNext())
{
java.util.Map.Entry ent = (java.util.Map.Entry) walker.next();
System.out.println("" + ent.getKey());
StackTraceElement[] stack = (StackTraceElement[]) ent.getValue();
for (int i = 0; i < stack.length; i++)
System.out.println("\t"+stack[i].toString());
}
stackDumperMeth = Thread.class.getDeclaredMethod("getAllStackTraces", new Class[0]);
}
catch (Throwable thr)
{
System.out.println("ERROR dumping thread stacks of:" + thr);
System.out.println("Stack dumping disabled because we can't reflect the dump method!:" + thr);
}
}
if (stackDumperMeth == null) return;
try
{
java.util.Map mappy = (java.util.Map)stackDumperMeth.invoke(null, (Object[])null);//Thread.getAllStackTraces();
java.util.Iterator walker = mappy.entrySet().iterator();
while (walker.hasNext())
{
java.util.Map.Entry ent = (java.util.Map.Entry) walker.next();
System.out.println("" + ent.getKey());
StackTraceElement[] stack = (StackTraceElement[]) ent.getValue();
for (int i = 0; i < stack.length; i++)
System.out.println("\t"+stack[i].toString());
}
}
catch (Throwable thr)
{
System.out.println("ERROR dumping thread stacks of:" + thr);
}
}
private static java.lang.reflect.Method stackDumperMeth = null;
View
@@ -49,7 +49,7 @@
// Enables checking all airings against the optimized airings. This is for testing only.
static final boolean VERIFY_AIRING_OPTIMIZATION = false;
private static final int CPU_CONTROL_MOD_COUNT = Sage.getInt("profiler_cpu_mod_count", Sage.EMBEDDED ? 2500 : 25000);
private static final int CPU_CONTROL_MOD_COUNT = Sage.getInt("profiler_cpu_mod_count", 25000);
public static final int LOVE_MASK = 0x0001;
public static final int TITLE_MASK = 0x0002;
@@ -92,11 +92,6 @@ public void run()
continue;
}
}
while (Sage.EMBEDDED && uiMgr.areUIActionsBeingProcessed(false))
{
// Hold off on this processing on limited resource systems if we're trying to respond to a user action
try{Thread.sleep(10);}catch(Exception e){}
}
if (DEBUG_LOADER && Sage.DBG) System.out.println("BGLoader1 is processing the image resource for src=" + (processMe.metaSrc == null ? processMe.thumbSrc : processMe.metaSrc));
if (!verifyLoadNeeded(processMe))
@@ -111,7 +106,7 @@ else if (processMe.metaSrc instanceof Album)
processMe.myMeta = MetaImage.getMetaImage((Album) processMe.metaSrc);
else if (processMe.metaSrc instanceof java.io.File)
processMe.myMeta = MetaImage.getMetaImage((java.io.File) processMe.metaSrc);
else if (processMe.metaSrc instanceof java.awt.Image && !Sage.EMBEDDED)
else if (processMe.metaSrc instanceof java.awt.Image)
processMe.myMeta = MetaImage.getMetaImage((java.awt.Image) processMe.metaSrc);
else if (processMe.metaSrc instanceof java.net.URL)
processMe.myMeta = MetaImage.getMetaImage((java.net.URL) processMe.metaSrc);
@@ -164,12 +159,6 @@ public void run()
}
}
while (Sage.EMBEDDED && uiMgr.areUIActionsBeingProcessed(false))
{
// Hold off on this processing on limited resource systems if we're trying to respond to a user action
try{Thread.sleep(10);}catch(Exception e){}
}
if (DEBUG_LOADER && Sage.DBG) System.out.println("BGLoader2 is processing the image resource for src=" + (processMe.metaSrc == null ? processMe.thumbSrc : processMe.metaSrc));
// Now we do the actual image decode/preload into memory; checking if its needed first of course
if (!verifyLoadNeeded(processMe))
@@ -181,11 +170,8 @@ public void run()
if (DEBUG_LOADER && Sage.DBG) System.out.println("BGLoader is preloading the image into the cache now for meta=" + processMe.myMeta);
if (nia != null)
nia.preloadImage(processMe.myMeta);
else if (!Sage.EMBEDDED)
{
processMe.myMeta.getJavaImage(0);
processMe.myMeta.removeJavaRef(0);
}
processMe.myMeta.getJavaImage(0);
processMe.myMeta.removeJavaRef(0);
if (processMe.myMeta.isNullOrFailed())
failedImageTimes.put(getFastKey(processMe.metaSrc == null ? processMe.thumbSrc : processMe.metaSrc), new Long(Sage.eventTime()));
if (DEBUG_LOADER && Sage.DBG) System.out.println("BGLoader is DONE preloading the image into the cache now; notify the listeners for meta=" + processMe.myMeta);
@@ -146,41 +146,35 @@ public BasicVideoFrame(UIManager inUIMgr)
videoBGColor = new java.awt.Color(30, 30, 30);
}
videoHShiftFreq = uiMgr.getLong(prefs + VIDEO_HORIZONTAL_SHIFT_FREQ, 0);
if (!Sage.EMBEDDED)
if (videoHShiftFreq != 0)
{
if (videoHShiftFreq != 0)
createVideoHShiftTimer();
}
setLayout(new java.awt.LayoutManager()
{
public void addLayoutComponent(String name, java.awt.Component comp){}
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
{
createVideoHShiftTimer();
return preferredLayoutSize(parent);
}
setLayout(new java.awt.LayoutManager()
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
{
public void addLayoutComponent(String name, java.awt.Component comp){}
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
{
return preferredLayoutSize(parent);
}
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
{
return parent.getPreferredSize();
}
public void removeLayoutComponent(java.awt.Component comp){}
public void layoutContainer(java.awt.Container parent)
{
videoComp.setBounds(0, 0, parent.getWidth(), parent.getHeight());
refreshVideoSizing();
}
});
setFocusTraversalKeysEnabled(false);
setBackground(java.awt.Color.gray);
}
return parent.getPreferredSize();
}
public void removeLayoutComponent(java.awt.Component comp){}
public void layoutContainer(java.awt.Container parent)
{
videoComp.setBounds(0, 0, parent.getWidth(), parent.getHeight());
refreshVideoSizing();
}
});
setFocusTraversalKeysEnabled(false);
setBackground(java.awt.Color.gray);
videoComp = new VideoCanvas();
if (!Sage.EMBEDDED)
{
videoComp.setFocusTraversalKeysEnabled(false);
add(videoComp);
videoComp.setVisible(false);
}
videoComp.setFocusTraversalKeysEnabled(false);
add(videoComp);
videoComp.setVisible(false);
mmc = MMC.getInstance();
forcedPAR = uiMgr.getFloat("ui/forced_pixel_aspect_ratio", 0);
}
@@ -367,19 +361,16 @@ public void setDisplayAspectRatio(float f)
public abstract float getCurrentAspectRatio();
public void refreshVideoSizing()
{
if (!Sage.EMBEDDED && getParent() == null) return;
if (getParent() == null) return;
refreshVideoSizing(getVideoSize());
}
public void refreshVideoSizing(java.awt.Dimension vsize)
{
if (!Sage.EMBEDDED && getParent() == null) return;
if (getParent() == null) return;
sage.geom.Rectangle myBounds;
if (videoBounds == null)
{
if (Sage.EMBEDDED)
myBounds = new sage.geom.Rectangle(0, 0, uiMgr.getRootPanel().getWidth(), uiMgr.getRootPanel().getHeight());
else
myBounds = new sage.geom.Rectangle(0, 0, getParent().getWidth(), getParent().getHeight());
myBounds = new sage.geom.Rectangle(0, 0, getParent().getWidth(), getParent().getHeight());
}
else
myBounds = new sage.geom.Rectangle(videoBounds);
@@ -484,7 +475,7 @@ public void setVideoHShiftFreq(long x)
videoHShiftTimer.cancel();
videoHShiftTimer = null;
}
if (x != 0 && !Sage.EMBEDDED)
if (x != 0)
{
createVideoHShiftTimer();
}
View
@@ -184,7 +184,7 @@ public static void clearWatched(Airing a)
}
Watched prior = Wizard.getInstance().getWatch(a);
if (prior != null) Wizard.getInstance().removeWatched(prior);
if (a.isTV() && (!Sage.EMBEDDED || Carny.getInstance().isLoveAir(a)))
if (a.isTV() && Carny.getInstance().isLoveAir(a))
Carny.getInstance().submitJob(new Object[] { Carny.WATCH_CLEAR_JOB, a });
triggerWatchedChangeEvent(a);
}
@@ -202,7 +202,7 @@ static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
long realWatchStart, long realWatchEnd, int titleNum, boolean checkOnly)
{
if (!SageConstants.LIBRARY_FUNCTION) return true;
if (!Sage.EMBEDDED && !SageConstants.LITE)
if (!SageConstants.LITE)
((byte[])Sage.q)[32] = (byte) (((byte[])Sage.q)[11] * ((byte[])Sage.q)[25]); // piracy protection
if (a == null) return false;
// Only track watches for TV & Video Airings & DVDs/BDs
@@ -224,7 +224,7 @@ static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
Wizard.getInstance().addWatched(a, (a.isDVD() || a.isBluRay()) ? 0 : a.getStartTime(),
(a.isDVD() || a.isBluRay()) ? a.getDuration() : a.getEndTime(),
0, 0);
if (a.isTV() && (!Sage.EMBEDDED || Carny.getInstance().isLoveAir(a)))
if (a.isTV() && Carny.getInstance().isLoveAir(a))
Carny.getInstance().submitJob(new Object[] { Carny.WATCH_MARK_JOB, a });
triggerWatchedChangeEvent(a);
}
@@ -235,7 +235,7 @@ static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
long watchedDur = airWatchEnd - airWatchStart;
boolean rv = false;
Watched priorWatch = Wizard.getInstance().getWatch(a);
if (watchedDur > MIN_WATCH_TIME || (Sage.EMBEDDED && priorWatch != null))
if (watchedDur > MIN_WATCH_TIME)
{
// It's not so short we ignore it.
// See if we want to apply this to the show or not
@@ -271,7 +271,7 @@ static boolean setWatched(Airing a, long airWatchStart, long airWatchEnd,
{
if (s != null)
s.setLastWatched(a.time);
if (a.isTV() && (!Sage.EMBEDDED || Carny.getInstance().isLoveAir(a)))
if (a.isTV() && Carny.getInstance().isLoveAir(a))
Carny.getInstance().submitJob(new Object[] { Carny.WATCH_REAL_JOB, a });
}
triggerWatchedChangeEvent(a);
View
@@ -21,20 +21,4 @@
*/
public class CVMUtils
{
static
{
if (Sage.EMBEDDED)
{
try
{
sage.Native.loadLibrary("CVMUtils");
}
catch (Throwable t)
{
System.out.println("ERROR Could not load library for CVMUtils!!!! " + t);
t.printStackTrace();
}
}
}
public static native int reloadNameserverCache();
}
@@ -542,7 +542,7 @@ public String getTuningPlugin()
sage.media.format.ContainerFormat cf;
// We don't know what it is in this case aside from container, so it'll get set through a message callback
cf = new sage.media.format.ContainerFormat();
if (Sage.getBoolean(prefs + "encode_digital_tv_as_program_stream", !Sage.EMBEDDED))
if (Sage.getBoolean(prefs + "encode_digital_tv_as_program_stream", true))
cf.setFormatName(sage.media.format.MediaFormat.MPEG2_PS);
else
cf.setFormatName(sage.media.format.MediaFormat.MPEG2_TS);
View
@@ -58,13 +58,13 @@
private static final String MAP_DENSITY = "carny_map_density";
static final String CARNY_KEY = "carny";
private static final long LOOKAHEAD = Sage.EMBEDDED ? 10*24*60*60*1000L : 14*24*60*60*1000L;
private static final long LOOKAHEAD = 14*24*60*60*1000L;
/*
* NOTE: I CHANGED THIS ON 7/22/03. I THINK IT'S WHY ITS RECORDING
* EXTRA STUFF, BECAUSE ANYTHING WILL COME THROUGH WITH AT LEAST THIS PROBABILITY
*/
private static final float MIN_WP = 0;//1e-6f;
public static final long SLEEP_PERIOD = Sage.EMBEDDED ? 120 : 30;
public static final long SLEEP_PERIOD = 30;
// The processor count is used to limit the number of threads we will spin up for agent processing.
public static final int PROCESSOR_COUNT = Math.max(Runtime.getRuntime().availableProcessors(), 1);
@@ -120,7 +120,7 @@ private Carny()
jobs = new Vector<Object[]>();
alive = true;
wiz = Wizard.getInstance();
trends = Sage.EMBEDDED ? new int[0] : new int[] { Agent.TITLE_MASK | Agent.FIRSTRUN_MASK, Agent.TITLE_MASK | Agent.RERUN_MASK,
trends = new int[] { Agent.TITLE_MASK | Agent.FIRSTRUN_MASK, Agent.TITLE_MASK | Agent.RERUN_MASK,
Agent.CHANNEL_MASK | Agent.CATEGORY_MASK,
Agent.NETWORK_MASK | Agent.CATEGORY_MASK, Agent.ACTOR_MASK,
Agent.CHANNEL_MASK | Agent.PR_MASK, Agent.CATEGORY_MASK | Agent.PR_MASK };
@@ -232,12 +232,9 @@ private boolean shouldContinueStdProcessing(boolean underTimeLimit)
void incWatchCount()
{
if (!Sage.EMBEDDED)
synchronized (GLOBAL_WATCH_COUNT)
{
synchronized (GLOBAL_WATCH_COUNT)
{
Sage.putInt(prefs + GLOBAL_WATCH_COUNT, ++globalWatchCount);
}
Sage.putInt(prefs + GLOBAL_WATCH_COUNT, ++globalWatchCount);
}
}
@@ -249,10 +246,7 @@ protected void notifyOfWatchCount(int wCount)
if (wCount >= globalWatchCount)
{
globalWatchCount = wCount + 1;
if (!Sage.EMBEDDED)
{
Sage.putInt(prefs + GLOBAL_WATCH_COUNT, globalWatchCount);
}
Sage.putInt(prefs + GLOBAL_WATCH_COUNT, globalWatchCount);
}
}
@@ -295,8 +289,8 @@ public Agent addFavorite(int agentMask, String title, String category, String su
wiz.releaseWriteLock(Wizard.AGENT_CODE);
}
long defaultFavoriteStartPadding = Sage.getLong("default_favorite_start_padding", Sage.EMBEDDED ? 5*Sage.MILLIS_PER_MIN : 0);
long defaultFavoriteStopPadding = Sage.getLong("default_favorite_stop_padding", Sage.EMBEDDED ? 5*Sage.MILLIS_PER_MIN : 0);
long defaultFavoriteStartPadding = Sage.getLong("default_favorite_start_padding", 0);
long defaultFavoriteStopPadding = Sage.getLong("default_favorite_stop_padding", 0);
if (defaultFavoriteStartPadding != 0)
{
rv.setStartPadding(defaultFavoriteStartPadding);
@@ -945,7 +939,7 @@ private void applyWasteData(Airing wasteAir)
// and be able to modify the information the agent is based on.
Show s = wasteAir.getShow();
// We don't track 'wasted' objects on embedded so disable that here
if (s == null || !wasteAir.isTV() || Sage.EMBEDDED) return;
if (s == null || !wasteAir.isTV()) return;
Stringer stit = s.title;
Agent[] allAgents = wiz.getAgents();
StringBuilder sbCache = new StringBuilder();
Oops, something went wrong.

0 comments on commit 0aa76ce

Please sign in to comment.