Add fix to prevent crash
[platform/core/api/sound-pool.git] / include / internal / stream_cb_manager.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_STREAMCBMANAGER_H__
18 #define __TIZEN_SOUNDPOOL_INTERNAL_STREAMCBMANAGER_H__
19
20 #include "internal/stream.h"
21
22 #include <pthread.h>
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 /**
32  * @brief Stream Callback Manager type.
33  *
34  * @since_tizen 3.0
35  */
36 struct stream_cb_manager_s {
37         sound_pool_t *pool;
38         GAsyncQueue *isolator_callback_queue;
39
40         pthread_t isolator_thread;
41         pthread_mutex_t isolator_data_mutex;
42         pthread_cond_t isolator_data_cond;
43         pthread_cond_t isolator_force_run_cond;
44         gboolean isolator_state_changed;
45         gboolean isolator_loop_run;
46         gboolean isolator_force_run;
47 };
48
49 typedef struct stream_cb_manager_event_data_s {
50         sound_stream_t *stream;
51         sound_pool_stream_state_e state;
52         sound_pool_stream_state_e state_previous;
53 } stream_cb_manager_event_data_t;
54
55 sound_pool_error_e _stream_cb_manager_create(sound_pool_t *pool, stream_cb_manager_t **cbmgr);
56
57 sound_pool_error_e _stream_cb_manager_destroy(stream_cb_manager_t *cbmgr);
58
59 sound_pool_error_e _stream_cb_manager_register_event(stream_cb_manager_t *cbmgr,
60                 sound_stream_t *stream);
61
62 sound_pool_error_e _stream_cb_manager_process_pending_events(stream_cb_manager_t *cbmgr);
63
64 sound_pool_error_e _stream_cb_manager_signal_completed_events(stream_cb_manager_t *cbmgr);
65
66 #ifdef __cplusplus
67 }
68 #endif /* __cplusplus */
69
70 #endif /* __TIZEN_SOUNDPOOL_INTERNAL_STREAMCBMANAGER_H__ */