-
-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(audio): custom surround-params #2424
Merged
ReenigneArcher
merged 4 commits into
LizardByte:master
from
mariotaku:feature/custom-surround-params
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* @file tests/test_audio.cpp | ||
* @brief Test src/audio.*. | ||
*/ | ||
#include <bitset> | ||
#include <src/audio.h> | ||
|
||
#include <tests/conftest.cpp> | ||
|
||
using namespace audio; | ||
|
||
class AudioTest: public virtual BaseTest, public PlatformInitBase, public ::testing::WithParamInterface<std::tuple<std::basic_string_view<char>, config_t>> { | ||
protected: | ||
void | ||
SetUp() override { | ||
BaseTest::SetUp(); | ||
PlatformInitBase::SetUp(); | ||
|
||
std::string_view p_name = std::get<0>(GetParam()); | ||
std::cout << "AudioTest(" << p_name << "):: starting Fixture SetUp" << std::endl; | ||
|
||
m_config = std::get<1>(GetParam()); | ||
m_mail = std::make_shared<safe::mail_raw_t>(); | ||
} | ||
|
||
void | ||
TearDown() override { | ||
PlatformInitBase::TearDown(); | ||
BaseTest::TearDown(); | ||
} | ||
|
||
protected: | ||
config_t m_config; | ||
safe::mail_t m_mail; | ||
}; | ||
|
||
static std::bitset<config_t::MAX_FLAGS> | ||
config_flags(int flag = -1) { | ||
std::bitset<3> result = std::bitset<config_t::MAX_FLAGS>(); | ||
if (flag >= 0) { | ||
result.set(flag); | ||
} | ||
return result; | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
Configurations, | ||
AudioTest, | ||
::testing::Values( | ||
std::make_tuple("HIGH_STEREO", config_t { 5, 2, 0x3, { 0 }, config_flags(config_t::HIGH_QUALITY) }), | ||
std::make_tuple("SURROUND51", config_t { 5, 6, 0x3F, { 0 }, config_flags() }), | ||
std::make_tuple("SURROUND71", config_t { 5, 8, 0x63F, { 0 }, config_flags() }), | ||
std::make_tuple("SURROUND51_CUSTOM", config_t { 5, 6, 0x3F, { 6, 4, 2, { 0, 1, 4, 5, 2, 3 } }, config_flags(config_t::CUSTOM_SURROUND_PARAMS) }))); | ||
|
||
TEST_P(AudioTest, TestEncode) { | ||
std::thread timer([&] { | ||
// Terminate the audio capture after 5 seconds. | ||
std::this_thread::sleep_for(5s); | ||
auto shutdown_event = m_mail->event<bool>(mail::shutdown); | ||
auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets); | ||
shutdown_event->raise(true); | ||
audio_packets->stop(); | ||
}); | ||
std::thread capture([&] { | ||
auto packets = m_mail->queue<packet_t>(mail::audio_packets); | ||
auto shutdown_event = m_mail->event<bool>(mail::shutdown); | ||
while (auto packet = packets->pop()) { | ||
if (shutdown_event->peek()) { | ||
break; | ||
} | ||
auto packet_data = packet->second; | ||
if (packet_data.size() == 0) { | ||
FAIL() << "Empty packet data"; | ||
} | ||
} | ||
}); | ||
audio::capture(m_mail, m_config, nullptr); | ||
|
||
timer.join(); | ||
capture.join(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of advertising them twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first
surround-params
will be applied toNormalQualityOpusConfig
, and the second one goes toHighQualityOpusConfig
. I think advertising them twice first will make sure both configs having the desired mapping.