audio-io sync branch of tizen_2.4
[platform/core/api/audio-io.git] / include / audio_io_private.h
1 /*
2 * Copyright (c) 2011 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_MEDIA_AUDIO_IO_PRIVATE_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_PRIVATE_H__
19 #include <sound_manager.h>
20 #include <mm_sound.h>
21 #include "audio_io.h"
22
23 /*
24 * Internal Macros
25 */
26
27 #define AUDIO_IO_INTERRUPTED_BY_RESUMABLE_MEDIA       (AUDIO_IO_INTERRUPTED_BY_NOTIFICATION + 1)
28 #define AUDIO_IO_INTERRUPTED_BY_RESUMABLE_CANCELED    (AUDIO_IO_INTERRUPTED_BY_NOTIFICATION + 2)
29
30 #define AUDIO_IO_CHECK_CONDITION(condition,error,msg)   \
31                 if(condition) {} else \
32                 { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \
33
34 #define AUDIO_IO_NULL_ARG_CHECK(arg)    \
35         AUDIO_IO_CHECK_CONDITION(arg != NULL, AUDIO_IO_ERROR_INVALID_PARAMETER, "AUDIO_IO_ERROR_INVALID_PARAMETER" )
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 typedef struct _audio_in_s{
42         MMSoundPcmHandle_t mm_handle;
43         int is_async;
44         int is_loopback;
45         int _buffer_size;
46         int _sample_rate;
47         audio_channel_e _channel;
48         audio_sample_type_e _type;
49         audio_io_interrupted_cb user_cb;
50         void* user_data;
51         audio_in_stream_cb stream_cb;
52         void* stream_userdata;
53 } audio_in_s;
54
55 typedef struct _audio_out_s{
56         MMSoundPcmHandle_t mm_handle;
57         int is_async;
58         int is_loopback;
59         int _buffer_size;
60         int _sample_rate;
61         audio_channel_e _channel;
62         audio_sample_type_e _type;
63         sound_type_e    _sound_type;
64         audio_io_interrupted_cb user_cb;
65         void* user_data;
66         audio_out_stream_cb stream_cb;
67         void* stream_userdata;
68 } audio_out_s;
69
70 int __convert_audio_io_error_code(int code, char *func_name);
71 int __check_parameter(int sample_rate, audio_channel_e channel, audio_sample_type_e type);
72 int __mm_sound_pcm_capture_msg_cb (int message, void *param, void *user_param);
73 audio_io_interrupted_code_e __translate_interrupted_code (int code);
74
75 int audio_in_create_private(int sample_rate, audio_channel_e channel, audio_sample_type_e type , int source_type, audio_in_h* input);
76
77 int audio_in_set_callback_private(audio_in_h input, audio_in_stream_cb callback, void* userdata);
78
79 int audio_out_create_private(int sample_rate, audio_channel_e channel, audio_sample_type_e type, sound_type_e sound_type, audio_out_h* output);
80
81 int audio_out_set_callback_private(audio_out_h output, audio_out_stream_cb callback, void* userdata);
82
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif //__TIZEN_MEDIA_AUDIO_IO_PRIVATE_H__