Skip to content

Commit

Permalink
Switch PipelineIntegrationTests to more permissive audio hash.
Browse files Browse the repository at this point in the history
We already use more permissive hashing in AudioDecoderTest, so
switch to it for PipelineIntegrationTest as well. This allows us
to avoid maintaining hashes per ARM, X86, fixed point, etc.

I've also rolled in a some constexpr changes and removed a few
unnecessary macros for EXPECT_EQ

Bug: 570762
Change-Id: I558802757f85c9003513e2d79184a64e93868f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4424780
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1130631}
  • Loading branch information
dalecurtis authored and Chromium LUCI CQ committed Apr 14, 2023
1 parent e433afa commit d7ed4b5
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 143 deletions.
9 changes: 4 additions & 5 deletions media/audio/clockless_audio_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/task/single_thread_task_runner.h"
#include "base/threading/simple_thread.h"
#include "media/base/audio_glitch_info.h"
#include "media/base/audio_hash.h"

namespace media {

Expand Down Expand Up @@ -48,9 +47,9 @@ class ClocklessAudioSinkThread : public base::DelegateSimpleThread::Delegate {
return playback_time_;
}

std::string GetAudioHash() {
const AudioHash& GetAudioHash() const {
DCHECK(audio_hash_);
return audio_hash_->ToString();
return *audio_hash_;
}

private:
Expand Down Expand Up @@ -164,8 +163,8 @@ void ClocklessAudioSink::StartAudioHashForTesting() {
hashing_ = true;
}

std::string ClocklessAudioSink::GetAudioHashForTesting() {
return thread_ && hashing_ ? thread_->GetAudioHash() : std::string();
const AudioHash& ClocklessAudioSink::GetAudioHashForTesting() const {
return thread_->GetAudioHash();
}

void ClocklessAudioSink::SetIsOptimizedForHardwareParametersForTesting(
Expand Down
3 changes: 2 additions & 1 deletion media/audio/clockless_audio_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>

#include "base/time/time.h"
#include "media/base/audio_hash.h"
#include "media/base/audio_renderer_sink.h"

namespace media {
Expand Down Expand Up @@ -45,7 +46,7 @@ class MEDIA_EXPORT ClocklessAudioSink : public AudioRendererSink {
void StartAudioHashForTesting();

// Returns the hash of all audio frames seen since construction.
std::string GetAudioHashForTesting();
const AudioHash& GetAudioHashForTesting() const;

void SetIsOptimizedForHardwareParametersForTesting(bool value);

Expand Down
4 changes: 2 additions & 2 deletions media/audio/null_audio_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void NullAudioSink::StartAudioHashForTesting() {
audio_hash_ = std::make_unique<AudioHash>();
}

std::string NullAudioSink::GetAudioHashForTesting() {
return audio_hash_ ? audio_hash_->ToString() : std::string();
const AudioHash& NullAudioSink::GetAudioHashForTesting() const {
return *audio_hash_;
}

} // namespace media
2 changes: 1 addition & 1 deletion media/audio/null_audio_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MEDIA_EXPORT NullAudioSink : public SwitchableAudioRendererSink {
void StartAudioHashForTesting();

// Returns the hash of all audio frames seen since construction.
std::string GetAudioHashForTesting();
const AudioHash& GetAudioHashForTesting() const;

protected:
~NullAudioSink() override;
Expand Down
6 changes: 0 additions & 6 deletions media/filters/audio_decoder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,9 @@ constexpr TestParams kFFmpegTestParams[] = {
{AudioCodec::kOpus,
"sfx-opus.ogg",
{{
#if defined(OPUS_FIXED_POINT)
{0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
{13500, 20000, "5.48,5.93,6.05,5.83,5.54,5.46,"},
{33500, 20000, "-3.44,-3.34,-3.57,-4.11,-4.74,-5.13,"},
#else
{0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
{13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"},
{33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"},
#endif
}},
-312,
48000,
Expand Down
2 changes: 1 addition & 1 deletion media/remoting/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST_F(MediaRemotingIntegrationTest, BasicPlayback) {
ASSERT_TRUE(WaitUntilOnEnded());

EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash().ToString());
}

TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) {
Expand Down
Loading

0 comments on commit d7ed4b5

Please sign in to comment.