FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oboe/tests/testStreamFramesProcessed.cpp at main · google/oboe · GitHub
google
/
oboe
Public
Notifications
You must be signed in to change notification settings
Fork
640
Star
4.1k
Code
Issues
153
Pull requests
6
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
oboe
/
tests
/
testStreamFramesProcessed.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
99 lines (83 loc) · 3.94 KB
Breadcrumbs
oboe
/
tests
/
testStreamFramesProcessed.cpp
Copy path
File metadata and controls
99 lines (83 loc) · 3.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#
include
<
gtest/gtest.h
>
#
include
<
oboe/Oboe.h
>
#
include
<
tuple
>
using
namespace
oboe
;
class
FramesProcessedCallback
:
public
AudioStreamDataCallback
{
public:
DataCallbackResult
onAudioReady
(AudioStream *oboeStream,
void
*audioData,
int32_t
numFrames)
override
{
return
DataCallbackResult::Continue;
}
};
using
StreamFramesProcessedParams = std::tuple<Direction,
int32_t
,
bool
>;
class
StreamFramesProcessed
: public ::testing::Test,
public ::testing::WithParamInterface<StreamFramesProcessedParams> {
protected:
void
TearDown
()
override
;
static
constexpr
int
PROCESS_TIME_SECONDS
=
5
;
AudioStreamBuilder
mBuilder
;
std::shared_ptr<AudioStream>
mStream
;
};
void
StreamFramesProcessed::TearDown
() {
if
(
mStream
) {
mStream
->
close
();
}
}
TEST_P
(StreamFramesProcessed, VerifyFramesProcessed) {
const
Direction direction = std::get<
0
>(
GetParam
());
const
int32_t
sampleRate = std::get<
1
>(
GetParam
());
const
bool
useOboeSampleRateConversion = std::get<
2
>(
GetParam
());
SampleRateConversionQuality srcQuality = useOboeSampleRateConversion ?
SampleRateConversionQuality::Medium : SampleRateConversionQuality::None;
AudioStreamDataCallback *callback =
new
FramesProcessedCallback
();
mBuilder
.
setDirection
(direction)
->
setFormat
(AudioFormat::
I16
)
->
setSampleRate
(sampleRate)
->
setSampleRateConversionQuality
(srcQuality)
->
setPerformanceMode
(PerformanceMode::LowLatency)
->
setSharingMode
(SharingMode::Exclusive)
->
setDataCallback
(callback);
Result r =
mBuilder
.
openStream
(
mStream
);
ASSERT_EQ
(r, Result::
OK
) <<
"
Failed to open stream.
"
<<
convertToText
(r);
r =
mStream
->
start
();
ASSERT_EQ
(r, Result::
OK
) <<
"
Failed to start stream.
"
<<
convertToText
(r);
sleep
(
PROCESS_TIME_SECONDS
);
//
The frames written should be close to sampleRate * PROCESS_TIME_SECONDS
const
int
kDeltaFramesWindowInFrames
=
30000
;
const
int64_t
framesWritten =
mStream
->
getFramesWritten
();
const
int64_t
framesRead =
mStream
->
getFramesRead
();
EXPECT_NEAR
(framesWritten, sampleRate *
PROCESS_TIME_SECONDS
,
kDeltaFramesWindowInFrames
);
EXPECT_NEAR
(framesRead, sampleRate *
PROCESS_TIME_SECONDS
,
kDeltaFramesWindowInFrames
);
}
INSTANTIATE_TEST_CASE_P
(
StreamFramesProcessedTest,
StreamFramesProcessed,
::testing::Values
(
StreamFramesProcessedParams
({Direction::Output,
8000
,
true
}),
StreamFramesProcessedParams({Direction::Output,
44100
,
true
}),
StreamFramesProcessedParams({Direction::Output,
96000
,
true
}),
StreamFramesProcessedParams({Direction::Input,
8000
,
true
}),
StreamFramesProcessedParams({Direction::Input,
44100
,
true
}),
StreamFramesProcessedParams({Direction::Input,
96000
,
true
}),
StreamFramesProcessedParams({Direction::Output,
8000
,
false
}),
StreamFramesProcessedParams({Direction::Output,
44100
,
false
}),
StreamFramesProcessedParams({Direction::Output,
96000
,
false
}),
StreamFramesProcessedParams({Direction::Input,
8000
,
false
}),
StreamFramesProcessedParams({Direction::Input,
44100
,
false
}),
StreamFramesProcessedParams({Direction::Input,
96000
,
false
})
)
);
Back
|
FazBrowse Home
|
New Git URL