Commit | Line | Data |
---|---|---|
d42e7319 JB |
1 | /* |
2 | * Copyright (c) 2013 Canonical Ltd | |
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 | ||
18 | #include <memory.h> | |
19 | #include <assert.h> | |
20 | #include <stdbool.h> | |
21 | #include <stdio.h> | |
22 | #include <stdlib.h> | |
23 | ||
24 | #include <android/hardware/audio.h> | |
25 | #include <android/hardware/hardware.h> | |
26 | ||
27 | int main(int argc, char **argv) | |
28 | { | |
29 | struct hw_module_t *hwmod = 0; | |
30 | struct audio_hw_device *audiohw; | |
31 | ||
32 | hw_get_module_by_class(AUDIO_HARDWARE_MODULE_ID, | |
33 | AUDIO_HARDWARE_MODULE_ID_PRIMARY, | |
34 | (const hw_module_t**) &hwmod); | |
35 | assert(hwmod != NULL); | |
36 | ||
37 | assert(audio_hw_device_open(hwmod, &audiohw) == 0); | |
38 | assert(audiohw->init_check(audiohw) == 0); | |
39 | printf("Audio Hardware Interface initialized.\n"); | |
40 | ||
41 | if (audiohw->get_master_volume) { | |
42 | float volume; | |
43 | audiohw->get_master_volume(audiohw, &volume); | |
44 | printf("Master Volume: %f\n", volume); | |
45 | } | |
46 | ||
47 | if (audiohw->get_master_mute) { | |
48 | bool mute; | |
49 | audiohw->get_master_mute(audiohw, &mute); | |
50 | printf("Master Mute: %d\n", mute); | |
51 | } | |
52 | ||
53 | audio_hw_device_close(audiohw); | |
54 | ||
55 | return 0; | |
56 | } | |
57 | ||
58 | // vim:ts=4:sw=4:noexpandtab |