9b015d3e6af7a97867fc1f49f64b956997a1e88a
[platform/core/api/sound-pool.git] / include / internal / soundpool.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_SOUNDPOOL_INTERNAL_SOUNDPOOL_H__
18 #define __TIZEN_SOUNDPOOL_INTERNAL_SOUNDPOOL_H__
19
20 #include "sound_pool_type.h"
21 #include "sound_pool_private.h"
22
23 #include <glib.h>
24 #include <AL/al.h>
25 #include <AL/alc.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 typedef struct stream_cb_manager_s stream_cb_manager_t;
32 typedef struct stream_priority_manager_s stream_priority_manager_t;
33
34 /**
35  * @brief Sound Pool pool type.
36  *
37  * @since_tizen 3.0
38  */
39 typedef struct sound_pool_s {
40         ALCcontext *al_context;
41         float volume;
42
43         GHashTable *sources;
44         GHashTable *streams;
45
46         guint max_streams;
47         guint max_stream_index;
48         sound_pool_state_e state;
49
50         struct {
51                 sound_pool_state_change_cb callback;
52                 void *user_data;
53         } state_cb_info;
54
55         stream_cb_manager_t *cbmgr;
56         stream_priority_manager_t *mgr_priority;
57 } sound_pool_t;
58
59 /* Max amount of sound pools which could be created. */
60 #define SOUND_POOL_MAX_POOLS_AMOUNT 32U
61
62 sound_pool_error_e _sound_pool_create(size_t max_streams, sound_pool_t **pool);
63
64 sound_pool_error_e _sound_pool_destroy(sound_pool_t *pool);
65
66 sound_pool_error_e _sound_pool_activate(sound_pool_t *pool);
67
68 sound_pool_error_e _sound_pool_deactivate(sound_pool_t *pool);
69
70 sound_pool_error_e _sound_pool_get_state(sound_pool_t *pool, sound_pool_state_e *state);
71
72 sound_pool_error_e _sound_pool_set_volume(sound_pool_t *pool, float volume);
73
74 sound_pool_error_e _sound_pool_get_volume(sound_pool_t *pool, float *volume);
75
76 sound_pool_error_e _sound_pool_set_callback(sound_pool_t *pool,
77                 sound_pool_state_change_cb callback, void *data);
78
79 sound_pool_error_e _sound_pool_unset_callback(sound_pool_t *pool);
80
81 #ifdef __cplusplus
82 }
83 #endif /* __cplusplus */
84
85 #endif /* __TIZEN_SOUNDPOOL_INTERNAL_SOUNDPOOL_H__ */