aboutsummaryrefslogtreecommitdiffstats
path: root/src/audiomanager_proxy.h
blob: e0c6b3d4d277ab50a241065af3150cf0fc0cf350 (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
/*
 * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
 *
 * 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_MANAGER_PROXY_H
#define AUDIO_MANAGER_PROXY_H
#include <glib.h>
#include <stdbool.h>
#include "sm-def.h"

typedef struct audiomanager_event{
    void (*on_new_main_connection)(void* closure, int connection, int source, int sink, int delay, int connection_state);
    void (*on_removed_main_connection)(void* closure, int connection);
    void (*on_main_connection_state_changed)(void* closure, int connection, int connection_state);
    void (*on_volume_changed)(void* closure, int sink, int volume);
    void (*on_sink_mute_state_changed)(void* closure, int sink, int mute);
    void (*on_set_routing_ready)(void* closure);
    void (*on_set_routing_rundown)(void* closure);
} am_event;

typedef struct audiomanager_instruction{
    void (*on_async_abort)(void* closure, int handle);
    void (*on_async_connect)(void* closure, int handle, int connection, int source, int sink, int connection_format);
    void (*on_async_disconnect)(void* closure, int handle, int connection);
    void (*on_async_set_sink_volume)(void* closure, int handle, int sink, int volume, int ramp, int time);
    void (*on_async_set_source_state)(void* closure, int handle, int source, int source_state);
} am_instruction;

struct domain_data{
    int     domainID;
    char*   name;
    char*   busname;
    char*   nodename;
    bool    early;
    bool    complete;
    int     state;
};

struct sound_property_s{
    int type;
    int value;
};
struct availability_s{
    int availability;
    int avalilable_reason;
};
struct notification_config_s{
    int type;
    int status;
    int parameter;
};
struct main_sound_property_s{
    int type;    /* am_CustomMainSoundPropertyType_t */
    int value;
};

ErrorCode am_proxy_connect(int source, int sink, int *main_connection_id);
ErrorCode am_proxy_disconnect(int main_connection_id);
ErrorCode am_proxy_set_volume(int sink, int volume);
ErrorCode am_proxy_volume_step(int sink, int volume);
ErrorCode am_proxy_set_sink_mute_state(int sink, int mute_state);
ErrorCode am_proxy_get_list_main_connections(GVariant* connection_list);
ErrorCode am_proxy_get_list_main_sources(GVariant* source_list);
ErrorCode am_proxy_get_list_main_sinks(GVariant* sink_list);
ErrorCode am_proxy_ack_connect(int handle, int connection_id, int usr_err);
ErrorCode am_proxy_ack_disconnect(int handle, int connection_id, int usr_err);
ErrorCode am_proxy_ack_set_source_state(int handle, int usr_err);
ErrorCode am_proxy_register_source(GVariant *source_data, int *source);
ErrorCode am_proxy_deregister_source(int source);
ErrorCode am_proxy_register_domain(GVariant* domain_data, int *domain);

GVariant* create_domain_data(struct domain_data* domain);
GVariant* create_source_data(int sourceID, int domainID, const char* appname, int sourceClassID,
    int  sourceState, int volume, bool visible, struct availability_s availables,
    int interrupt,  struct sound_property_s soundPropertyList, int connectionFormatList,
    struct main_sound_property_s mainPropertyList, struct notification_config_s NConfRouting,
    struct notification_config_s NConfCommand);

ErrorCode initialize_proxy();
void set_event_callback(const am_event *callback);
void close_proxy();
ErrorCode open_soundmanager_interface(const am_instruction *callback);
void close_soundmanager_inerface();

#endif //AUDIO_MANAGER_PROXY_H