Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.32
+Version: 0.10.33
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
========================================================================================*/
#define SAFE_FREE(x) \
if (x) {\
+ free(x); \
+ x = NULL; \
+ }
+
+#define SAFE_G_FREE(x) \
+ if (x) {\
g_free(x); \
x = NULL; \
}
}
if (sc->info_video) {
- if (sc->info_video->filename) {
- free(sc->info_video->filename);
- sc->info_video->filename = NULL;
- }
- sc->info_video->filename = strdup(filename);
+ SAFE_G_FREE(sc->info_video->filename);
+ sc->info_video->filename = g_strdup(filename);
if (sc->info_video->filename == NULL) {
_mmcam_dbg_err("failed to strdup filename [%s]", filename);
return FALSE;
goto _ERR_CAMCORDER_AUDIO_COMMAND;
}
- info->filename = strdup(temp_filename);
+ info->filename = g_strdup(temp_filename);
if (!info->filename) {
_mmcam_dbg_err("STRDUP was failed");
goto _ERR_CAMCORDER_AUDIO_COMMAND;
if (info->filename) {
_mmcam_dbg_log("file delete(%s)", info->filename);
unlink(info->filename);
- g_free(info->filename);
- info->filename = NULL;
+ SAFE_G_FREE(info->filename);
}
break;
/* Send recording report message to application */
msg.id = MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED;
- report = (MMCamRecordingReport*) malloc(sizeof(MMCamRecordingReport));
+ report = (MMCamRecordingReport*) g_malloc(sizeof(MMCamRecordingReport));
if (!report) {
_mmcam_dbg_err("Recording report fail(%s). Out of memory.", info->filename);
return FALSE;
}
/* END TAG HERE */
- report->recording_filename = strdup(info->filename);
+ report->recording_filename = g_strdup(info->filename);
msg.param.data= report;
_mmcamcorder_send_message(handle, &msg);
sc->isMaxsizePausing = FALSE;
sc->isMaxtimePausing = FALSE;
- g_free(info->filename);
- info->filename = NULL;
+ SAFE_G_FREE(info->filename);
_mmcam_dbg_err("_MMCamcorder_CMD_COMMIT : end");
if (err != MM_ERROR_NONE) {
if (err_name) {
_mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
} else {
_mmcam_dbg_err("failed to get attributes [0x%x]", err);
}
char *get_new_string(char* src_string)
{
- return strdup(src_string);
+ return g_strdup(src_string);
}
void _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf** configure_info)
if (buffer_string == NULL) {
_mmcam_dbg_err("buffer_string alloc failed : %d", sizeof(char) * BUFFER_LENGTH_STRING);
*configure_info = NULL;
- g_free(new_conf);
+ SAFE_G_FREE(new_conf);
return MM_ERROR_CAMCORDER_LOW_MEMORY;
}
if (fd == NULL) {
_mmcam_dbg_err("failed file descriptor fail");
*configure_info = NULL;
- g_free(buffer_string);
- g_free(new_conf);
+ SAFE_G_FREE(buffer_string);
+ SAFE_G_FREE(new_conf);
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
{
read_main = 1;
buffer_token[0] = token;
- SAFE_FREE( detail_string );
+ SAFE_G_FREE( detail_string );
break;
}
}
else
{
- SAFE_FREE( detail_string );
+ SAFE_G_FREE( detail_string );
}
}
if( count_details == 0 )
{
_mmcam_dbg_warn( "category %s has no detail value... skip this category...", category_name );
- SAFE_FREE(category_name);
+ SAFE_G_FREE(category_name);
continue;
}
for( i = 0 ; i < count_details ; i++ )
{
- SAFE_FREE( buffer_details[i] );
+ SAFE_G_FREE( buffer_details[i] );
}
}
}
- SAFE_FREE(category_name);
+ SAFE_G_FREE(category_name);
}
//(*configure_info) = new_conf;
- SAFE_FREE( buffer_string );
+ SAFE_G_FREE( buffer_string );
/*_mmcam_dbg_log( "Done." );*/
switch (type) {
case CONFIGURE_VALUE_INT:
temp_int = (type_int2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int->name);
+ SAFE_G_FREE(temp_int->name);
break;
case CONFIGURE_VALUE_INT_RANGE:
temp_int_range = (type_int_range*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_range->name);
+ SAFE_G_FREE(temp_int_range->name);
break;
case CONFIGURE_VALUE_INT_ARRAY:
temp_int_array = (type_int_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_array->name);
- SAFE_FREE(temp_int_array->value);
+ SAFE_G_FREE(temp_int_array->name);
+ SAFE_G_FREE(temp_int_array->value);
break;
case CONFIGURE_VALUE_INT_PAIR_ARRAY:
temp_int_pair_array = (type_int_pair_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_int_pair_array->name);
- SAFE_FREE(temp_int_pair_array->value[0]);
- SAFE_FREE(temp_int_pair_array->value[1]);
+ SAFE_G_FREE(temp_int_pair_array->name);
+ SAFE_G_FREE(temp_int_pair_array->value[0]);
+ SAFE_G_FREE(temp_int_pair_array->value[1]);
break;
case CONFIGURE_VALUE_STRING:
temp_string = (type_string2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_string->name);
- SAFE_FREE(temp_string->value);
+ SAFE_G_FREE(temp_string->name);
+ SAFE_G_FREE(temp_string->value);
break;
case CONFIGURE_VALUE_STRING_ARRAY:
temp_string_array = (type_string_array*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_string_array->name);
+ SAFE_G_FREE(temp_string_array->name);
if (temp_string_array->value) {
count = temp_string_array->count;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_string_array->value[k]);
+ SAFE_G_FREE(temp_string_array->value[k]);
}
- g_free(temp_string_array->value);
- temp_string_array->value = NULL;
+ SAFE_G_FREE(temp_string_array->value);
}
- SAFE_FREE(temp_string_array->default_value);
+ SAFE_G_FREE(temp_string_array->default_value);
break;
case CONFIGURE_VALUE_ELEMENT:
temp_element = (type_element2*)(temp_conf->info[i]->detail_info[j]);
- SAFE_FREE(temp_element->name);
- SAFE_FREE(temp_element->element_name);
+ SAFE_G_FREE(temp_element->name);
+ SAFE_G_FREE(temp_element->element_name);
if (temp_element->value_int) {
count = temp_element->count_int;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_element->value_int[k]->name);
- SAFE_FREE(temp_element->value_int[k]);
+ SAFE_G_FREE(temp_element->value_int[k]->name);
+ SAFE_G_FREE(temp_element->value_int[k]);
}
- g_free(temp_element->value_int);
+ SAFE_G_FREE(temp_element->value_int);
}
if (temp_element->value_string) {
count = temp_element->count_string;
for (k = 0 ; k < count ; k++) {
- SAFE_FREE(temp_element->value_string[k]->name);
- SAFE_FREE(temp_element->value_string[k]->value);
- SAFE_FREE(temp_element->value_string[k]);
+ SAFE_G_FREE(temp_element->value_string[k]->name);
+ SAFE_G_FREE(temp_element->value_string[k]->value);
+ SAFE_G_FREE(temp_element->value_string[k]);
}
- g_free(temp_element->value_string);
+ SAFE_G_FREE(temp_element->value_string);
}
break;
default:
}
}
- SAFE_FREE(temp_conf->info[i]->detail_info[j]);
- temp_conf->info[i]->detail_info[j] = NULL;
+ SAFE_G_FREE(temp_conf->info[i]->detail_info[j]);
}
- SAFE_FREE(temp_conf->info[i]->detail_info);
- temp_conf->info[i]->detail_info = NULL;
+ SAFE_G_FREE(temp_conf->info[i]->detail_info);
- SAFE_FREE(temp_conf->info[i]);
+ SAFE_G_FREE(temp_conf->info[i]);
temp_conf->info[i] = NULL;
}
}
- SAFE_FREE((*configure_info)->info);
- SAFE_FREE((*configure_info));
+ SAFE_G_FREE((*configure_info)->info);
+ SAFE_G_FREE((*configure_info));
_mmcam_dbg_log("Done.");
}
new_int_array->name = get_new_string( buffer_token[0] );
new_int_array->value = (int*)g_malloc0( sizeof(int)*count_value );
if (new_int_array->value == NULL) {
- if (new_int_array->name) {
- free(new_int_array->name);
- new_int_array->name = NULL;
- }
- free(new_int_array);
- new_int_array = NULL;
+ SAFE_G_FREE(new_int_array->name);
+ SAFE_G_FREE(new_int_array);
_mmcam_dbg_err("allocation failed");
break;
}
break;
}
new_int_pair_array->name = get_new_string( buffer_token[0] );
- new_int_pair_array->value[0] = (int*)g_malloc( sizeof(int)*(count_value) );
+ new_int_pair_array->value[0] = (int*)g_malloc0( sizeof(int)*(count_value) );
if ( new_int_pair_array->value[0] == NULL ) {
- if (new_int_pair_array->name) {
- free( new_int_pair_array->name );
- new_int_pair_array->name = NULL;
- }
- g_free( new_int_pair_array );
- new_int_pair_array = NULL;
+ SAFE_G_FREE(new_int_pair_array->name);
+ SAFE_G_FREE(new_int_pair_array);
_mmcam_dbg_err("allocation failed");
break;
}
- new_int_pair_array->value[1] = (int*)g_malloc( sizeof(int)*(count_value) );
+ new_int_pair_array->value[1] = (int*)g_malloc0( sizeof(int)*(count_value) );
if ( new_int_pair_array->value[1] == NULL ) {
- g_free( new_int_pair_array->value[0] );
- new_int_pair_array->value[0] = NULL;
- if (new_int_pair_array->name) {
- free( new_int_pair_array->name );
- new_int_pair_array->name = NULL;
- }
- g_free( new_int_pair_array );
- new_int_pair_array = NULL;
+ SAFE_G_FREE(new_int_pair_array->value[0]);
+ SAFE_G_FREE(new_int_pair_array->name);
+ SAFE_G_FREE(new_int_pair_array);
_mmcam_dbg_err("allocation failed");
break;
}
new_string_array->count = count_value;
new_string_array->value = (char**)g_malloc0( sizeof(char*)*count_value );
if ( new_string_array->value == NULL ) {
- if (new_string_array->name) {
- free(new_string_array->name);
- new_string_array->name = NULL;
- }
- free(new_string_array);
- new_string_array = NULL;
+ SAFE_G_FREE(new_string_array->name);
+ SAFE_G_FREE(new_string_array);
_mmcam_dbg_err("allocation failed");
break;
}
new_element->value_int = (type_int2**)g_malloc0( sizeof(type_int2*)*(new_element->count_int) );
if ( new_element->value_int) {
for ( j = 0 ; j < new_element->count_int ; j++ ) {
- new_element->value_int[j] = (type_int2*)g_malloc( sizeof(type_int2) );
+ new_element->value_int[j] = (type_int2*)g_malloc0( sizeof(type_int2) );
if ( new_element->value_int[j] ) {
new_element->value_int[j]->name = get_new_string( buffer_token[4+(j<<1)] );
new_element->value_int[j]->value = atoi( buffer_token[5+(j<<1)] );
caps_str = gst_caps_to_string(video_caps);
_mmcam_dbg_log("encodebin caps [%s]", caps_str);
- free(caps_str);
+ g_free(caps_str);
caps_str = NULL;
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "caps", video_caps);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", "encodesink_encbin", element_list, err);
/* check element availability */
- mm_camcorder_get_attributes(handle, &err_name,
+ err = mm_camcorder_get_attributes(handle, &err_name,
MMCAM_AUDIO_ENCODER, &audio_enc,
MMCAM_AUDIO_CHANNEL, &channel,
MMCAM_VIDEO_ENCODER_BITRATE, &v_bitrate,
MMCAM_AUDIO_ENCODER_BITRATE, &a_bitrate,
NULL);
+ if (err != MM_ERROR_NONE) {
+ if (err_name) {
+ _mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
+ SAFE_FREE(err_name);
+ } else {
+ _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+ }
+
+ return err;
+ }
+
_mmcam_dbg_log("Profile[%d]", profile);
/* Set information */
if (err != MM_ERROR_NONE) {
if (err_name) {
_mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
} else {
_mmcam_dbg_err("failed to get attributes [0x%x]", err);
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
GstCameraControl *control = NULL;
- GstCameraControlExifInfo exif_info;
+ GstCameraControlExifInfo exif_info = {0,};
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control != NULL) {
gst_camera_control_get_exif_info(control, &exif_info); //get video input device information
- focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
+ if (exif_info.focal_len_denominator != 0)
+ focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
} else {
_mmcam_dbg_err("Fail to get camera control interface!");
focal_len = 0.0;
NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_err("Set attributes error(%s:%x)!", err_name, err);
- if (err_name) {
- free(err_name);
- err_name = NULL;
- }
+ SAFE_FREE(err_name);
return FALSE;
}
} else {
char *caps_string = gst_caps_to_string(caps);
if (caps_string) {
_mmcam_dbg_log("%s", caps_string);
- free(caps_string);
+ g_free(caps_string);
caps_string = NULL;
}
gst_caps_unref(caps);
NULL);
}
- _mmcam_dbg_log("vidoesrc new caps set. %"GST_PTR_FORMAT, caps);
-
- MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
- gst_caps_unref(caps);
- caps = NULL;
+ if (caps) {
+ _mmcam_dbg_log("vidoesrc new caps set. %"GST_PTR_FORMAT, caps);
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
+ gst_caps_unref(caps);
+ caps = NULL;
+ } else {
+ _mmcam_dbg_err("There are no caps");
+ }
}
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
NULL);
if (err_attr_name) {
_mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
NULL);
if (err_attr_name) {
_mmcam_dbg_err("Get brightness FAILED.");
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
NULL);
if (err_attr_name) {
_mmcam_dbg_err("Set %s FAILED.", err_attr_name);
- free(err_attr_name);
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control == NULL) {
_mmcam_dbg_err("cast CAMERA_CONTROL failed");
+ _MMCAMCORDER_UNLOCK_CMD(hcamcorder);
return MM_ERROR_CAMCORDER_INTERNAL;
}
/* alloc info for each mode */
switch (type) {
case MM_CAMCORDER_MODE_AUDIO:
- sc->info_audio = malloc( sizeof(_MMCamcorderAudioInfo));
+ sc->info_audio = g_malloc0( sizeof(_MMCamcorderAudioInfo));
if(!sc->info_audio) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_audio, 0x00, sizeof(_MMCamcorderAudioInfo));
break;
case MM_CAMCORDER_MODE_VIDEO_CAPTURE:
default:
- sc->info_image = malloc( sizeof(_MMCamcorderImageInfo));
+ sc->info_image = g_malloc0( sizeof(_MMCamcorderImageInfo));
if(!sc->info_image) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_image, 0x00, sizeof(_MMCamcorderImageInfo));
/* init sound status */
sc->info_image->sound_status = _SOUND_STATUS_INIT;
- sc->info_video = malloc( sizeof(_MMCamcorderVideoInfo));
+ sc->info_video = g_malloc0( sizeof(_MMCamcorderVideoInfo));
if(!sc->info_video) {
_mmcam_dbg_err("Failed to alloc info structure");
goto ALLOC_SUBCONTEXT_FAILED;
}
- memset(sc->info_video, 0x00, sizeof(_MMCamcorderVideoInfo));
g_mutex_init(&sc->info_video->size_check_lock);
break;
}
ALLOC_SUBCONTEXT_FAILED:
if (sc) {
- if (sc->info_audio) {
- free(sc->info_audio);
- sc->info_audio = NULL;
- }
- if (sc->info_image) {
- free(sc->info_image);
- sc->info_image = NULL;
- }
+ SAFE_G_FREE(sc->info_audio);
+ SAFE_G_FREE(sc->info_image);
if (sc->info_video) {
g_mutex_clear(&sc->info_video->size_check_lock);
- free(sc->info_video);
- sc->info_video = NULL;
}
+ SAFE_G_FREE(sc->info_video);
if (sc->element) {
free(sc->element);
sc->element = NULL;
if (sc->info_video) {
_mmcam_dbg_log("release info_video");
- if (sc->info_video->filename) {
- free(sc->info_video->filename);
- sc->info_video->filename = NULL;
- }
+ SAFE_G_FREE(sc->info_video->filename);
g_mutex_clear(&sc->info_video->size_check_lock);
free(sc->info_video);
sc->info_video = NULL;
if (sc->info_audio) {
_mmcam_dbg_log("release info_audio");
- if (sc->info_audio->filename) {
- free(sc->info_audio->filename);
- sc->info_audio->filename = NULL;
- }
+ SAFE_G_FREE(sc->info_audio->filename);
free(sc->info_audio);
sc->info_audio = NULL;
}
goto DROP_MESSAGE;
}
- cam_fd_info = (MMCamFaceDetectInfo *)malloc(sizeof(MMCamFaceDetectInfo));
+ cam_fd_info = (MMCamFaceDetectInfo *)g_malloc(sizeof(MMCamFaceDetectInfo));
if (cam_fd_info == NULL) {
_mmcam_dbg_warn("cam_fd_info alloc failed");
-
- free(fd_info);
- fd_info = NULL;
-
+ SAFE_FREE(fd_info);
goto DROP_MESSAGE;
}
cam_fd_info->num_of_faces = fd_info->num_of_faces;
if (cam_fd_info->num_of_faces > 0) {
- cam_fd_info->face_info = (MMCamFaceInfo *)malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
+ cam_fd_info->face_info = (MMCamFaceInfo *)g_malloc(sizeof(MMCamFaceInfo) * cam_fd_info->num_of_faces);
if (cam_fd_info->face_info) {
/* set information of each face */
for (i = 0 ; i < fd_info->num_of_faces ; i++) {
_mmcam_dbg_warn("MMCamFaceInfo alloc failed");
/* free allocated memory that is not sent */
- free(cam_fd_info);
- cam_fd_info = NULL;
+ SAFE_G_FREE(cam_fd_info);
}
} else {
cam_fd_info->face_info = NULL;
NULL);
if (err_name) {
_mmcam_dbg_warn("get_attributes err %s, ret 0x%x", err_name, ret);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
}
ret = MM_ERROR_NONE;
NULL);
if (err_name) {
_mmcam_dbg_warn("get_attributes err %s", err_name);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
}
/* set new caps */
NULL);
if (err_name) {
_mmcam_dbg_warn("get_attributes err %s, ret 0x%x", err_name, ret);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
}
/* set JPEG quality */
MMCAM_CAMERA_FPS, &fps,
MMCAM_CAMERA_ROTATION, &rotation,
NULL);
+ if (err_name) {
+ _mmcam_dbg_warn("get_attributes err %s, ret 0x%x", err_name, ret);
+ SAFE_FREE(err_name);
+ }
/* set new caps */
ret = _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, rotation);
if (fputs(x_str, x_file) == EOF) \
{\
_mmcam_dbg_err("[Critical] fputs() returns fail.\n");\
- SAFE_FREE(str); \
+ SAFE_G_FREE(str); \
return FALSE;\
}\
}
str = str_to_utf8("location_name");
FPUTS_CHECK(str, f); // name
- SAFE_FREE(str);
+ SAFE_G_FREE(str);
FPUTC_CHECK('\0', f);
FPUTC_CHECK(0, f); //role
str = str_to_utf8("Astronomical_body");
FPUTS_CHECK(str, f);//Astronomical_body
- SAFE_FREE(str);
+ SAFE_G_FREE(str);
FPUTC_CHECK('\0', f);
str = str_to_utf8("Additional_notes");
FPUTS_CHECK(str, f); // Additional_notes
- SAFE_FREE(str);
+ SAFE_G_FREE(str);
FPUTC_CHECK('\0', f);
list = g_list_next(list);
hcamcorder->buffer_probes = g_list_remove(hcamcorder->buffer_probes, item);
- SAFE_FREE(item);
+ SAFE_G_FREE(item);
} else {
_mmcam_dbg_log("Skip item : [ID : %lu], [Category : %x] ", item->handler_id, item->category);
list = g_list_next(list);
list = g_list_next(list);
hcamcorder->buffer_probes = g_list_remove(hcamcorder->buffer_probes, item);
- SAFE_FREE(item);
+ SAFE_G_FREE(item);
break;
} else {
list = g_list_next(list);
hcamcorder->event_probes = g_list_remove(hcamcorder->event_probes, item);
- SAFE_FREE(item);
+ SAFE_G_FREE(item);
} else {
_mmcam_dbg_log("Skip item : [ID : %lu], [Category : %x] ", item->handler_id, item->category);
list = g_list_next(list);
list = g_list_next(list);
hcamcorder->signals = g_list_remove(hcamcorder->signals, item);
- SAFE_FREE(item);
+ SAFE_G_FREE(item);
} else {
_mmcam_dbg_log("Skip item : [ID : %lu], [Category : %x] ", item->handler_id, item->category);
list = g_list_next(list);
if (item->id == MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO) {
MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)item->param.data;
if (cam_fd_info) {
- SAFE_FREE(cam_fd_info->face_info);
- free(cam_fd_info);
- cam_fd_info = NULL;
+ SAFE_G_FREE(cam_fd_info->face_info);
+ SAFE_G_FREE(cam_fd_info);
item->param.data = NULL;
item->param.size = 0;
MMCamRecordingReport *report = (MMCamRecordingReport *)item->param.data;
if (report) {
if (report->recording_filename) {
- free(report->recording_filename);
- report->recording_filename = NULL;
+ SAFE_G_FREE(report->recording_filename);
}
- free(report);
- report = NULL;
-
+ SAFE_G_FREE(report);
item->param.data = NULL;
}
}
g_mutex_unlock(&item->lock);
g_mutex_clear(&item->lock);
- free(item);
- item = NULL;
+ SAFE_G_FREE(item);
/* For not being called again */
return FALSE;
if (data->id == MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO) {
MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)data->param.data;
if (cam_fd_info) {
- SAFE_FREE(cam_fd_info->face_info);
- free(cam_fd_info);
- cam_fd_info = NULL;
-
- data->param.data = NULL;
+ SAFE_G_FREE(cam_fd_info->face_info);
+ SAFE_G_FREE(cam_fd_info);
data->param.size = 0;
}
} else if (data->id == MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED ||
data->id == MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED) {
MMCamRecordingReport *report = (MMCamRecordingReport *)data->param.data;
if (report) {
- if (report->recording_filename) {
- free(report->recording_filename);
- report->recording_filename = NULL;
- }
- free(report);
- report = NULL;
-
+ SAFE_G_FREE(report->recording_filename);
data->param.data = NULL;
}
+ SAFE_G_FREE(report);
}
#endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
if (item->id == MM_MESSAGE_CAMCORDER_FACE_DETECT_INFO) {
MMCamFaceDetectInfo *cam_fd_info = (MMCamFaceDetectInfo *)item->param.data;
if (cam_fd_info) {
- SAFE_FREE(cam_fd_info->face_info);
- free(cam_fd_info);
- cam_fd_info = NULL;
-
- item->param.data = NULL;
+ SAFE_G_FREE(cam_fd_info->face_info);
item->param.size = 0;
}
+ SAFE_G_FREE(cam_fd_info);
} else if (item->id == MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED ||
item->id == MM_MESSAGE_CAMCORDER_AUDIO_CAPTURED) {
MMCamRecordingReport *report = (MMCamRecordingReport *)item->param.data;
if (report) {
- if (report->recording_filename) {
- free(report->recording_filename);
- report->recording_filename = NULL;
- }
- free(report);
- report = NULL;
-
- item->param.data = NULL;
+ SAFE_G_FREE(report->recording_filename);
}
+ SAFE_G_FREE(report);
}
hcamcorder->msg_data = g_list_remove(hcamcorder->msg_data, item);
if (ret == TRUE) {
g_mutex_clear(&item->lock);
- free(item);
- item = NULL;
+ SAFE_G_FREE(item);
_mmcam_dbg_log("remove msg done");
}
/* Send recording report to application */
msg.id = MM_MESSAGE_CAMCORDER_VIDEO_CAPTURED;
- report = (MMCamRecordingReport *)malloc(sizeof(MMCamRecordingReport));
+ report = (MMCamRecordingReport *)g_malloc(sizeof(MMCamRecordingReport));
if (!report) {
_mmcam_dbg_err("Recording report fail(%s). Out of memory.", info->filename);
} else {
- report->recording_filename = strdup(info->filename);
+ report->recording_filename = g_strdup(info->filename);
msg.param.data= report;
msg.param.code = 1;
_mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
MMCAM_TARGET_FILENAME, &temp_filename, &size,
NULL);
if (temp_filename) {
- info->filename = strdup(temp_filename);
+ info->filename = g_strdup(temp_filename);
}
if (!info->filename) {
int ret = 0; \
ret = expr; \
if (ret != MM_ERROR_NONE) {\
- printf("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
+ g_print("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
return; \
}\
} while(0)
} while(0)
#ifndef SAFE_FREE
-#define SAFE_FREE(x) if(x) {g_free(x); x = NULL;}
+#define SAFE_FREE(x) if(x) {free(x); x = NULL;}
#endif
+#ifndef SAFE_G_FREE
+#define SAFE_G_FREE(x) if(x) {g_free(x); x = NULL;}
+#endif
GTimeVal previous;
GTimeVal current;
static int camcordertest_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param)
{
audio_stream_cb_cnt++;
- printf("audio_stream cb is called (stream:%p, data:%p, format:%d, channel:%d, volume_dB:%f, length:%d, timestamp:%d)\n",
+ g_print("audio_stream cb is called (stream:%p, data:%p, format:%d, channel:%d, volume_dB:%f, length:%d, timestamp:%d)\n",
stream, stream->data, stream->format, stream->channel, stream->volume_dB, stream->length, stream->timestamp);
return TRUE;
{
video_stream_cb_cnt++;
- printf("VIDEO STREAM CALLBACK total length :%u, size %dx%d\n", stream->length_total, stream->width, stream->height);
+ g_print("VIDEO STREAM CALLBACK total length :%u, size %dx%d\n", stream->length_total, stream->width, stream->height);
return TRUE;
}
FILE *fp = NULL;
if (!path || !data || size <= 0) {
- printf("ERROR %p %p %d\n", path, data, size);
+ g_print("ERROR %p %p %d\n", path, data, size);
return;
}
fp = fopen(path, "w");
if (fp == NULL) {
- printf("open error! [%s], errno %d\n", path, errno);
+ g_print("open error! [%s], errno %d\n", path, errno);
return;
} else {
- printf("open success [%s]\n", path);
+ g_print("open success [%s]\n", path);
if (fwrite(data, size, 1, fp) != 1) {
- printf("write error! errno %d\n", errno);
+ g_print("write error! errno %d\n", errno);
} else {
- printf("write success [%s]\n", path);
+ g_print("write success [%s]\n", path);
}
fclose(fp);
FILE *fp = NULL;
if (!path || !data || size <= 0) {
- printf("ERROR %p %p %d\n", path, data, size);
+ g_print("ERROR %p %p %d\n", path, data, size);
return;
}
fp = fopen(path, "w");
if (fp == NULL) {
- printf("open error! [%s], errno %d\n", path, errno);
+ g_print("open error! [%s], errno %d\n", path, errno);
return;
} else {
- printf("open success [%s]\n", path);
+ g_print("open success [%s]\n", path);
if (fwrite(data, size, 1, fp) != 1) {
- printf("write error! errno %d\n", errno);
+ g_print("write error! errno %d\n", errno);
} else {
- printf("write success [%s]\n", path);
+ g_print("write success [%s]\n", path);
}
fclose(fp);
if (nret) {
_file_write(m_filename, dst, dst_size);
} else {
- printf("Failed to encode YUV(%d) -> JPEG. \n", main->format);
+ g_print("Failed to encode YUV(%d) -> JPEG. \n", main->format);
}
-
- free(dst);
- dst = NULL;
+ SAFE_FREE(dst);
} else if (!hcamcorder->isMultishot) {
- printf("MM_PIXEL_FORMAT_ENCODED main->data=%p main->length=%d, main->width=%d, main->heigtht=%d \n",
+ g_print("MM_PIXEL_FORMAT_ENCODED main->data=%p main->length=%d, main->width=%d, main->heigtht=%d \n",
main->data, main->length, main->width, main->height);
/* main image */
if (scrnl != NULL) {
_file_write2(IMAGE_CAPTURE_SCREENNAIL_PATH, scrnl->data, scrnl->length);
} else {
- printf( "Screennail buffer is NULL.\n" );
+ g_print( "Screennail buffer is NULL.\n" );
}
/* EXIF data */
if (err < 0) {
warn_msg_t("Multishot mm_camcorder_capture_start = %x", err);
}
-
return FALSE;
}
NULL);
if (err < 0) {
err_msg_t("camcordertest_set_attr_xypair : Error(%s:%x)!!", err_attr_name, err);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
return FALSE;
}
//success
+ SAFE_FREE(err_attr_name);
return TRUE;
}
if(hcamcorder->isMultishot) {
int interval = 0;
flush_stdin();
- printf("\ninput interval(ms) \n");
+ g_print("\ninput interval(ms) \n");
err = scanf("%d", &interval);
if (err == EOF) {
- printf("\nscanf error : errno %d\n", errno);
+ g_print("\nscanf error : errno %d\n", errno);
interval = 300;
}
err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
NULL);
if (err != MM_ERROR_NONE) {
err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
}
} else {
err = mm_camcorder_set_attributes(hcamcorder->camcorder, &err_attr_name,
NULL);
if (err != MM_ERROR_NONE) {
err_msg_t("Attribute setting fail : (%s:%x)", err_attr_name, err);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
}
}
}
err = scanf("%d",&idx);
if (err == EOF) {
- printf("\nscanf error : errno %d\n", errno);
+ g_print("\nscanf error : errno %d\n", errno);
} else {
if( idx > 0 && idx <= width_count ) {
//Set capture size first
}
err = scanf("%d",&idx);
if (err == EOF) {
- printf("\nscanf error : errno %d\n", errno);
+ g_print("\nscanf error : errno %d\n", errno);
} else {
if( idx > 0 && idx <= width_count ) {
//Set capture size first
if( err != MM_ERROR_NONE ) {
g_print( "Failed to set touch AF area.(%x)(%s)\n", err, err_attr_name );
- free( err_attr_name );
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
} else {
g_print( "Succeed to set touch AF area.\n" );
}
NULL);
if (err != MM_ERROR_NONE) {
g_print("Failed to set Camcorder Motion Rate %f [err:0x%x]\n", motion_rate, err);
- free( err_attr_name );
- err_attr_name = NULL;
+ SAFE_FREE(err_attr_name);
} else {
g_print("Succeed to set Motion Rate %f\n", motion_rate);
}
hcamcorder->menu_state = MENU_STATE_MAIN;
}
- if(err_attr_name){
- free( err_attr_name );
- err_attr_name = NULL;
- }
-
g_print("\t bret : 0x%x \n", bret);
+
+ SAFE_FREE(err_attr_name);
+
+ return;
}
break;
}
- g_free(buf);
- buf = NULL;
-
+ SAFE_G_FREE(buf);
print_menu();
} else {
debug_msg_t("No read input");
void validity_print(MMCamAttrsInfo *info)
{
- printf("info(%d,%d, %d))\n", info->type, info->flag, info->validity_type);
- if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY)
- {
- printf("int array(%p, %d)\n", info->int_array.array, info->int_array.count);
- }
- else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE)
- {
- printf("int range(%d, %d)\n", info->int_range.min, info->int_range.max);
- }
- else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_ARRAY)
- {
- printf("double array(%p, %d)\n", info->double_array.array, info->double_array.count);
- }
- else if(info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_RANGE)
- {
- printf("double range(%f, %f)\n", info->double_range.min, info->double_range.max);
- }
- else
- {
- printf("validity none\n");
- }
- return;
+ g_print("info(%d,%d, %d))\n", info->type, info->flag, info->validity_type);
+ if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_ARRAY)
+ {
+ g_print("int array(%p, %d)\n", info->int_array.array, info->int_array.count);
+ }
+ else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_INT_RANGE)
+ {
+ g_print("int range(%d, %d)\n", info->int_range.min, info->int_range.max);
+ }
+ else if (info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_ARRAY)
+ {
+ g_print("double array(%p, %d)\n", info->double_array.array, info->double_array.count);
+ }
+ else if(info->validity_type == MM_CAM_ATTRS_VALID_TYPE_DOUBLE_RANGE)
+ {
+ g_print("double range(%f, %f)\n", info->double_range.min, info->double_range.max);
+ }
+ else
+ {
+ g_print("validity none\n");
+ }
+ return;
}
if (err != MM_ERROR_NONE) {
warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
goto ERROR;
}
if (err < 0) {
warn_msg_t("Init fail. (%s:%x)", err_attr_name, err);
- SAFE_FREE (err_attr_name);
+ SAFE_FREE(err_attr_name);
goto ERROR;
}
mm_camcorder_set_audio_stream_callback(hcamcorder->camcorder, (mm_camcorder_audio_stream_callback)camcordertest_audio_stream_cb, (void*)hcamcorder->camcorder);
#endif /* USE_AUDIO_STREAM_CB */
}
-
+ SAFE_FREE (err_attr_name);
debug_msg_t("Init DONE.");
return TRUE;