[Release version 0.10.26] Support tizenipcsrc (patch #2) and remove build warnings
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_sound.h
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_CAMCORDER_SOUND_H__
23 #define __MM_CAMCORDER_SOUND_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <pulse/pulseaudio.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*=======================================================================================
35 | GLOBAL DEFINITIONS AND DECLARATIONS FOR CAMCORDER                                     |
36 ========================================================================================*/
37
38
39 /*=======================================================================================
40 | MACRO DEFINITIONS                                                                     |
41 ========================================================================================*/
42 #define _MMCAMCORDER_FILEPATH_CAPTURE_SND        "/usr/share/sounds/mm-camcorder/capture_shutter_01.wav"
43 #define _MMCAMCORDER_FILEPATH_CAPTURE2_SND       "/usr/share/sounds/mm-camcorder/capture_shutter_02.wav"
44 #define _MMCAMCORDER_FILEPATH_REC_START_SND      "/usr/share/sounds/mm-camcorder/recording_start_01.wav"
45 #define _MMCAMCORDER_FILEPATH_REC_STOP_SND       "/usr/share/sounds/mm-camcorder/recording_stop_01.wav"
46 #define _MMCAMCORDER_SAMPLE_SOUND_NAME_CAPTURE   "camera-shutter"
47 #define _MMCAMCORDER_SAMPLE_SOUND_NAME_REC_STOP  "recording-stop"
48
49 /*=======================================================================================
50 | ENUM DEFINITIONS                                                                      |
51 ========================================================================================*/
52 typedef enum {
53         _MMCAMCORDER_SOUND_STATE_NONE,
54         _MMCAMCORDER_SOUND_STATE_INIT,
55         _MMCAMCORDER_SOUND_STATE_PLAYING,
56 } _MMCamcorderSoundState;
57
58 /*=======================================================================================
59 | STRUCTURE DEFINITIONS                                                                 |
60 ========================================================================================*/
61 /**
62  * Structure of sound info
63  */
64 typedef struct __SOUND_INFO {
65         /* PCM */
66         MMSoundPcmHandle_t handle;
67         int volume_type;
68         unsigned int volume_level;
69
70         /* mutex and cond */
71         pthread_mutex_t play_mutex;
72         pthread_cond_t play_cond;
73         pthread_mutex_t open_mutex;
74         pthread_cond_t open_cond;
75
76         /* pulse audio */
77         pa_threaded_mainloop *pulse_mainloop;
78         pa_context *pulse_context;
79
80 #ifdef _MMCAMCORDER_UPLOAD_SAMPLE
81         /* sound file */
82         SF_INFO sfinfo;
83         SNDFILE *infile;
84         char *filename;
85         pa_stream *sample_stream;
86         pa_sample_spec sample_spec;
87         size_t sample_length;
88         pa_channel_map channel_map;
89 #else /* _MMCAMCORDER_UPLOAD_SAMPLE */
90         pa_stream *sample_stream;
91         pa_sample_spec sample_spec;
92 #endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
93
94         _MMCamcorderSoundState state;
95 } SOUND_INFO;
96
97 /*=======================================================================================
98 | CONSTANT DEFINITIONS                                                                  |
99 ========================================================================================*/
100
101
102 /*=======================================================================================
103 | GLOBAL FUNCTION PROTOTYPES                                                            |
104 ========================================================================================*/
105 #ifdef _MMCAMCORDER_UPLOAD_SAMPLE
106 gboolean _mmcamcorder_sound_init(MMHandleType handle, char *filename);
107 #else /* _MMCAMCORDER_UPLOAD_SAMPLE */
108 gboolean _mmcamcorder_sound_init(MMHandleType handle);
109 #endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
110 gboolean _mmcamcorder_sound_play(MMHandleType handle, const char *sample_name, gboolean sync_play);
111 gboolean _mmcamcorder_sound_finalize(MMHandleType handle);
112
113 void _mmcamcorder_sound_solo_play(MMHandleType handle, const char *filepath, gboolean sync_play);
114 void _mmcamcorder_sound_solo_play_wait(MMHandleType handle);
115
116 #ifdef __cplusplus
117 }
118 #endif
119
120 #endif /* __MM_CAMCORDER_SOUND_H__ */