Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
Fixed memory buffer handling and made buffer display in megabytes ins…
Browse files Browse the repository at this point in the history
…tead of bytes (by SharkHunter)
  • Loading branch information
ikarsokolov committed Jun 22, 2012
1 parent 04ea550 commit b5dd407
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 70 deletions.
91 changes: 67 additions & 24 deletions src/main/java/net/pms/configuration/PmsConfiguration.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* file. * file.
*/ */
public class PmsConfiguration { public class PmsConfiguration {
private static final Logger logger = LoggerFactory.getLogger(PmsConfiguration.class); private static final Logger LOGGER = LoggerFactory.getLogger(PmsConfiguration.class);
private static final int DEFAULT_PROXY_SERVER_PORT = -1; private static final int DEFAULT_PROXY_SERVER_PORT = -1;
private static final int DEFAULT_SERVER_PORT = 5001; private static final int DEFAULT_SERVER_PORT = 5001;


Expand All @@ -71,6 +71,9 @@ public class PmsConfiguration {
private static final String KEY_AUDIO_THUMBNAILS_METHOD = "audio_thumbnails_method"; private static final String KEY_AUDIO_THUMBNAILS_METHOD = "audio_thumbnails_method";
private static final String KEY_AUTO_UPDATE = "auto_update"; private static final String KEY_AUTO_UPDATE = "auto_update";
private static final String KEY_AVISYNTH_CONVERT_FPS = "avisynth_convertfps"; private static final String KEY_AVISYNTH_CONVERT_FPS = "avisynth_convertfps";
private static final String KEY_AVISYNTH_INTERFRAME = "avisynth_interframe";
private static final String KEY_AVISYNTH_INTERFRAME_GPU = "avisynth_interframegpu";
private static final String KEY_AVISYNTH_MULTITHREADING = "avisynth_multithreading";

This comment has been minimized.

Copy link
@taconaut

taconaut Jun 22, 2012

Contributor

Are we going to use those?

This comment has been minimized.

Copy link
@ikarsokolov

ikarsokolov Jun 22, 2012

Author Member

It depends on whether we'll support new AviSynth features (interframe?) from SubJunk's fork with windows build.
Personally I don know much about AviSynth and have no interest in windows-only functionality.

This comment has been minimized.

Copy link
@taconaut

taconaut Jun 22, 2012

Contributor

Same here. The picture looks great anyway, don't need avi synth to squeeze in frames.
I suggest we remove them from the configuration (along with folder limit)

This comment has been minimized.

Copy link
@ikarsokolov

ikarsokolov Jun 22, 2012

Author Member

Yeah, since almost all modern TVs have some sort of frame interpolation features (MotionFlow etc) the benefits from this AvySynth filter is not clear. Not to mention higher CPU utilization and wasted bitrate for additional frames.

But maybe someone from more windows-centric members has other opinion.

This comment has been minimized.

Copy link
@taconaut

taconaut Jun 22, 2012

Contributor

Windows is underrepresented ;) I don't expect anyone wanting to maintain is.

private static final String KEY_AVISYNTH_SCRIPT = "avisynth_script"; private static final String KEY_AVISYNTH_SCRIPT = "avisynth_script";
private static final String KEY_BUFFER_TYPE = "buffertype"; private static final String KEY_BUFFER_TYPE = "buffertype";
private static final String KEY_CHAPTER_INTERVAL = "chapter_interval"; private static final String KEY_CHAPTER_INTERVAL = "chapter_interval";
Expand All @@ -85,6 +88,7 @@ public class PmsConfiguration {
private static final String KEY_FFMPEG_SETTINGS = "ffmpeg"; private static final String KEY_FFMPEG_SETTINGS = "ffmpeg";
private static final String KEY_FIX_25FPS_AV_MISMATCH = "fix_25fps_av_mismatch"; private static final String KEY_FIX_25FPS_AV_MISMATCH = "fix_25fps_av_mismatch";
private static final String KEY_FORCETRANSCODE = "forcetranscode"; private static final String KEY_FORCETRANSCODE = "forcetranscode";
private static final String KEY_FOLDER_LIMIT="folder_limit";
private static final String KEY_HIDE_EMPTY_FOLDERS = "hide_empty_folders"; private static final String KEY_HIDE_EMPTY_FOLDERS = "hide_empty_folders";
private static final String KEY_HIDE_ENGINENAMES = "hide_enginenames"; private static final String KEY_HIDE_ENGINENAMES = "hide_enginenames";
private static final String KEY_HIDE_EXTENSIONS = "hide_extensions"; private static final String KEY_HIDE_EXTENSIONS = "hide_extensions";
Expand Down Expand Up @@ -177,6 +181,7 @@ public class PmsConfiguration {
private static final String KEY_UUID = "uuid"; private static final String KEY_UUID = "uuid";
private static final String KEY_VIDEOTRANSCODE_START_DELAY = "key_videotranscode_start_delay"; private static final String KEY_VIDEOTRANSCODE_START_DELAY = "key_videotranscode_start_delay";
private static final String KEY_VIRTUAL_FOLDERS = "vfolders"; private static final String KEY_VIRTUAL_FOLDERS = "vfolders";
private static final String KEY_BUFFER_MAX = "buffer_max";


// the name of the subdirectory under which PMS config files are stored for this build (default: PMS). // the name of the subdirectory under which PMS config files are stored for this build (default: PMS).
// see Build for more details // see Build for more details
Expand All @@ -187,7 +192,9 @@ public class PmsConfiguration {


private static String DEFAULT_AVI_SYNTH_SCRIPT; private static String DEFAULT_AVI_SYNTH_SCRIPT;
private static final String BUFFER_TYPE_FILE = "file"; private static final String BUFFER_TYPE_FILE = "file";
private static final int MAX_MAX_MEMORY_BUFFER_SIZE = 400; private static final int MAX_MAX_MEMORY_DEFAULT_SIZE = 400;
private static final int BUFFER_MEMORY_FACTOR = 368;
private static int MAX_MAX_MEMORY_BUFFER_SIZE = MAX_MAX_MEMORY_DEFAULT_SIZE;
private static final char LIST_SEPARATOR = ','; private static final char LIST_SEPARATOR = ',';
private static final String KEY_FOLDERS = "folders"; private static final String KEY_FOLDERS = "folders";
private final PropertiesConfiguration configuration; private final PropertiesConfiguration configuration;
Expand Down Expand Up @@ -243,7 +250,7 @@ PMS_PROFILE is read (in this order) from the property pms.profile.path or the
under multiple profiles without fiddling with environment variables, properties or under multiple profiles without fiddling with environment variables, properties or
command-line arguments. command-line arguments.
1) if PMS_PROFILE is not set, PMS.conf is located in: 1) if PMS_PROFILE is not set, PMS.conf is located in:
Windows: %ALLUSERSPROFILE%\$build Windows: %ALLUSERSPROFILE%\$build
Mac OS X: $HOME/Library/Application Support/$build Mac OS X: $HOME/Library/Application Support/$build
Expand Down Expand Up @@ -351,8 +358,8 @@ it is taken to be the profile, and its parent dir is taken to be the profile (i.
* Default constructor that will attempt to load the PMS configuration file * Default constructor that will attempt to load the PMS configuration file
* from the profile path. * from the profile path.
* *
* @throws ConfigurationException * @throws org.apache.commons.configuration.ConfigurationException
* @throws IOException * @throws java.io.IOException
*/ */
public PmsConfiguration() throws ConfigurationException, IOException { public PmsConfiguration() throws ConfigurationException, IOException {
this(true); this(true);
Expand All @@ -364,8 +371,8 @@ public PmsConfiguration() throws ConfigurationException, IOException {
* @param loadFile Set to true to attempt to load the PMS configuration * @param loadFile Set to true to attempt to load the PMS configuration
* file from the profile path. Set to false to skip * file from the profile path. Set to false to skip
* loading. * loading.
* @throws ConfigurationException * @throws org.apache.commons.configuration.ConfigurationException
* @throws IOException * @throws java.io.IOException
*/ */
public PmsConfiguration(boolean loadFile) throws ConfigurationException, IOException { public PmsConfiguration(boolean loadFile) throws ConfigurationException, IOException {
configuration = new PropertiesConfiguration(); configuration = new PropertiesConfiguration();
Expand All @@ -381,7 +388,7 @@ public PmsConfiguration(boolean loadFile) throws ConfigurationException, IOExcep
if (pmsSkelConfFile.isFile() && pmsSkelConfFile.canRead()) { if (pmsSkelConfFile.isFile() && pmsSkelConfFile.canRead()) {
// load defaults from skel file, save them later to PROFILE_PATH // load defaults from skel file, save them later to PROFILE_PATH
configuration.load(pmsSkelConfFile); configuration.load(pmsSkelConfFile);
logger.info("Default configuration loaded from " + SKEL_PROFILE_PATH); LOGGER.info("Default configuration loaded from " + SKEL_PROFILE_PATH);
} }
} }
} }
Expand All @@ -391,17 +398,21 @@ public PmsConfiguration(boolean loadFile) throws ConfigurationException, IOExcep
tempFolder = new TempFolder(getString(KEY_TEMP_FOLDER_PATH, null)); tempFolder = new TempFolder(getString(KEY_TEMP_FOLDER_PATH, null));
programPaths = createProgramPathsChain(configuration); programPaths = createProgramPathsChain(configuration);
Locale.setDefault(new Locale(getLanguage())); Locale.setDefault(new Locale(getLanguage()));
// set DEFAULT_AVI_SYNTH_SCRIPT properly according to language
// Set DEFAULT_AVI_SYNTH_SCRIPT according to language
DEFAULT_AVI_SYNTH_SCRIPT = DEFAULT_AVI_SYNTH_SCRIPT =
Messages.getString("MEncoderAviSynth.4") Messages.getString("MEncoderAviSynth.4") +
+ Messages.getString("MEncoderAviSynth.5") Messages.getString("MEncoderAviSynth.5") +
+ Messages.getString("MEncoderAviSynth.6") Messages.getString("MEncoderAviSynth.6") +
+ Messages.getString("MEncoderAviSynth.7") Messages.getString("MEncoderAviSynth.7") +
+ Messages.getString("MEncoderAviSynth.8") Messages.getString("MEncoderAviSynth.8") +
+ Messages.getString("MEncoderAviSynth.9") Messages.getString("MEncoderAviSynth.10") +
+ Messages.getString("MEncoderAviSynth.10") Messages.getString("MEncoderAviSynth.11");
+ Messages.getString("MEncoderAviSynth.11")
+ Messages.getString("MEncoderAviSynth.12"); long usableMemory = (Runtime.getRuntime().maxMemory() / 1048576) - BUFFER_MEMORY_FACTOR;

This comment has been minimized.

Copy link
@Raptor399

Raptor399 Nov 22, 2012

Member

Could it be that the removal of this line (and the corresponding label) cause problems reported on the forum?

if (usableMemory > MAX_MAX_MEMORY_DEFAULT_SIZE) {
MAX_MAX_MEMORY_BUFFER_SIZE = (int) usableMemory;
}
} }


/** /**
Expand Down Expand Up @@ -1023,7 +1034,7 @@ public String getMencoderSubCp() {
* @return True if fontconfig should be used, false otherwise. * @return True if fontconfig should be used, false otherwise.
*/ */
public boolean isMencoderFontConfig() { public boolean isMencoderFontConfig() {
return getBoolean(KEY_MENCODER_FONT_CONFIG, false); return getBoolean(KEY_MENCODER_FONT_CONFIG, true);
} }


/** /**
Expand Down Expand Up @@ -1518,7 +1529,7 @@ public void setUseSubtitles(boolean value) {
* @return True if PMS should hide the folder, false othewise. * @return True if PMS should hide the folder, false othewise.
*/ */
public boolean getHideVideoSettings() { public boolean getHideVideoSettings() {
return getBoolean(KEY_HIDE_VIDEO_SETTINGS, false); return getBoolean(KEY_HIDE_VIDEO_SETTINGS, true);
} }


/** /**
Expand Down Expand Up @@ -1567,7 +1578,31 @@ public void setAvisynthConvertFps(boolean value) {
* @return True if PMS should pass the flag. * @return True if PMS should pass the flag.
*/ */
public boolean getAvisynthConvertFps() { public boolean getAvisynthConvertFps() {
return getBoolean(KEY_AVISYNTH_CONVERT_FPS, true); return getBoolean(KEY_AVISYNTH_CONVERT_FPS, false);
}

public void setAvisynthInterFrame(boolean value) {
configuration.setProperty(KEY_AVISYNTH_INTERFRAME, value);
}

public boolean getAvisynthInterFrame() {
return getBoolean(KEY_AVISYNTH_INTERFRAME, false);
}

public void setAvisynthInterFrameGPU(boolean value) {
configuration.setProperty(KEY_AVISYNTH_INTERFRAME_GPU, value);
}

public boolean getAvisynthInterFrameGPU() {
return getBoolean(KEY_AVISYNTH_INTERFRAME_GPU, false);
}

public void setAvisynthMultiThreading(boolean value) {
configuration.setProperty(KEY_AVISYNTH_MULTITHREADING, value);
}

public boolean getAvisynthMultiThreading() {
return getBoolean(KEY_AVISYNTH_MULTITHREADING, false);
} }


/** /**
Expand Down Expand Up @@ -1777,7 +1812,7 @@ private static List<String> hackAvs(SystemUtils registry, List<String> input) {
for (String engineId : input) { for (String engineId : input) {
if (engineId.startsWith("avs") && !registry.isAvis() && Platform.isWindows()) { if (engineId.startsWith("avs") && !registry.isAvis() && Platform.isWindows()) {
if (!avsHackLogged) { if (!avsHackLogged) {
logger.info("AviSynth is not installed. You cannot use " + engineId + " as a transcoding engine."); LOGGER.info("AviSynth is not installed. You cannot use " + engineId + " as a transcoding engine.");
avsHackLogged = true; avsHackLogged = true;
} }
toBeRemoved.add(engineId); toBeRemoved.add(engineId);
Expand All @@ -1791,7 +1826,7 @@ private static List<String> hackAvs(SystemUtils registry, List<String> input) {


public void save() throws ConfigurationException { public void save() throws ConfigurationException {
configuration.save(); configuration.save();
logger.info("Configuration saved to: " + PROFILE_PATH); LOGGER.info("Configuration saved to: " + PROFILE_PATH);
} }


public String getFolders() { public String getFolders() {
Expand Down Expand Up @@ -2209,7 +2244,7 @@ public String getProfileName() {
try { try {
HOSTNAME = InetAddress.getLocalHost().getHostName(); HOSTNAME = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
logger.info("Can't determine hostname"); LOGGER.info("Can't determine hostname");
HOSTNAME = "unknown host"; HOSTNAME = "unknown host";
} }
} }
Expand Down Expand Up @@ -2248,4 +2283,12 @@ public void addConfigurationListener(ConfigurationListener l) {
public void removeConfigurationListener(ConfigurationListener l) { public void removeConfigurationListener(ConfigurationListener l) {
configuration.removeConfigurationListener(l); configuration.removeConfigurationListener(l);
} }

public boolean getFolderLimit() {
return getBoolean(KEY_FOLDER_LIMIT, false);
}

public boolean initBufferMax() {
return getBoolean(KEY_BUFFER_MAX, false);
}
} }
Loading

0 comments on commit b5dd407

Please sign in to comment.