Skip to content

Commit

Permalink
Parallel processing default off
Browse files Browse the repository at this point in the history
Updated the parallel processing to be off by default since it was causing problems for some users. Combined with the "convert to ogg" settings, the default app behavior is back to what it was in v1.5 but has settings available for more advanced processing if users want it.
  • Loading branch information
bradytheinventor committed Feb 4, 2024
1 parent 76676c7 commit ffb822e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ class DisplayStrings():
STR_MIXMONO_TITLE = "Play tracks from the jukebox block"
STR_DP_VER_TITLE = "Use legacy datapack"
STR_KEEPTMP_TITLE = "Keep intermediate converted files"
STR_SKIPPROC_TITLE = "Convert tracks to .ogg one at a time"
STR_PROC_OGG = "Process .ogg files instead of copying"
# "Convert tracks with parallel processing"
STR_PAR_PROC_TITLE = "Convert tracks to .ogg all at once (experimental)"
STR_PROC_OGG = "Convert .ogg files instead of copying"

STR_PACKPNG_TOOLTIP = "Optional in-game icon. Auto-fills if you put a 'pack.png' in the same folder as the app."
STR_PACKNAME_TOOLTIP = "The name Minecraft will use to reference your pack."
Expand All @@ -184,9 +183,8 @@ class DisplayStrings():
STR_MIXMONO_TOOLTIP = "Mixes stereo tracks to mono. May increase generation time and reduce sound quality."
STR_DP_VER_TOOLTIP = "1.19.3 and earlier only supports the legacy datapack."
STR_KEEPTMP_TOOLTIP = "Save a copy of converted files so pack generation can go faster next time."
STR_SKIPPROC_TOOLTIP = "Slower, but more reliable. Try this if the parallel processing is not working."
STR_PAR_PROC_TOOLTIP = "Much faster, but doesn't work on some computers."
STR_PROC_OGG_TOOLTIP = "Sometimes fixes \"Can't detect ogg file length\" errors by removing bad header data."
# "Much faster, but doesn't work on some computers."

#dictionary to associate Status : status message string
StatusMessageDict = {
Expand Down Expand Up @@ -346,7 +344,7 @@ class SettingContents:
SettingContents(key='mix_mono', type=SettingType.CHECK, label=DisplayStrings.STR_MIXMONO_TITLE, tooltip=DisplayStrings.STR_MIXMONO_TOOLTIP ),
SettingContents(key='legacy_dp', type=SettingType.CHECK, label=DisplayStrings.STR_DP_VER_TITLE, tooltip=DisplayStrings.STR_DP_VER_TOOLTIP ),
# SettingContents(key='keep_tmp', type=SettingType.CHECK, label=DisplayStrings.STR_KEEPTMP_TITLE, tooltip=DisplayStrings.STR_KEEPTMP_TOOLTIP )
SettingContents(key='skip_proc', type=SettingType.CHECK, label=DisplayStrings.STR_SKIPPROC_TITLE, tooltip=DisplayStrings.STR_SKIPPROC_TOOLTIP ),
SettingContents(key='par_proc', type=SettingType.CHECK, label=DisplayStrings.STR_PAR_PROC_TITLE, tooltip=DisplayStrings.STR_PAR_PROC_TOOLTIP ),
SettingContents(key='proc_ogg', type=SettingType.CHECK, label=DisplayStrings.STR_PROC_OGG, tooltip=DisplayStrings.STR_PROC_OGG_TOOLTIP, )
]

Expand Down
19 changes: 10 additions & 9 deletions src/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,8 @@ def convert_all_to_ogg(self, entry_list: DiscListContents, settings: dict, conve
arg = self.prepare_for_convert(e, settings)
args.append(arg)

# use multiprocessing to run FFmpeg over many files in parallel
# ...or run them one-by-one if the user prefers (multiprocessing
# sometimes doesn't work for everyone)
if(settings.get('skip_proc', False)):
for a in args:
self.convert_to_ogg(a)
convert_cb()

else:
# use multiprocessing to run FFmpeg over many files in parallel, if the user desires
if(settings.get('par_proc', False)):
cpus = multiprocessing.cpu_count()

with multiprocessing.Pool(processes=cpus) as pool:
Expand All @@ -126,6 +119,14 @@ def convert_all_to_ogg(self, entry_list: DiscListContents, settings: dict, conve
for r in result:
convert_cb()

# otherwise, by default, run them one-by-one (multiprocessing doesn't work for
# everyone and it's better to opt-in to an experimental feature than for the app
# to break by default)
else:
for a in args:
self.convert_to_ogg(a)
convert_cb()

# update entry list to point to converted files
for (a, e) in zip(args, entry_list.entries):
e.track_file = a.out_track
Expand Down

0 comments on commit ffb822e

Please sign in to comment.