summaryrefslogtreecommitdiff
path: root/include/avsys-audio-handle.h
blob: 4e9b1e1f00a027a5a71696049b083993a18c7c0b (plain)
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
/*
 * avsystem
 *
 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
 *
 * 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 __AVSYS_AUDIO_HANDLE_H__
#define __AVSYS_AUDIO_HANDLE_H__

#include <pthread.h>
#include "avsys-audio-logical-volume.h"

#define AVSYS_AUDIO_HANDLE_MAX 64 /* this is related with allocated bit size in avsys_audio_handle_info_t*/
#define AVSYS_AUDIO_LOCK_SLOT_MAX 4

enum {
	AVSYS_AUDIO_PRIMARY_VOLUME_CLEAR = 0,
	AVSYS_AUDIO_PRIMARY_VOLUME_SET
};

enum {
	AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_0 = 0,	/**< normal */
	AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_1,		/**< solo */
	AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_2,		/**< solo with transition effect */
	AVSYS_AUDIO_HANDLE_PRIORITY_TYPE_MAX,
};

enum {
	AVSYS_AUDIO_HANDLE_EXT_DEV_NONE		= 0x00000000,
	AVSYS_AUDIO_HANDLE_EXT_DEV_FMRADIO	= 0x00000001,
};

typedef struct {
	/* common base */
	int mode;
	int channels;
	int mute;
	int format;
	int samplerate;
	int period;
	int msec_per_period;
	int pid;
	int tid;
	int priority;

	/* logical volume */
	avsys_audio_volume_setting_t gain_setting;
	avsys_audio_volume_t setting_vol;
	avsys_audio_volume_t working_vol;
	int fadeup_vol;
	int fadeup_multiplier;
	char dirty_volume;

	/* routing information */
	char during_cp_audio;/* if this value set 1, this handle created during cp audio status (means call) */
	char path_off;
	int	stream_index;
	int handle_route;

	/* backend specific */
	void	*device;
} avsys_audio_handle_t;

typedef struct {
	long long int allocated;
	int handle_amp; /* 1 for unmute, 0 for mute per each handle*/
	int ext_device_amp;
	int ext_device_status;
	int volume_value[AVSYS_AUDIO_VOLUME_TYPE_MAX];
	int primary_volume_type;
	pid_t primary_volume_pid;
	char handle_priority[AVSYS_AUDIO_HANDLE_MAX];
	pid_t handlelock_pid[AVSYS_AUDIO_LOCK_SLOT_MAX];
	avsys_audio_handle_t handles[AVSYS_AUDIO_HANDLE_MAX];
} avsys_audio_handle_info_t;

enum {
	HANDLE_PTR_MODE_NORMAL,
	HANDLE_PTR_MODE_FAST,
	HANDLE_PTR_MODE_NUM,
};

int avsys_audio_handle_init(void);
int avsys_audio_handle_fini(void);
int avsys_audio_handle_reset(int *volume_value);
int avsys_audio_handle_dump(void);
int avsys_audio_handle_rejuvenation(void);
int avsys_audio_handle_alloc(int *handle);
int avsys_audio_handle_alloc_unlocked(int *handle);
int avsys_audio_handle_free(int handle);
int avsys_audio_handle_get_ptr(int handle, avsys_audio_handle_t **ptr, const int mode);
int avsys_audio_handle_get_ptr_unlocked(int handle, avsys_audio_handle_t **ptr, const int mode);
int avsys_audio_handle_release_ptr(int handle, const int mode);
int avsys_audio_handle_set_mute(int handle, int mute);
int avsys_audio_handle_ext_dev_set_mute(avsysaudio_ext_device_t device_type, int mute);
int avsys_audio_handle_ext_dev_status(avsysaudio_ext_device_t device_type, int *onoff);
int avsys_audio_handle_ext_dev_status_update(avsysaudio_ext_device_t device_type, int onoff);
int avsys_audio_handle_current_playing_volume_type(int *type);
int avsys_audio_handle_update_volume(avsys_audio_handle_t *p, const int volume_config);
int avsys_audio_handle_update_volume_by_type(const int volume_type, const int volume_value);
int avsys_audio_handle_set_primary_volume_type(const int pid, const int type, const int command);
int avsys_audio_handle_update_priority(int handle, int priority, int handle_route, int cmd);
int avsys_audio_handle_current_capture_status(int *on_capture);
#endif /* __AVSYS_AUDIO_HANDLE_H__ */