2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <sound_manager.h>
28 static GMainLoop *g_mainloop = NULL;
29 static GThread *event_thread;
30 #define MAX_VOLUME_TYPE 5
32 gpointer GmainThread(gpointer data){
33 g_mainloop = g_main_loop_new (NULL, 0);
34 g_main_loop_run (g_mainloop);
39 void _sound_manager_volume_changed_cb(sound_type_e type, unsigned int volume, void* user_data)
41 printf("changed!! type=%d, volume = %d\n", type, volume);
46 printf("set volume test\n");
48 sound_manager_set_volume_changed_cb(_sound_manager_volume_changed_cb ,NULL);
49 for( i = SOUND_TYPE_SYSTEM ; i <=MAX_VOLUME_TYPE; i++){
52 sound_manager_get_max_volume(i, &max_value);
53 printf(" sound type = %d , max volume = %d\n", i, max_value);
54 for( j = 0; j <= max_value+1 ; j++){
57 ret = sound_manager_set_volume(i, j);
58 if( j <= max_value && ret == 0 ){
59 sound_manager_get_volume(i, &getvalue);
63 printf("FAIL!set=%d, get=%d\n", j, getvalue);
64 } else if( j > max_value && ret == 0 )
65 printf("FAIL! max_value over!!\n");
69 //sound_manager_unset_volume_changed_cb();
70 printf("end set volume test!!!\n");
75 void _sound_manager_route_policy_changed_cb(sound_route_policy_e route , void* user_data)
77 printf("new route policy %d\n", route);
82 printf("-----------set policy test--------------\n");
85 //sound_route_policy_e value;
86 sound_manager_set_route_policy_changed_cb(_sound_manager_route_policy_changed_cb,NULL);
88 for( i = SOUND_ROUTE_DEFAULT ; i <= SOUND_ROUTE_HANDSET_ONLY ; i++){
89 ret = sound_manager_set_route_policy(i);
90 ret = sound_manager_get_route_policy(&value);
97 ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT);
98 ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT);
99 ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT);
100 ret = sound_manager_set_route_policy(SOUND_ROUTE_DEFAULT);
107 static void mm_volume_changed_cb(void *user_data)
109 int v = (int)user_data;
110 unsigned int value = 0;
111 int ret = mm_sound_volume_get_value(v, &value);
112 printf("mm_volume_changed_cb type = %d ,volume = %d , ret = %x\n", v, value, ret );
119 mm_sound_volume_add_callback(0 , mm_volume_changed_cb , (void*)0);
120 mm_sound_volume_add_callback(1 , mm_volume_changed_cb ,(void*) 1);
121 mm_sound_volume_add_callback(2 , mm_volume_changed_cb , (void*)2);
122 mm_sound_volume_add_callback(5 , mm_volume_changed_cb , (void*)5);
126 for( i = 0 ; i < 10 ; i++)
128 ret = mm_sound_volume_set_value(0, i);
129 printf("type = 0 , volume = %d set , ret = %x\n", i, ret);
130 ret = mm_sound_volume_set_value(1, i);
131 printf("type = 1 , volume = %d set , ret = %x\n", i, ret);
132 ret = mm_sound_volume_set_value(2, i);
133 printf("type = 2 , volume = %d set , ret = %x\n", i, ret);
134 ret = mm_sound_volume_set_value(5, i);
135 printf("type = 5 , volume = %d set , ret = %x\n", i, ret);
139 //mm_sound_volume_remove_callback(0);
140 //mm_sound_volume_remove_callback(1);
141 //mm_sound_volume_remove_callback(2);
142 //mm_sound_volume_remove_callback(5);
145 ret = mm_sound_volume_set_value(5, 4);
147 mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT);
148 mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT);
149 mm_sound_route_set_system_policy(SOUND_ROUTE_DEFAULT);
159 strcat(path, "/test2.wav");
160 for( i =0 ; i < 10 ; i++){
161 mm_sound_play_sound(path, SOUND_TYPE_MEDIA, NULL ,NULL, &id);
162 mm_sound_stop_sound(id);
166 void session_notify_cb(sound_session_notify_e notify, void *user_data)
168 printf("notify %d\n", notify);
175 printf("session_test\n");
179 ret = sound_manager_set_session_type(SOUND_SESSION_TYPE_EXCLUSIVE);
180 sound_manager_set_session_notify_cb(session_notify_cb,NULL);
184 ret = player_create(&player);
185 printf("player_create ret =%x\n", ret);
186 ret = player_set_uri(player, "title_theme.mp3");
187 printf("player_set_uri ret =%x\n", ret);
188 ret =player_prepare(player);
189 printf("player_prepare ret =%x\n", ret);
190 ret = player_start(player);
191 printf("player_start ret =%x\n", ret);
194 player_state_e state;
195 player_get_state(player, &state);
196 printf("state %d\n", state);
198 //player_start(player);
200 //wav_player_start("test.wav", SOUND_TYPE_MEDIA,NULL, NULL,NULL);
210 sound_manager_get_a2dp_status(&isconnected, &name);
212 printf("name = %s\n", name);
215 printf("disconnected\n");
217 sound_device_e device;
218 sound_manager_get_current_sound_device(&device);
219 printf("device =%d\n", device);
225 if( !g_thread_supported() )
231 event_thread = g_thread_create(GmainThread, NULL, 1, &gerr);