• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 #include <stdint.h>
17 #include <gtest/gtest.h>
18 
19 #include <tinyalsa/asoundlib.h>
20 #include <Log.h>
21 #include <audio/AudioHardware.h>
22 
23 class MixerTest : public testing::Test {
24 public:
25 
SetUp()26     virtual void SetUp() {
27 
28     }
29 
TearDown()30     virtual void TearDown() {
31 
32     }
33 };
34 
35 
TEST_F(MixerTest,tryTinyAlsaTest)36 TEST_F(MixerTest, tryTinyAlsaTest) {
37     int hwId = AudioHardware::detectAudioHw();
38     ASSERT_TRUE(hwId >= 0);
39     struct mixer* mixerp = mixer_open(hwId);
40     ASSERT_TRUE(mixerp != NULL);
41     int num_ctls = mixer_get_num_ctls(mixerp);
42     LOGI("Number of mixel control %d", num_ctls);
43     for (int i = 0; i < num_ctls; i++) {
44         struct mixer_ctl* control = mixer_get_ctl(mixerp, i);
45         ASSERT_TRUE(control != NULL);
46         LOGI("Mixer control %s type %s value %d", mixer_ctl_get_name(control),
47                 mixer_ctl_get_type_string(control), mixer_ctl_get_num_values(control));
48         free(control);
49     }
50     // no mixer control for MobilePre. If this assumption fails,
51     // mixer control should be added.
52     ASSERT_TRUE(num_ctls == 0);
53     mixer_close(mixerp);
54 }
55 
56