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
|
/*
* audio-hal
*
* Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* 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.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "tizen-audio-internal.h"
static audio_return_e __set_message_callback(audio_hal_s *ah, message_cb callback, void *user_data)
{
audio_return_e audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(callback, AUDIO_ERR_PARAMETER);
ah->comm.msg_cb = callback;
ah->comm.user_data = user_data;
AUDIO_LOG_DEBUG("message callback is set, callback(%p), user_data(%p)", ah->comm.msg_cb, ah->comm.user_data);
return audio_ret;
}
static audio_return_e __unset_message_callback(audio_hal_s *ah)
{
audio_return_e audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
ah->comm.msg_cb = NULL;
ah->comm.user_data = NULL;
AUDIO_LOG_DEBUG("message callback is unset");
return audio_ret;
}
audio_return_e _audio_comm_init(audio_hal_s *ah)
{
audio_return_e audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
ah->comm.msg_cb = NULL;
ah->comm.user_data = NULL;
return audio_ret;
}
audio_return_e _audio_comm_deinit(audio_hal_s *ah)
{
audio_return_e audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
ah->comm.msg_cb = NULL;
ah->comm.user_data = NULL;
return audio_ret;
}
audio_return_e _audio_comm_send_message(audio_hal_s *ah, const char *name, int value)
{
audio_return_e audio_ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(name, AUDIO_ERR_PARAMETER);
AUDIO_LOG_DEBUG("send message : name(%s), value(%d)", name, value);
if (ah->comm.msg_cb)
ah->comm.msg_cb(name, value, ah->comm.user_data);
return audio_ret;
}
audio_return_e audio_add_message_cb(void *audio_handle, message_cb callback, void *user_data)
{
audio_return_e ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(audio_handle, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(callback, AUDIO_ERR_PARAMETER);
/* NOTE: Management of several callbacks could be implemented.
But we do not care of it for now.*/
ret = __set_message_callback((audio_hal_s *)audio_handle, callback, user_data);
return ret;
}
audio_return_e audio_remove_message_cb(void *audio_handle, message_cb callback)
{
audio_return_e ret = AUDIO_RET_OK;
AUDIO_RETURN_VAL_IF_FAIL(audio_handle, AUDIO_ERR_PARAMETER);
AUDIO_RETURN_VAL_IF_FAIL(callback, AUDIO_ERR_PARAMETER);
ret = __unset_message_callback((audio_hal_s *)audio_handle);
return ret;
}
|