int fps = (int)ceil(handle->mm.fps);
int min_qsize = context->read_fps;
- if (fps < min_qsize) {
+ if (fps && fps < min_qsize) {
min_qsize = fps;
}
+ if (!min_qsize) {
+ min_qsize = 1;
+ }
+
if (!context->file_read_thread_running) {
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_BREAK;
}
+ if (switch_queue_size(context->eh.video_queue) < min_qsize / 2) {
+ return SWITCH_STATUS_BREAK;
+ }
+
while((flags & SVR_FLUSH) && switch_queue_size(context->eh.video_queue) > min_qsize) {
if (switch_queue_trypop(context->eh.video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img = (switch_image_t *) pop;
if (!context->file_read_thread_running) {
return SWITCH_STATUS_FALSE;
}
-
+
if ((flags & SVR_BLOCK)) {
status = switch_queue_pop(context->eh.video_queue, &pop);
} else {
int last_h;
int serno;
int pop_count;
+ int video_sync;
switch_image_t *banner_img;
switch_time_t banner_timeout;
struct local_stream_context *next;
switch_memory_pool_t *temp_pool = NULL;
uint32_t dir_count = 0, do_shuffle = 0;
char *p;
+ int old_total = 0;
switch_mutex_lock(globals.mutex);
THREADS++;
is_open = switch_test_flag(use_fh, SWITCH_FILE_OPEN);
+ if (is_open && source->total != old_total && source->total == 1) {
+ if (switch_core_file_has_video(&fh)) {
+ flush_video_queue(source->video_q);
+ }
+
+ switch_buffer_zero(audio_buffer);
+ }
+
+ old_total = source->total;
+
if (source->hup) {
source->hup = 0;
if (is_open) {
switch_core_file_read(&fh, abuf, &olen);
olen = source->samples;
}
-
+
if (switch_core_file_read(use_fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
switch_core_file_close(use_fh);
flush_video_queue(source->video_q);
break;
}
+ source->prebuf = source->samples * 2 * source->channels * 10;
+
if (!is_open || used >= source->prebuf || (source->total && used > source->samples * 2 * source->channels)) {
void *pop;
local_stream_context_t *context = handle->private_info;
switch_status_t status;
switch_time_t now;
-
+ int fps = (int)ceil(handle->mm.fps);
+ int min_qsize = fps;
+
if (!(context->ready && context->source->ready)) {
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_BREAK;
}
- while(context->ready && context->source->ready && (flags & SVR_FLUSH) && switch_queue_size(context->video_q) > 1) {
+ context->video_sync = 1;
+
+ while(context->ready && context->source->ready && (flags & SVR_FLUSH) && switch_queue_size(context->video_q) > min_qsize) {
if (switch_queue_trypop(context->video_q, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img = (switch_image_t *) pop;
switch_img_free(&img);