D4(fprintf(debug_file,"?6"));//frame not ready, frame pointer seems valid, but not ready
D3(fprintf(debug_file,"?6"));//frame not ready, frame pointer seems valid, but not ready
D6(fprintf(debug_file,",fp=0x%x\n",fp));//frame not ready, frame pointer seems valid, but not ready
D6(fprintf(debug_file,",FRAME NOT READY fp=0x%x\n",fp));//frame not ready, frame pointer seems valid, but not ready
return-CAMOGM_FRAME_NOT_READY;// frame pointer valid, but no frames yet
return-CAMOGM_FRAME_NOT_READY;// frame pointer valid, but no frames yet
}
}
#ifdef MIN_USED_SIZE
// process skipping frames. TODO: add - skipping time between frames (or better - actual time period - use the nearest frame) instead of the frame number
// process skipping frames. TODO: add - skipping time between frames (or better - actual time period - use the nearest frame) instead of the frame number
if((state->frames_skip>0)&&(state->frames_skip_left[port]>0)){//skipping frames, not seconds.
if((state->frames_skip>0)&&(state->frames_skip_left[port]>0)){//skipping frames, not seconds.
@@ -613,29 +682,38 @@ int sendImageFrame(camogm_state *state)
...
@@ -613,29 +682,38 @@ int sendImageFrame(camogm_state *state)
return-CAMOGM_FRAME_BROKEN;
return-CAMOGM_FRAME_BROKEN;
}
}
D4(fprintf(debug_file,"_2_"));
D4(fprintf(debug_file,"_2_"));
// find location of the timestamp and copy it to the frame_params structure
// find location of the timestamp and copy it to the frame_params structure
timestamp_start=state->cirbuf_rp[port]+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;// magic shift - should index first byte of the time stamp
timestamp_start=state->cirbuf_rp[port]+((state->jpeg_len+CCAM_MMAP_META+3)&(~0x1f))+32-CCAM_MMAP_META_SEC;// magic shift - should index first byte of the time stamp
D6(fprintf(debug_file,"start_jpeg() before open_state_file: Block device positions: start = %llu, current = %llu, end = %llu, params->next_segment_pos=0x%llx\n",
D0(syslog(LOG_INFO,"Raw %s is opened in 0x%08x mode, __O_DIRECT=0x%08x, O_DIRECT=0x%08x",state->rawdev.rawdev_path,fcntl(state->writer_params.blockdev_fd,F_GETFL),__O_DIRECT,O_DIRECT));
D6(fprintf(debug_file,"\ndump iovect array for port %u, chunk_index=%u, chunk_data_index=%u, data_segments=%u\n",state->port_num,state->chunk_index,state->chunk_data_index,state->data_segments));
D6(fprintf(debug_file,"\ndump iovect array for port %u, chunk_index=%u, chunk_data_index=%u, data_segments=%u\n",state->port_num,state->chunk_index,state->chunk_data_index,state->data_segments));
pthread_cond_wait(¶ms->writer_cond,¶ms->writer_mutex);// They are called with mutex locked by the calling thread or undefined behaviour will result.
pthread_cond_signal(¶ms->main_cond);// ********** Do not signal if can write more !
// pthread_cond_signal(¶ms->main_cond); // signal to main thread that prepares data
D6(fprintf(debug_file,"_w06_: wrote data (%d , %d), buffer empty, signal main thread @ %07d\n",params->chunk_page_prep,params->chunk_page_write,get_fpga_usec(state->fd_fparmsall[0],0)));
pthread_cond_broadcast(¶ms->writer_cond);// signal to other writer thread waiting for this one to finish writing
}else{
D6(fprintf(debug_file,"%s_w06b_: wrote data (%d , %d), signal main thread @ %07d\n",dbg_pref, \
D6(fprintf(debug_file,"_w06a_: wrote data (%d , %d), has more to write, do not signal! @ %07d\n",params->chunk_page_prep,params->chunk_page_write,get_fpga_usec(state->fd_fparmsall[0],0)));