Move private defines to radio_private.h
[platform/core/api/radio.git] / src / radio.c
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 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <mm_types.h>
21 #include <radio_private.h>
22 #include <system_info.h>
23
24 /*
25 * Internal Implementation
26 */
27 static int __convert_error_code(int code, char *func_name)
28 {
29         int ret = RADIO_ERROR_NONE;
30         char *msg = "RADIO_ERROR_NONE";
31         LOGI("Enter code :%x", code);
32         switch (code) {
33         case MM_ERROR_NONE:
34                 ret = RADIO_ERROR_NONE;
35                 msg = "RADIO_ERROR_NONE";
36                 break;
37         case MM_ERROR_RADIO_NO_FREE_SPACE:
38         case MM_ERROR_OUT_OF_MEMORY:
39                 ret = RADIO_ERROR_OUT_OF_MEMORY;
40                 msg = "RADIO_ERROR_OUT_OF_MEMORY";
41                 break;
42         case MM_ERROR_RADIO_NOT_INITIALIZED:
43         case MM_ERROR_RADIO_NO_OP:
44         case MM_ERROR_RADIO_INVALID_STATE:
45                 ret = RADIO_ERROR_INVALID_STATE;
46                 msg = "RADIO_ERROR_INVALID_STATE";
47                 break;
48         case MM_ERROR_COMMON_INVALID_ARGUMENT:
49         case MM_ERROR_INVALID_ARGUMENT:
50                 ret = RADIO_ERROR_INVALID_PARAMETER;
51                 msg = "RADIO_ERROR_INVALID_PARAMETER";
52                 break;
53         case MM_ERROR_POLICY_BLOCKED:
54         case MM_ERROR_POLICY_INTERRUPTED:
55         case MM_ERROR_POLICY_INTERNAL:
56         case MM_ERROR_POLICY_DUPLICATED:
57                 ret = RADIO_ERROR_SOUND_POLICY;
58                 msg = "RADIO_ERROR_SOUND_POLICY";
59                 break;
60         case MM_ERROR_RADIO_DEVICE_NOT_FOUND:
61                 ret = RADIO_ERROR_NOT_SUPPORTED;
62                 msg = "RADIO_ERROR_NOT_SUPPORTED";
63                 break;
64         case MM_ERROR_RADIO_NO_ANTENNA:
65                 ret = RADIO_ERROR_NO_ANTENNA;
66                 msg = "RADIO_ERROR_NO_ANTENNA";
67                 break;
68         case MM_ERROR_RADIO_DEVICE_NOT_OPENED:
69         case MM_ERROR_RADIO_PERMISSION_DENIED:
70                 ret = RADIO_ERROR_PERMISSION_DENIED;
71                 msg = "RADIO_ERROR_PERMISSION_DENIED";
72                 break;
73         case MM_ERROR_NOT_IMPLEMENTED:
74         case MM_ERROR_RADIO_INTERNAL:
75         case MM_ERROR_RADIO_RESPONSE_TIMEOUT:
76         default:
77                 ret = RADIO_ERROR_INVALID_OPERATION;
78                 msg = "RADIO_ERROR_INVALID_OPERATION";
79                 break;
80         }
81         LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
82         return ret;
83 }
84
85 static radio_state_e __convert_radio_state(MMRadioStateType state)
86 {
87         int converted_state = RADIO_STATE_READY;
88         LOGI("Enter state: %d", state);
89         switch (state) {
90
91         case MM_RADIO_STATE_PLAYING:
92                 converted_state = RADIO_STATE_PLAYING;
93                 break;
94         case MM_RADIO_STATE_SCANNING:
95                 converted_state = RADIO_STATE_SCANNING;
96                 break;
97         case MM_RADIO_STATE_NULL:
98         case MM_RADIO_STATE_READY:
99         default:
100                 converted_state = RADIO_STATE_READY;
101                 break;
102         }
103         LOGI("Leave converted_state: %d", converted_state);
104         return converted_state;
105 }
106
107 static int __set_callback(_radio_event_e type, radio_h radio, void *callback, void *user_data)
108 {
109         RADIO_INSTANCE_CHECK(radio);
110         RADIO_NULL_ARG_CHECK(callback);
111         radio_s *handle = (radio_s *)radio;
112         handle->user_cb[type] = callback;
113         handle->user_data[type] = user_data;
114         LOGI("Event type : %d", type);
115         return RADIO_ERROR_NONE;
116 }
117
118 static int __unset_callback(_radio_event_e type, radio_h radio)
119 {
120         RADIO_INSTANCE_CHECK(radio);
121         radio_s *handle = (radio_s *)radio;
122         handle->user_cb[type] = NULL;
123         handle->user_data[type] = NULL;
124         LOGI("Event type : %d", type);
125         return RADIO_ERROR_NONE;
126 }
127
128 static int __msg_callback(int message, void *param, void *user_data)
129 {
130         radio_s *handle = (radio_s *)user_data;
131         MMMessageParamType *msg = (MMMessageParamType *)param;
132         LOGI("Got message type : 0x%x", message);
133         switch (message) {
134         case MM_MESSAGE_RADIO_SCAN_INFO:
135                 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])
136                         ((radio_scan_updated_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_INFO])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SCAN_INFO]);
137                 break;
138         case MM_MESSAGE_RADIO_SCAN_STOP:
139                 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])
140                         ((radio_scan_stopped_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_STOP]);
141                 __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP, (radio_h)handle);
142                 __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, (radio_h)handle);
143                 break;
144         case MM_MESSAGE_RADIO_SCAN_FINISH:
145                 if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])
146                         ((radio_scan_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SCAN_FINISH])(handle->user_data[_RADIO_EVENT_TYPE_SCAN_FINISH]);
147                 __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, (radio_h)handle);
148                 break;
149         case MM_MESSAGE_RADIO_SEEK_FINISH:
150                 if (handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH]) {
151                         ((radio_seek_completed_cb)handle->user_cb[_RADIO_EVENT_TYPE_SEEK_FINISH])(msg->radio_scan.frequency, handle->user_data[_RADIO_EVENT_TYPE_SEEK_FINISH]);
152                         handle->seeking = false;
153                 }
154                 __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, (radio_h)handle);
155                 break;
156         //LCOV_EXCL_START
157         case MM_MESSAGE_STATE_INTERRUPTED:
158                 if (msg->union_type == MM_MSG_UNION_STATE) {
159                         handle->state = __convert_radio_state(msg->state.current);
160                         if (handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])
161                                 ((radio_interrupted_cb)handle->user_cb[_RADIO_EVENT_TYPE_INTERRUPT])(RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT, handle->user_data[_RADIO_EVENT_TYPE_INTERRUPT]);
162                 }
163                 break;
164         case MM_MESSAGE_ERROR:
165                 __convert_error_code(msg->code, (char *)__FUNCTION__);
166                 break;
167         //LCOV_EXCL_STOP
168         case MM_MESSAGE_RADIO_SCAN_START:
169                 LOGI("Scan Started");
170                 break;
171         case MM_MESSAGE_STATE_CHANGED:
172                 handle->state = __convert_radio_state(msg->state.current);
173                 LOGI("State Changed --- from : %d , to : %d", __convert_radio_state(msg->state.previous), handle->state);
174                 break;
175         case MM_MESSAGE_RADIO_SEEK_START:
176                 LOGI("Seek Started");
177                 break;
178         default:
179                 break;
180         }
181         return 1;
182 }
183
184 static int __radio_check_system_info_feature_supported()
185 {
186         bool val = false;
187         int ret = false;
188
189         ret = system_info_get_platform_bool("http://tizen.org/feature/fmradio", &val);
190
191         if (ret != SYSTEM_INFO_ERROR_NONE) {
192                 LOGE("SYSTEM_INFO_ERROR");
193                 return false;
194         }
195
196         if (val == false)
197                 LOGI("system_info_get_platform_bool returned Unsupported feature capability");
198         else
199                 LOGI("system_info_get_platform_bool returned Supported status feature");
200
201         return val;
202 }
203
204 /*
205 * Public Implementation
206 */
207 int radio_create(radio_h *radio)
208 {
209         LOGI("Enter");
210         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
211         RADIO_INSTANCE_CHECK(radio);
212         radio_s *handle;
213
214         handle = (radio_s *)malloc(sizeof(radio_s));
215         if (!handle) {
216                 LOGE("RADIO_ERROR_OUT_OF_MEMORY(0x%08x)", RADIO_ERROR_OUT_OF_MEMORY);
217                 return RADIO_ERROR_OUT_OF_MEMORY;
218         }
219
220         memset(handle, 0, sizeof(radio_s));
221
222         int ret = mm_radio_create(&handle->mm_handle);
223         if (ret != MM_ERROR_NONE) {
224                 free(handle);
225                 handle = NULL;
226                 return __convert_error_code(ret, (char *)__FUNCTION__);
227         }
228
229         *radio = (radio_h)handle;
230
231         ret = mm_radio_set_message_callback(handle->mm_handle, __msg_callback, (void *)handle);
232         if (ret != MM_ERROR_NONE)
233                 LOGW("Failed to set message callback function (0x%x)", ret);
234
235         ret = mm_radio_realize(handle->mm_handle);
236         if (ret != MM_ERROR_NONE)
237                 return __convert_error_code(ret, (char *)__FUNCTION__);
238
239         handle->state = RADIO_STATE_READY;
240         handle->mute = false;
241         handle->seeking = false;
242         return RADIO_ERROR_NONE;
243 }
244
245 int radio_destroy(radio_h radio)
246 {
247         LOGI("Enter");
248         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
249         RADIO_INSTANCE_CHECK(radio);
250         radio_s *handle = (radio_s *)radio;
251
252         int ret;
253         ret = mm_radio_unrealize(handle->mm_handle);
254         if (ret != MM_ERROR_NONE)
255                 LOGW("Failed to unrealize (0x%x)", ret);
256
257         ret = mm_radio_destroy(handle->mm_handle);
258         if (ret != MM_ERROR_NONE)
259                 return __convert_error_code(ret, (char *)__FUNCTION__);
260
261         free(handle);
262         handle = NULL;
263         return RADIO_ERROR_NONE;
264 }
265
266 int radio_get_state(radio_h radio, radio_state_e *state)
267 {
268         LOGI("Enter");
269         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
270         RADIO_INSTANCE_CHECK(radio);
271         RADIO_NULL_ARG_CHECK(state);
272         radio_s *handle = (radio_s *)radio;
273         MMRadioStateType currentStat = MM_RADIO_STATE_NULL;
274         int ret = mm_radio_get_state(handle->mm_handle, &currentStat);
275         if (ret != MM_ERROR_NONE) {
276                 *state = handle->state;
277                 return __convert_error_code(ret, (char *)__FUNCTION__);
278         }
279
280         handle->state = __convert_radio_state(currentStat);
281         *state = handle->state;
282         return RADIO_ERROR_NONE;
283 }
284
285 int radio_start(radio_h radio)
286 {
287         LOGI("Enter");
288         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
289         RADIO_INSTANCE_CHECK(radio);
290         radio_s *handle = (radio_s *)radio;
291         RADIO_STATE_CHECK(handle, RADIO_STATE_READY);
292
293         int ret = mm_radio_start(handle->mm_handle);
294         if (ret != MM_ERROR_NONE)
295                 return __convert_error_code(ret, (char *)__FUNCTION__);
296
297         handle->state = RADIO_STATE_PLAYING;
298         return RADIO_ERROR_NONE;
299 }
300
301 int radio_stop(radio_h radio)
302 {
303         LOGI("Enter");
304         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
305         RADIO_INSTANCE_CHECK(radio);
306         radio_s *handle = (radio_s *)radio;
307         RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
308
309         int ret = mm_radio_stop(handle->mm_handle);
310         if (ret != MM_ERROR_NONE)
311                 return __convert_error_code(ret, (char *)__FUNCTION__);
312
313         handle->state = RADIO_STATE_READY;
314         return RADIO_ERROR_NONE;
315 }
316
317 int radio_seek_up(radio_h radio, radio_seek_completed_cb callback, void *user_data)
318 {
319         LOGI("Enter");
320         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
321         RADIO_INSTANCE_CHECK(radio);
322         radio_s *handle = (radio_s *)radio;
323         RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
324
325         if (handle->seeking) {
326                 LOGI("radio is seeking, can't serve another request try again");
327                 return RADIO_ERROR_INVALID_OPERATION;
328         }
329
330         handle->seeking = true;
331
332         if (callback != NULL)
333                 __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
334         else
335                 __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
336
337         int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_UP);
338         if (ret != MM_ERROR_NONE)
339                 return __convert_error_code(ret, (char *)__FUNCTION__);
340
341         return RADIO_ERROR_NONE;
342 }
343
344 int radio_seek_down(radio_h radio, radio_seek_completed_cb callback, void *user_data)
345 {
346         LOGI("Enter");
347         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
348         RADIO_INSTANCE_CHECK(radio);
349         radio_s *handle = (radio_s *)radio;
350         RADIO_STATE_CHECK(handle, RADIO_STATE_PLAYING);
351
352         if (handle->seeking) {
353                 LOGI("radio is seeking, can't serve another request try again");
354                 return RADIO_ERROR_INVALID_OPERATION;
355         }
356
357         handle->seeking = true;
358
359         if (callback != NULL)
360                 __set_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio, callback, user_data);
361         else
362                 __unset_callback(_RADIO_EVENT_TYPE_SEEK_FINISH, radio);
363
364         int ret = mm_radio_seek(handle->mm_handle, MM_RADIO_SEEK_DOWN);
365         if (ret != MM_ERROR_NONE)
366                 return __convert_error_code(ret, (char *)__FUNCTION__);
367
368         return RADIO_ERROR_NONE;
369 }
370
371 int radio_set_frequency(radio_h radio, int frequency)
372 {
373         LOGI("Enter");
374         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
375         RADIO_INSTANCE_CHECK(radio);
376         if (frequency < 87500 || frequency > 108000) {
377                 LOGE("RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (87500 ~ 108000)", RADIO_ERROR_INVALID_PARAMETER);
378                 return RADIO_ERROR_INVALID_PARAMETER;
379         }
380
381         radio_s *handle = (radio_s *)radio;
382         int ret = mm_radio_set_frequency(handle->mm_handle, frequency);
383         if (ret != MM_ERROR_NONE)
384                 return __convert_error_code(ret, (char *)__FUNCTION__);
385
386         return RADIO_ERROR_NONE;
387 }
388
389 int radio_get_frequency(radio_h radio, int *frequency)
390 {
391         LOGI("Enter");
392         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
393         RADIO_INSTANCE_CHECK(radio);
394         RADIO_NULL_ARG_CHECK(frequency);
395         radio_s *handle = (radio_s *)radio;
396
397         int freq;
398         int ret = mm_radio_get_frequency(handle->mm_handle, &freq);
399         if (ret != MM_ERROR_NONE)
400                 return __convert_error_code(ret, (char *)__FUNCTION__);
401
402         *frequency = freq;
403         return RADIO_ERROR_NONE;
404 }
405
406 int radio_get_signal_strength(radio_h radio, int *strength)
407 {
408         LOGI("Enter");
409         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
410         RADIO_INSTANCE_CHECK(radio);
411         RADIO_NULL_ARG_CHECK(strength);
412         radio_s *handle = (radio_s *)radio;
413
414         int _strength;
415         int ret = mm_radio_get_signal_strength(handle->mm_handle, &_strength);
416         if (ret != MM_ERROR_NONE)
417                 return __convert_error_code(ret, (char *)__FUNCTION__);
418
419         *strength = _strength;
420         return RADIO_ERROR_NONE;
421 }
422
423 int radio_scan_start(radio_h radio, radio_scan_updated_cb callback, void *user_data)
424 {
425         LOGI("Enter");
426         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
427         RADIO_INSTANCE_CHECK(radio);
428         radio_s *handle = (radio_s *)radio;
429
430         if (callback != NULL)
431                 __set_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio, callback, user_data);
432         else
433                 __unset_callback(_RADIO_EVENT_TYPE_SCAN_INFO, radio);
434
435         int ret = mm_radio_scan_start(handle->mm_handle);
436         if (ret != MM_ERROR_NONE)
437                 return __convert_error_code(ret, (char *)__FUNCTION__);
438
439         handle->state = RADIO_STATE_SCANNING;
440         return RADIO_ERROR_NONE;
441
442 }
443
444 int radio_scan_stop(radio_h radio, radio_scan_stopped_cb callback, void *user_data)
445 {
446         LOGI("Enter");
447         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
448         RADIO_INSTANCE_CHECK(radio);
449         radio_s *handle = (radio_s *)radio;
450         RADIO_STATE_CHECK(handle, RADIO_STATE_SCANNING);
451
452         if (handle->user_cb[_RADIO_EVENT_TYPE_SCAN_STOP]) {
453                 LOGW("Failed to stop scan (0x%x)", RADIO_ERROR_INVALID_OPERATION);
454                 return RADIO_ERROR_INVALID_OPERATION;
455         }
456
457         if (callback != NULL)
458                 __set_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio, callback, user_data);
459         else
460                 __unset_callback(_RADIO_EVENT_TYPE_SCAN_STOP, radio);
461
462         int ret = mm_radio_scan_stop(handle->mm_handle);
463         if (ret != MM_ERROR_NONE)
464                 return __convert_error_code(ret, (char *)__FUNCTION__);
465
466         return RADIO_ERROR_NONE;
467 }
468
469 int radio_set_mute(radio_h radio, bool muted)
470 {
471         LOGI("Enter");
472         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
473         RADIO_INSTANCE_CHECK(radio);
474         radio_s *handle = (radio_s *)radio;
475
476         int ret = mm_radio_set_mute(handle->mm_handle, muted);
477         if (ret != MM_ERROR_NONE)
478                 return __convert_error_code(ret, (char *)__FUNCTION__);
479
480         handle->mute = muted;
481         return RADIO_ERROR_NONE;
482
483 }
484
485 int radio_is_muted(radio_h radio, bool *muted)
486 {
487         LOGI("Enter");
488         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
489         RADIO_INSTANCE_CHECK(radio);
490         RADIO_NULL_ARG_CHECK(muted);
491         radio_s *handle = (radio_s *)radio;
492         *muted = handle->mute;
493         return RADIO_ERROR_NONE;
494 }
495
496 int radio_set_scan_completed_cb(radio_h radio, radio_scan_completed_cb callback, void *user_data)
497 {
498         LOGI("Enter");
499         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
500         return __set_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio, callback, user_data);
501 }
502
503 int radio_unset_scan_completed_cb(radio_h radio)
504 {
505         LOGI("Enter");
506         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
507         return __unset_callback(_RADIO_EVENT_TYPE_SCAN_FINISH, radio);
508 }
509
510 int radio_set_interrupted_cb(radio_h radio, radio_interrupted_cb callback, void *user_data)
511 {
512         LOGI("Enter");
513         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
514         return __set_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio, callback, user_data);
515 }
516
517 int radio_unset_interrupted_cb(radio_h radio)
518 {
519         LOGI("Enter");
520         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
521         return __unset_callback(_RADIO_EVENT_TYPE_INTERRUPT, radio);
522 }
523
524 int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq)
525 {
526         LOGI("Enter");
527         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
528         RADIO_INSTANCE_CHECK(radio);
529         RADIO_NULL_ARG_CHECK(min_freq);
530         RADIO_NULL_ARG_CHECK(max_freq);
531         radio_s *handle = (radio_s *)radio;
532
533         unsigned int min = 0;
534         unsigned int max = 0;
535
536         int ret = mm_radio_get_region_frequency_range(handle->mm_handle, &min, &max);
537         if (ret != MM_ERROR_NONE)
538                 return __convert_error_code(ret, (char *)__FUNCTION__);
539
540         *min_freq = min;
541         *max_freq = max;
542         return RADIO_ERROR_NONE;
543 }
544
545 int radio_get_channel_spacing(radio_h radio, int *channel_spacing)
546 {
547         LOGI("Enter");
548         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
549         RADIO_INSTANCE_CHECK(radio);
550
551         radio_s *handle = (radio_s *)radio;
552
553         int ret = mm_radio_get_channel_spacing(handle->mm_handle, channel_spacing);
554         if (ret != MM_ERROR_NONE)
555                 return __convert_error_code(ret, (char *)__FUNCTION__);
556
557         return RADIO_ERROR_NONE;
558 }
559
560 int radio_set_volume(radio_h radio, float volume)
561 {
562         LOGI("Enter");
563         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
564         RADIO_INSTANCE_CHECK(radio);
565         if (volume < 0.0 || volume > 1.0) {
566                 LOGE("RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", RADIO_ERROR_INVALID_PARAMETER);
567                 return RADIO_ERROR_INVALID_PARAMETER;
568         }
569
570         radio_s *handle = (radio_s *)radio;
571         int ret = mm_radio_set_volume(handle->mm_handle, volume);
572         if (ret != MM_ERROR_NONE)
573                 return __convert_error_code(ret, (char *)__FUNCTION__);
574
575         return RADIO_ERROR_NONE;
576 }
577
578 int radio_get_volume(radio_h radio, float *volume)
579 {
580         LOGI("Enter");
581         RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported());
582         RADIO_INSTANCE_CHECK(radio);
583         RADIO_NULL_ARG_CHECK(volume);
584         radio_s *handle = (radio_s *)radio;
585
586         float vol;
587         int ret = mm_radio_get_volume(handle->mm_handle, &vol);
588         if (ret != MM_ERROR_NONE)
589                 return __convert_error_code(ret, (char *)__FUNCTION__);
590
591         *volume = vol;
592         return RADIO_ERROR_NONE;
593 }