• Home
  • History
  • Annotate
  • 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 <UniquePtr.h>
20 #include <tinyalsa/asoundlib.h>
21 #include <Log.h>
22 #include <audio/AudioHardware.h>
23 
24 class MixerTest : public testing::Test {
25 public:
26 
SetUp()27     virtual void SetUp() {
28 
29     }
30 
TearDown()31     virtual void TearDown() {
32 
33     }
34 };
35 
36 
TEST_F(MixerTest,tryTinyAlsaTest)37 TEST_F(MixerTest, tryTinyAlsaTest) {
38     int hwId = AudioHardware::detectAudioHw();
39     ASSERT_TRUE(hwId >= 0);
40     struct mixer* mixerp = mixer_open(hwId);
41     ASSERT_TRUE(mixerp != NULL);
42     int num_ctls = mixer_get_num_ctls(mixerp);
43     LOGI("Number of mixel control %d", num_ctls);
44     for (int i = 0; i < num_ctls; i++) {
45         struct mixer_ctl* control = mixer_get_ctl(mixerp, i);
46         ASSERT_TRUE(control != NULL);
47         LOGI("Mixer control %s type %s value %d", mixer_ctl_get_name(control),
48                 mixer_ctl_get_type_string(control), mixer_ctl_get_num_values(control));
49         free(control);
50     }
51     // no mixer control for MobilePre. If this assumption fails,
52     // mixer control should be added.
53     ASSERT_TRUE(num_ctls == 0);
54     mixer_close(mixerp);
55 }
56 
57