Skip to content

Commit

Permalink
Changed results file paths to use ~ as a delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
AVLatency committed Aug 17, 2023
1 parent 449c5bf commit aec32ca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Audio-Latency/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,8 +1319,10 @@ void Gui::StartTest()
}
}

std::string fileString = StringHelper::GetFilenameSafeString(std::format("{} {}", TestNotes::Notes.DutModel, TestNotes::Notes.DutOutputType()));
fileString = fileString.substr(0, 80); // 80 is a magic number that will keep path lengths reasonable without needing to do a lot of Windows API programming.
const char* outType = OutputOffsetProfiles::CurrentProfile()->OutType == OutputOffsetProfile::OutputType::HdmiAudioPassthrough
? TestNotes::Notes.DutPassthroughOutputType() : TestNotes::Notes.DutOutputType();
std::string fileString = StringHelper::GetFilenameSafeString(std::format("{}~{}", outType, TestNotes::Notes.DutModel));
fileString = fileString.substr(0, 67); // 67 is a magic number that will keep path lengths reasonable without needing to do a lot of Windows API programming.


DacLatencyProfile* currentDacProfile =
Expand Down
2 changes: 1 addition & 1 deletion Audio-Latency/TestNotes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestNotes
char DutModel[128] = "";
char DutFirmwareVersion[128] = "";
int DutOutputTypeIndex = 0;
const char* DutOutputTypeOptions[4] = { "", "Speaker", "Headphone Output", "Other" };
const char* DutOutputTypeOptions[4] = { "", "Speaker", "Headphone", "Other" };
char DutOutputTypeOther[128] = "";
const char* DutOutputType()
{
Expand Down
30 changes: 30 additions & 0 deletions Shared-Items/OutputOffsetProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ std::string OutputOffsetProfile::OutputTypeName(OutputOffsetProfile::OutputType
}
}

std::string OutputOffsetProfile::OutputTypeNameFileSafe(OutputOffsetProfile::OutputType outputType)
{
switch (outputType)
{
case OutputOffsetProfile::OutputType::None:
return " ";
break;
case OutputOffsetProfile::OutputType::Hdmi:
return "HDMI";
break;
case OutputOffsetProfile::OutputType::Spdif:
return "SPDIF";
break;
case OutputOffsetProfile::OutputType::ARC:
return "ARC RX";
break;
case OutputOffsetProfile::OutputType::eARC:
return "eARC RX";
break;
case OutputOffsetProfile::OutputType::Analog:
return "Analog";
break;
case OutputOffsetProfile::OutputType::HdmiAudioPassthrough:
return "HDMI Passthrgh";
break;
default:
throw "Attempting to get OutputTypeNameFileSafe for an OutputType that has not been handled.";
}
}

OutputOffsetProfile::OutputOffsetProfile(OutputType type, std::string name, OutputOffset(*getOffsetFunc)(int numChannels, int sampleRate, int bitDepth), bool (*formatFilter)(WAVEFORMATEX*))
: OutType(type), Name(name), GetOffset(getOffsetFunc), FormatFilter(formatFilter), Image(AVLTexture()), isNoOffset(false), isCurrentWindowsAudioFormat(false)
{
Expand Down
1 change: 1 addition & 0 deletions Shared-Items/OutputOffsetProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OutputOffsetProfile
};

static std::string OutputTypeName(OutputOffsetProfile::OutputType outputType);
static std::string OutputTypeNameFileSafe(OutputOffsetProfile::OutputType outputType);

OutputOffsetProfile(OutputType type, std::string name, OutputOffset (*getOffsetFunc)(int numChannels, int sampleRate, int bitDepth), bool (*formatFilter)(WAVEFORMATEX*));

Expand Down
2 changes: 1 addition & 1 deletion Shared-Items/TestManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TestManager::TestManager(AudioEndpoint& outputEndpoint, const AudioEndpoint& inputEndpoint, std::vector<AudioFormat*> selectedFormats, std::string fileString, std::string appDirectory, IResultsWriter& resultsWriter, OutputOffsetProfile* currentProfile, DacLatencyProfile* referenceDacLatency)
: outputEndpoint(outputEndpoint), inputEndpoint(inputEndpoint), SelectedFormats(selectedFormats), AppDirectory(appDirectory), resultsWriter(resultsWriter), Time(time(0)), outputOffsetProfile(currentProfile), referenceDacLatency(referenceDacLatency)
{
TestFileString = std::format("{} {}", StringHelper::GetTimeString(Time, true), fileString);
TestFileString = std::format("{}~{}~{}", StringHelper::GetTimeString(Time, true), OutputOffsetProfile::OutputTypeNameFileSafe(currentProfile->OutType) , fileString);

// Removes all spaces from the beginning of the string
while (TestFileString.size() > 0 && isspace(TestFileString.front()))
Expand Down

0 comments on commit aec32ca

Please sign in to comment.