Modify stream stop API to prevent segfault
[platform/core/api/sound-pool.git] / include / internal / stream.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_STREAM_H__
18 #define __TIZEN_SOUNDPOOL_INTERNAL_STREAM_H__
19
20
21 #include "sound_pool_private.h"
22 #include "internal/source.h"
23
24 #include <glib.h>
25 #include <AL/al.h>
26 #include <AL/alc.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * @brief Sound Pool stream type.
34  *
35  * @since_tizen 3.0
36  */
37 typedef struct sound_stream_s {
38         unsigned id;
39         sound_source_t *parent_source;
40
41         unsigned priority;
42         unsigned loop;
43         float volume;
44
45         sound_pool_stream_priority_policy_e priority_policy;
46         sound_pool_stream_state_e state;
47         sound_pool_stream_state_e state_previous;
48         gboolean stopped;
49         gboolean mute;
50         gboolean suspended;
51
52         struct {
53                 sound_pool_stream_state_changed_cb callback;
54                 void *user_data;
55         } state_cb_info;
56
57         ALuint al_source;
58 } sound_stream_t;
59
60 sound_pool_error_e _sound_stream_create(sound_source_t *src, unsigned loop,
61                 float volume, unsigned priority, sound_pool_stream_priority_policy_e priority_policy,
62                 sound_pool_stream_state_changed_cb cb, void *data, sound_stream_t **stream);
63
64 sound_pool_error_e _sound_stream_destroy(sound_stream_t *src);
65
66 sound_pool_error_e _sound_stream_play(sound_stream_t *stream);
67
68 sound_pool_error_e _sound_stream_pause(sound_stream_t *stream);
69
70 sound_pool_error_e _sound_stream_resume(sound_stream_t *stream);
71
72 sound_pool_error_e  _sound_stream_suspend(sound_stream_t *stream);
73
74 sound_pool_error_e _sound_stream_stop(sound_stream_t *stream);
75
76 sound_pool_error_e _sound_stream_set_loop(sound_stream_t *stream, unsigned loop);
77
78 sound_pool_error_e _sound_stream_set_volume(sound_stream_t *stream, float volume);
79 sound_pool_error_e _sound_stream_get_volume(sound_stream_t *stream, float *volume);
80
81 sound_pool_error_e _sound_stream_set_mute(sound_stream_t *stream, gboolean mute);
82
83 sound_pool_error_e _sound_stream_set_priority(sound_stream_t *stream, unsigned rank);
84 sound_pool_error_e _sound_stream_get_priority(sound_stream_t *stream, unsigned *rank);
85
86 sound_pool_error_e _sound_stream_set_priority_policy(sound_stream_t *stream,
87                 sound_pool_stream_priority_policy_e priority_policy);
88
89 sound_pool_error_e _sound_stream_get_state(sound_stream_t *stream,
90                 sound_pool_stream_state_e *state);
91
92 sound_pool_error_e _sound_stream_set_callback(sound_stream_t *stream,
93                 sound_pool_stream_state_changed_cb callback, void *data);
94
95 sound_pool_error_e _sound_stream_send_event(sound_stream_t *stream,
96                 sound_pool_stream_state_e state);
97
98 sound_pool_error_e _sound_pool_get_stream_by_id(sound_pool_t *pool, unsigned id,
99                 sound_stream_t **stream);
100 #ifdef __cplusplus
101 }
102 #endif /* __cplusplus */
103
104 #endif /* __TIZEN_SOUNDPOOL_INTERNAL_STREAM_H__ */