Commit 74b40b6b authored by Mikhail Karpenko's avatar Mikhail Karpenko

Fix incorrect initialization between consequent files

parent 313f638e
......@@ -373,6 +373,7 @@ int camogm_start(camogm_state *state, bool restart)
state->formats |= 1 << (state->format);
// exit on unknown formats?
}
state->chunk_frame_cntr = state->frames_per_chunk;
state->max_frames = state->set_max_frames;
state->frames_per_chunk = state->set_frames_per_chunk;
pthread_mutex_lock(&state->mutex);
......@@ -729,7 +730,6 @@ int sendImageFrame(camogm_state *state)
} else {
D6(fprintf(debug_file, "save video frame with time: %ld:%06ld\n", state->audio.ts_video.tv_sec, state->audio.ts_video.tv_usec));
state->audio.begin_of_stream_with_audio = 0;
state->chunk_frame_cntr = state->frames_per_chunk;
}
}
......@@ -1812,7 +1812,7 @@ int listener_loop(camogm_state *state)
} else if (state->prog_state == STATE_STARTING) { // no commands in queue,starting (but not started yet)
// retry starting
switch ((rslt = -camogm_start(state, true))) {
switch ((rslt = -camogm_start(state, false))) {
case 0:
break; // file started OK, nothing to do
case CAMOGM_TOO_EARLY:
......
......@@ -226,7 +226,7 @@ typedef struct {
unsigned int chunk_frame_cntr; ///< QuickTime, number of video frames recorded in current chunk
int set_frames_per_chunk; ///< QuickTime, index for fast forward (sample-to-chunk atom)
int frameno; ///< total image frame counter, does not include audio samples
unsigned long *frame_lengths; ///< QuickTime; pointer to an array of frame lengths wich includes both image frames
unsigned long *frame_lengths; ///< QuickTime; pointer to an array of frame lengths which includes both image frames
///< and audio samples if audio recording is enabled. MSB of each entry indicates
///< the type of frame this length relates to: if MSB = 0 then this is images frame and
///< if MSB = 1 then this is audio sample. Stealing one bit from the length field
......
......@@ -170,7 +170,6 @@ void audio_init_sw(struct audio *audio, bool restart, int frames)
audio->ctx_a.time_last.tv_sec = 0;
audio->ctx_a.time_last.tv_usec = 0;
audio->ctx_a.sample_time = SAMPLE_TIME;
audio->ctx_a.sbuffer_pos = 0;
if (audio->audio_enable == 0)
return;
......@@ -182,6 +181,8 @@ void audio_init_sw(struct audio *audio, bool restart, int frames)
assert(audio->ctx_a.sbuffer == NULL);
audio->ctx_a.sbuffer_pos = 0;
/* decide if camogm can sleep using lseek into video buffer: if audio HW buffer size is less than
* video frame period then we need to process audio stream between video frames and must use shorter
* sleep periods to prevent buffer overflow, and we are good if audio HW buffer is bigger than
......
......@@ -266,6 +266,9 @@ static int camogm_audio_mov(struct audio *audio, void *buff, long len, long slen
/**
* @brief Move to the start of the file and insert generated header
* Asserts:
* array of frame lengths is not defined;
* array of sample-to-chunk audio atoms is not defined;
* @param[in] state pointer to the #camogm_state structure for current sensor port
* @return this function is always successful and returns 0
*/
......@@ -275,6 +278,7 @@ int camogm_end_mov(camogm_state *state)
int port = state->port_num;
assert(state->frame_lengths);
assert(state->audio.audio_samples_to_chunk);
timescale = 10000; // frame period measured in 1/10000 of a second?
// that was in old code. If that works - try to switch to microseconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment