summaryrefslogtreecommitdiff
path: root/mobile/libmm-sound.patch
blob: 037a64a288a87e641d5be56e6423df40bea8cb3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
diff --git a/mm_sound.c b/mm_sound.c
index 9c08623..94daab8 100644
--- a/mm_sound.c
+++ b/mm_sound.c
@@ -76,6 +76,7 @@ typedef struct {
 	bool 				is_started;
 	bool				is_playback;
 	bool				skip_session;
+	ASM_resource_t resource;
 	pthread_mutex_t pcm_mutex_internal;
 	MMMessageCallback	msg_cb;
 	void *msg_cb_param;
@@ -420,7 +421,7 @@ static void __sound_pcm_send_message (mm_sound_pcm_t *pcmHandle, int message, in
 	}
 }
 
-ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void *cb_data)
+static ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src, ASM_sound_commands_t command, unsigned int sound_status, void *cb_data)
 {
 	mm_sound_pcm_t *pcmHandle = (mm_sound_pcm_t *)cb_data;
 	ASM_cb_result_t	cb_res = ASM_CB_RES_IGNORE;
@@ -434,6 +435,7 @@ ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src
 	debug_log ("command = %d, handle = %p, is_started = %d\n",command, pcmHandle, pcmHandle->is_started);
 	switch(command)
 	{
+	case ASM_COMMAND_PAUSE:
 	case ASM_COMMAND_STOP:
 		/* Do stop */
 		PCM_LOCK_INTERNAL(&pcmHandle->pcm_mutex_internal);
@@ -446,7 +448,6 @@ ASM_cb_result_t sound_pcm_asm_callback(int handle, ASM_event_sources_t event_src
 		cb_res = ASM_CB_RES_IGNORE;
 		break;
 
-	case ASM_COMMAND_PAUSE:
 	case ASM_COMMAND_PLAY:
 	case ASM_COMMAND_NONE:
 		debug_error ("Not an expected case!!!!\n");
@@ -568,15 +569,17 @@ int mm_sound_pcm_capture_open(MMSoundPcmHandle_t *handle, const unsigned int rat
 		return MM_ERROR_POLICY_INTERNAL;
 	}
 	/* register asm */
-	if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
+	if(pcmHandle->asm_event != ASM_EVENT_CALL &&
+		pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
 		if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event,
-				/* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode))
-		{
+				/* ASM_STATE_PLAYING */ ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) {
 			debug_error("ASM_register_sound() failed 0x%x\n", errorcode);
 			PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal);
 			free(pcmHandle);
 			return MM_ERROR_POLICY_BLOCKED;
 		}
+	} else {
+		pcmHandle->skip_session = true;
 	}
 
 	/* Open */
@@ -626,7 +629,7 @@ static int _pcm_sound_start (MMSoundPcmHandle_t handle)
 
 	if (pcmHandle->skip_session == false) {
 		/* ASM set state to PLAYING */
-		if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_PLAYING, ASM_RESOURCE_NONE, &errorcode)) {
+		if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_PLAYING, pcmHandle->resource, &errorcode)) {
 			debug_error("ASM_set_sound_state(PLAYING) failed 0x%x\n", errorcode);
 			ret = MM_ERROR_POLICY_BLOCKED;
 			goto EXIT;
@@ -719,7 +722,7 @@ static int _pcm_sound_stop(MMSoundPcmHandle_t handle)
 	if (ret == MM_ERROR_NONE) {
 		/* Set ASM State to STOP */
 		if (pcmHandle->skip_session == false) {
-			if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_STOP, ASM_RESOURCE_NONE, &errorcode)) {
+			if (!ASM_set_sound_state(pcmHandle->asm_handle, pcmHandle->asm_event, ASM_STATE_STOP, pcmHandle->resource, &errorcode)) {
 				debug_error("ASM_set_sound_state(STOP) failed 0x%x\n", errorcode);
 				ret = MM_ERROR_POLICY_BLOCKED;
 				goto EXIT;
@@ -823,13 +826,16 @@ int mm_sound_pcm_capture_close(MMSoundPcmHandle_t handle)
 	}
 
 	/* Unregister ASM */
-	if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
-		if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) {
-    		debug_error("ASM_unregister failed in %s with 0x%x\n", __func__, errorcode);
-			result = MM_ERROR_SOUND_INTERNAL;
-			goto EXIT;
-    	}
-    }
+	if(pcmHandle->asm_event != ASM_EVENT_CALL &&
+		pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
+		if (pcmHandle->skip_session == false && pcmHandle->asm_handle) {
+			if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) {
+				debug_error("ASM_unregister failed in %s with 0x%x\n", __func__, errorcode);
+				result = MM_ERROR_SOUND_INTERNAL;
+				goto EXIT;
+			}
+		}
+	}
 
 	debug_log ("pcm capture sound [%p] closed success!!!\n", handle);
 
@@ -943,20 +949,23 @@ int mm_sound_pcm_play_open_ex (MMSoundPcmHandle_t *handle, const unsigned int ra
 			return MM_ERROR_POLICY_INTERNAL;
 		}
 
-		if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
+		if(pcmHandle->asm_event != ASM_EVENT_CALL &&
+			pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
 			/* register asm */
 			if(!ASM_register_sound(-1, &pcmHandle->asm_handle, pcmHandle->asm_event,
-					ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode)) {
+					ASM_STATE_NONE, sound_pcm_asm_callback, (void*)pcmHandle, pcmHandle->resource, &errorcode)) {
 				debug_error("ASM_register_sound() failed 0x%x\n", errorcode);
 				PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal);
 				free(pcmHandle);
 				return MM_ERROR_POLICY_BLOCKED;
 			}
+		} else {
+			pcmHandle->skip_session = true;
 		}
 	} else {
 		/* register asm using asm_event input */
 		if(!ASM_register_sound(-1, &pcmHandle->asm_handle, asm_event,
-				ASM_STATE_NONE, NULL, (void*)pcmHandle, ASM_RESOURCE_NONE, &errorcode)) {
+				ASM_STATE_NONE, NULL, (void*)pcmHandle, pcmHandle->resource, &errorcode)) {
 			debug_error("ASM_register_sound() failed 0x%x\n", errorcode);
 			PCM_LOCK_DESTROY_INTERNAL(&pcmHandle->pcm_mutex_internal);
 			free(pcmHandle);
@@ -1109,7 +1118,8 @@ int mm_sound_pcm_play_close(MMSoundPcmHandle_t handle)
 
 	if (pcmHandle->skip_session == false) {
 		/* Unregister ASM */
-		if(pcmHandle->asm_event != ASM_EVENT_CALL && pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
+		if(pcmHandle->asm_event != ASM_EVENT_CALL &&
+			pcmHandle->asm_event != ASM_EVENT_VIDEOCALL) {
 			if(!ASM_unregister_sound(pcmHandle->asm_handle, pcmHandle->asm_event, &errorcode)) {
 				debug_error("ASM_unregister failed in %s with 0x%x\n",__func__, errorcode);
 				result = MM_ERROR_SOUND_INTERNAL;
diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec
index b07199e..040586d 100644
--- a/packaging/libmm-sound.spec
+++ b/packaging/libmm-sound.spec
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.7.4
+Version:    0.7.5
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0