Skip to content

Commit

Permalink
Mixdowns use MP3
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Jan 18, 2024
1 parent bba5375 commit 64364cf
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
29 changes: 22 additions & 7 deletions libraries/lib-cloud-audiocom/ServiceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,19 @@ std::chrono::milliseconds ServiceConfig::GetProgressCallbackTimeout() const
return std::chrono::seconds(3);
}

std::vector<std::string> ServiceConfig::GetPreferredAudioFormats() const
std::vector<std::string>
ServiceConfig::GetPreferredAudioFormats(bool preferLossless) const
{
return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
if (preferLossless)
return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
else
return { "audio/mpeg" };
}

rapidjson::Document ServiceConfig::GetExportConfig(const std::string& mimeType) const
rapidjson::Document
ServiceConfig::GetExportConfig(const std::string& mimeType) const
{
if(mimeType == "audio/x-wavpack")
if (mimeType == "audio/x-wavpack")
{
rapidjson::Document config;
config.SetObject();
Expand All @@ -169,17 +174,27 @@ rapidjson::Document ServiceConfig::GetExportConfig(const std::string& mimeType)
config.AddMember("hybrid_mode", false, config.GetAllocator());
return config;
}
if(mimeType == "audio/x-flac")
else if (mimeType == "audio/x-flac")
{
rapidjson::Document config;
config.SetObject();
config.AddMember("bit_depth", rapidjson::Value(24), config.GetAllocator());
config.AddMember(
"bit_depth", rapidjson::Value(24), config.GetAllocator());
config.AddMember("level", rapidjson::Value(5), config.GetAllocator());
}
if(mimeType == "audio/x-wav")
else if (mimeType == "audio/x-wav")
{
return {};
}
else if (mimeType == "audio/mpeg")
{
rapidjson::Document config;
config.SetObject();
config.AddMember("mode", rapidjson::Value("VBR"), config.GetAllocator());
config.AddMember("quality", rapidjson::Value(5), config.GetAllocator());
return config;
}

throw std::invalid_argument("unknown mime-type");
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/lib-cloud-audiocom/ServiceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CLOUD_AUDIOCOM_API ServiceConfig final
//! Timeout between progress callbacks
std::chrono::milliseconds GetProgressCallbackTimeout() const;
//! Preferred audio format
std::vector<std::string> GetPreferredAudioFormats() const;
std::vector<std::string> GetPreferredAudioFormats(bool preferLossless = true) const;
//! Export configuration suitable for the mime type provided
rapidjson::Document GetExportConfig(const std::string& exporterName) const;
//! Return the mime type server should store the file. This is a requirement
Expand Down
2 changes: 1 addition & 1 deletion libraries/lib-cloud-audiocom/sync/LocalProjectSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ void LocalProjectSnapshot::OnSnapshotCreated(
if (mProjectCloudExtension.NeedsMixdownSync())
{
mMixdownUploadInProgress.store(true, std::memory_order_release);

mMixdownUploader = MixdownUploader::Upload(
mCloudSyncUI, mServiceConfig, *project, mixdownUrls,
[this](std::string, bool success)
{
if (success)
mProjectCloudExtension.MixdownSynced();

mMixdownUploader.reset();
mMixdownUploadInProgress.store(
false, std::memory_order_release);
});
Expand Down
7 changes: 5 additions & 2 deletions libraries/lib-cloud-audiocom/sync/MixdownUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void MixdownUploader::ExportProject()
const auto& registry = ExportPluginRegistry::Get();

for (const auto& preferredMimeType :
GetServiceConfig().GetPreferredAudioFormats())
GetServiceConfig().GetPreferredAudioFormats(false))
{
auto config = GetServiceConfig().GetExportConfig(preferredMimeType);
ExportProcessor::Parameters parameters;
Expand Down Expand Up @@ -325,7 +325,10 @@ void MixdownUploader::UploadMixdown()
[this](UploadResult result)
{
BasicUI::CallAfter([this, result = std::move(result)]
{ mCloudSyncUI.OnMixdownFinished(); });
{
mCloudSyncUI.OnMixdownFinished();
mOnComplete(result.ErrorMessage, result.Code == UploadResultCode::Success);
});
},
{});
}
Expand Down

0 comments on commit 64364cf

Please sign in to comment.