+bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const mmf_value_t *value)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ mmf_return_val_if_fail(hcamcorder && value, FALSE);
+
+ if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
+ /* Replay gain enable */
+ int current_state = MM_CAMCORDER_STATE_NONE;
+ int audio_disable = FALSE;
+
+ current_state = _mmcamcorder_get_state(handle);
+ if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
+ _mmcam_dbg_err("Can not set replay gain enable [state : %d]", current_state);
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
+ return FALSE;
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_AUDIO_DISABLE, &audio_disable,
+ NULL);
+
+ if (audio_disable) {
+ _mmcam_dbg_err("audio is disabled");
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("set replay gain enable : %d", value->value.i_val);
+ } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
+ /* Replay gain reference level */
+ int replay_gain_enable = FALSE;
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
+ NULL);
+
+ if (replay_gain_enable == FALSE) {
+ _mmcam_dbg_err("replay gain is disabled");
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("set reference level for replay gain : %ld dB", value->value.d_val);
+ } else {
+ _mmcam_dbg_err("unknown attribute id %d", attr_idx);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+