Skip to content

Commit

Permalink
feat: concurrent processing & progress feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pnck committed Apr 26, 2024
1 parent 1c1b6b8 commit 010c3cc
Show file tree
Hide file tree
Showing 9 changed files with 312 additions and 210 deletions.
4 changes: 2 additions & 2 deletions foo_input_ncm.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ copy $(TargetPath) $(ProjectDir)dist\$(Platform)\</Command>
<ClInclude Include="src\common\consts.hpp" />
<ClInclude Include="src\common\helpers.hpp" />
<ClInclude Include="src\common\platform.hpp" />
<ClInclude Include="src\context_menu.hpp" />
<ClInclude Include="src\ui\context_menu.hpp" />
<ClInclude Include="src\input_ncm.hpp" />
<ClInclude Include="src\ncm_file.hpp" />
<ClInclude Include="src\stdafx.h" />
Expand All @@ -208,7 +208,7 @@ copy $(TargetPath) $(ProjectDir)dist\$(Platform)\</Command>
<ClCompile Include="src\cipher\abnormal_RC4.cpp" />
<ClCompile Include="src\cipher\aes_common.cpp" />
<ClCompile Include="src\cipher\aes_win32.cpp" />
<ClCompile Include="src\context_menu.cpp" />
<ClCompile Include="src\ui\context_menu.cpp" />
<ClCompile Include="src\input_ncm.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\ncm_file.cpp" />
Expand Down
14 changes: 10 additions & 4 deletions foo_input_ncm.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<Filter Include="Source Files\cipher">
<UniqueIdentifier>{8fbe3d95-ce5d-45fc-9c23-7924f6a1effd}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\ui">
<UniqueIdentifier>{3501375e-da47-48cf-9b61-e1aaea8a1d3c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ui">
<UniqueIdentifier>{66067789-eb07-4b26-b5cd-2cfb2626231a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\album_art_extractor.hpp">
Expand Down Expand Up @@ -60,8 +66,8 @@
<ClInclude Include="src\cipher\aes_common.hpp">
<Filter>Header Files\cipher</Filter>
</ClInclude>
<ClInclude Include="src\context_menu.hpp">
<Filter>Header Files</Filter>
<ClInclude Include="src\ui\context_menu.hpp">
<Filter>Header Files\ui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -89,8 +95,8 @@
<ClCompile Include="src\cipher\aes_common.cpp">
<Filter>Source Files\cipher</Filter>
</ClCompile>
<ClCompile Include="src\context_menu.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="src\ui\context_menu.cpp">
<Filter>Source Files\ui</Filter>
</ClCompile>
</ItemGroup>
</Project>
23 changes: 17 additions & 6 deletions foo_input_ncm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
A35F92E42BD6E8E600ABAABA /* context_menu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A35F92E32BD6E8E500ABAABA /* context_menu.cpp */; };
A35F92E52BD82FC400ABAABA /* foo_input_ncm.component in CopyFiles */ = {isa = PBXBuildFile; fileRef = A3B7380C2BCCBC6700DF7424 /* foo_input_ncm.component */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
A35F93C42BDBF18200ABAABA /* context_menu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A35F93C02BDBF18200ABAABA /* context_menu.cpp */; };
A3B738312BCCCF1A00DF7424 /* libpfc-Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A3B738302BCCCF1A00DF7424 /* libpfc-Mac.a */; };
A3B738742BCE313B00DF7424 /* libfoobar2000_component_client.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A3B738732BCE313B00DF7424 /* libfoobar2000_component_client.a */; };
A3B738762BCE313B00DF7424 /* libfoobar2000_SDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A3B738752BCE313B00DF7424 /* libfoobar2000_SDK.a */; };
Expand Down Expand Up @@ -39,8 +39,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
A35F92E22BD6E84D00ABAABA /* context_menu.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = context_menu.hpp; sourceTree = "<group>"; };
A35F92E32BD6E8E500ABAABA /* context_menu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = context_menu.cpp; sourceTree = "<group>"; };
A35F93C02BDBF18200ABAABA /* context_menu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = context_menu.cpp; sourceTree = "<group>"; };
A35F93C12BDBF18200ABAABA /* context_menu.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = context_menu.hpp; sourceTree = "<group>"; };
A35F93C22BDBF18200ABAABA /* extraction_process.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = extraction_process.hpp; sourceTree = "<group>"; };
A3B7380C2BCCBC6700DF7424 /* foo_input_ncm.component */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = foo_input_ncm.component; sourceTree = BUILT_PRODUCTS_DIR; };
A3B738302BCCCF1A00DF7424 /* libpfc-Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = "libpfc-Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A3B738732BCE313B00DF7424 /* libfoobar2000_component_client.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libfoobar2000_component_client.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -91,9 +92,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
A35F93C32BDBF18200ABAABA /* ui */ = {
isa = PBXGroup;
children = (
A35F93C02BDBF18200ABAABA /* context_menu.cpp */,
A35F93C12BDBF18200ABAABA /* context_menu.hpp */,
A35F93C22BDBF18200ABAABA /* extraction_process.hpp */,
);
name = ui;
path = src/ui;
sourceTree = "<group>";
};
A3B738032BCCBC6700DF7424 = {
isa = PBXGroup;
children = (
A35F93C32BDBF18200ABAABA /* ui */,
A3B738962BCE497400DF7424 /* src */,
A3B7380D2BCCBC6700DF7424 /* Products */,
A3B738292BCCCF1A00DF7424 /* Frameworks */,
Expand Down Expand Up @@ -157,8 +170,6 @@
A3B738822BCE497400DF7424 /* common */,
A3B7388C2BCE497400DF7424 /* album_art_extractor.cpp */,
A3B7388D2BCE497400DF7424 /* album_art_extractor.hpp */,
A35F92E32BD6E8E500ABAABA /* context_menu.cpp */,
A35F92E22BD6E84D00ABAABA /* context_menu.hpp */,
A3B7388F2BCE497400DF7424 /* input_ncm.cpp */,
A3B738902BCE497400DF7424 /* input_ncm.hpp */,
A3B738912BCE497400DF7424 /* main.cpp */,
Expand Down Expand Up @@ -245,7 +256,7 @@
A3B738972BCE497400DF7424 /* abnormal_RC4.cpp in Sources */,
A3B7389F2BCE497400DF7424 /* album_art_extractor.cpp in Sources */,
A3B738A22BCE497400DF7424 /* main.cpp in Sources */,
A35F92E42BD6E8E600ABAABA /* context_menu.cpp in Sources */,
A35F93C42BDBF18200ABAABA /* context_menu.cpp in Sources */,
A3B738A42BCE497400DF7424 /* stdafx.cpp in Sources */,
A3B738A12BCE497400DF7424 /* input_ncm.cpp in Sources */,
);
Expand Down
1 change: 1 addition & 0 deletions src/cipher/abnormal_RC4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace fb2k_ncm::cipher
// c++20 ranges version, returns a transform view
template <std::ranges::range R>
auto transform(const R &r) {
// TODO: consider parallel implementation (std::execution::par)
return r | std::views::all | std::views::transform([tf = get_transform(), this](auto b) { return tf(b, counter_++); });
}

Expand Down
4 changes: 3 additions & 1 deletion src/common/consts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace fb2k_ncm
0x35, 0x6B, 0x49, 0x6E, 0x62, 0x61, 0x78, 0x57}; // the AES key used to encrypt its RC4 seed
constexpr uint8_t ncm_meta_aes_key[] = {0x23, 0x31, 0x34, 0x6C, 0x6A, 0x6B, 0x5F, 0x21,
0x5C, 0x5D, 0x26, 0x30, 0x55, 0x3C, 0x27, 0x28}; // the AES key used to encrypt meta info

struct ncm_file_st {
uint64_t magic = ncm_magic;
uint8_t unknown_padding[2];
Expand All @@ -41,4 +40,7 @@ namespace fb2k_ncm
uint64_t album_image_offset;
uint64_t audio_content_offset;
};

constexpr int max_thread_count = 8; // recommended number of threads (hint)

} // namespace fb2k_ncm
195 changes: 0 additions & 195 deletions src/context_menu.cpp

This file was deleted.

4 changes: 3 additions & 1 deletion src/ncm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ bool ncm_file::save_raw_audio(const char *to_dir, abort_callback &p_abort) {
path_raw_saved_to_ = output;
return true;
}
} catch (const exception_aborted &) {
DEBUG_LOG("[DEBUG] Aborted: ", path());
} catch (const pfc::exception &e) {
FB2K_console_print("[ERR] ", e.what(), " (", output, ") ");
FB2K_console_print("[ERR] ", e.what(), " (writing ", output, ") ");
}
DEBUG_LOG("[DEBUG] Extraction failed: ", path());
path_raw_saved_to_.clear();
Expand Down
Loading

0 comments on commit 010c3cc

Please sign in to comment.