• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "audio_validation.h"
18 
19 #ifndef LOG_TAG
20 #define LOG_TAG "[TestShared]"
21 #endif
22 
23 namespace chre {
24 namespace test_shared {
25 
checkAudioSamplesAllZeros(const int16_t * data,const size_t dataLen)26 bool checkAudioSamplesAllZeros(const int16_t *data, const size_t dataLen) {
27   for (size_t i = 0; i < dataLen; ++i) {
28     if (data[i] != 0) {
29       return true;
30     }
31   }
32   return false;
33 }
34 
checkAudioSamplesAllSame(const int16_t * data,const size_t dataLen)35 bool checkAudioSamplesAllSame(const int16_t *data, const size_t dataLen) {
36   if (dataLen > 0) {
37     const int16_t controlValue = data[0];
38     for (size_t i = 1; i < dataLen; ++i) {
39       if (data[i] != controlValue) {
40         return true;
41       }
42     }
43   }
44   return false;
45 }
46 
47 }  // namespace test_shared
48 }  // namespace chre
49