-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaudio_config.h
145 lines (119 loc) · 4.48 KB
/
audio_config.h
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (C) 2012-2013 Wolfson Microelectronics plc
*
* 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.
*/
#ifndef AUDIO_CONFIG_H
#define AUDIO_CONFIG_H
#include <stddef.h>
#include <system/audio.h>
struct mixer_ctl;
struct config_mgr;
struct audio_config;
/** Stream type */
enum stream_type {
e_stream_out_pcm,
e_stream_in_pcm,
e_stream_out_compress,
e_stream_in_compress,
e_stream_hardware /* unspecified type routed in hardware */
};
/** Information about a stream */
struct hw_stream {
enum stream_type type : 8;
uint8_t card_number;
uint8_t device_number;
unsigned int rate;
unsigned int period_size;
unsigned int period_count;
};
/** Test whether a stream is an input */
static inline bool stream_is_input( const struct hw_stream *stream )
{
return (stream->type == e_stream_in_pcm)
|| (stream->type == e_stream_in_compress);
}
/** Test whether a stream is PCM */
static inline bool stream_is_pcm( const struct hw_stream *stream )
{
return (stream->type == e_stream_out_pcm)
|| (stream->type == e_stream_in_pcm);
}
/** Test whether a stream is compressed */
static inline bool stream_is_compressed( const struct hw_stream *stream )
{
return (stream->type == e_stream_out_compress)
|| (stream->type == e_stream_in_compress);
}
/** Test whether stream is PCM output */
static inline bool stream_is_pcm_out( const struct hw_stream *stream )
{
return (stream->type == e_stream_out_pcm);
}
/** Test whether stream is PCM input */
static inline bool stream_is_pcm_in( const struct hw_stream *stream )
{
return (stream->type == e_stream_in_pcm);
}
/** Test whether stream is compressed output */
static inline bool stream_is_compressed_out( const struct hw_stream *stream )
{
return (stream->type == e_stream_out_compress);
}
/** Test whether stream is compressed input */
static inline bool stream_is_compressed_in( const struct hw_stream *stream )
{
return (stream->type == e_stream_in_compress);
}
/** Test whether stream is a hardware link */
static inline bool stream_is_hardware( const struct hw_stream *stream )
{
return (stream->type == e_stream_hardware);
}
/** Initialize audio config layer */
struct config_mgr *init_audio_config();
/** Delete audio config layer */
void free_audio_config( struct config_mgr *cm );
/** Get list of all supported devices */
uint32_t get_supported_devices( struct config_mgr *cm );
/** Find a suitable stream and return pointer to it */
const struct hw_stream *get_stream( struct config_mgr *cm,
const audio_devices_t devices,
const audio_output_flags_t flags,
const struct audio_config *config );
/** Find a named custom stream and return a pointer to it */
const struct hw_stream *get_named_stream(struct config_mgr *cm,
const char *name);
/** Test whether a named custom stream is defined */
bool is_named_stream_defined(struct config_mgr *cm, const char *name);
/** Release stream */
void release_stream( const struct hw_stream *stream );
/** Get currently connected routes */
uint32_t get_current_routes( const struct hw_stream *stream );
/** Apply new device routing to a stream */
void apply_route( const struct hw_stream *stream, uint32_t devices );
/** Get bitmask of devices currently connected to this stream */
uint32_t get_routed_devices( const struct hw_stream *stream );
/** Adjust routing for all streams that alter with orentiation */
void rotate_routes( struct config_mgr *cm, int orientation );
/** Apply hardware volume */
int set_hw_volume( const struct hw_stream *stream, int left_pc, int right_pc);
/** Apply a custom use-case
*
* @return 0 on success
* @return -ENOSYS if the usecase not declared
*/
int apply_use_case( const struct hw_stream* stream,
const char *setting,
const char *case_name);
#endif /* ifndef AUDIO_CONFIG_H */