libobs/media-io: Profile audio/video_thread

This commit is contained in:
Palana
2015-07-11 09:14:34 +02:00
parent cf6b75e067
commit c6140b4756
2 changed files with 22 additions and 0 deletions

View File

@@ -22,10 +22,13 @@
#include "../util/darray.h"
#include "../util/circlebuf.h"
#include "../util/platform.h"
#include "../util/profiler.h"
#include "audio-io.h"
#include "audio-resampler.h"
extern profiler_name_store_t *obs_get_profiler_name_store(void);
/* #define DEBUG_AUDIO */
#define nop() do {int invalid = 0;} while(0)
@@ -402,9 +405,14 @@ static void *audio_thread(void *param)
os_set_thread_name("audio-io: audio thread");
const char *audio_thread_name =
profile_store_name(obs_get_profiler_name_store(),
"audio_thread(%s)", audio->info.name);
while (os_event_try(audio->stop_event) == EAGAIN) {
os_sleep_ms(AUDIO_WAIT_TIME);
profile_start(audio_thread_name);
pthread_mutex_lock(&audio->line_mutex);
audio_time = os_gettime_ns() - buffer_time;
@@ -412,6 +420,9 @@ static void *audio_thread(void *param)
prev_time = audio_time;
pthread_mutex_unlock(&audio->line_mutex);
profile_end(audio_thread_name);
profile_reenable_thread();
}
return NULL;

View File

@@ -18,6 +18,7 @@
#include <assert.h>
#include "../util/bmem.h"
#include "../util/platform.h"
#include "../util/profiler.h"
#include "../util/threading.h"
#include "../util/darray.h"
@@ -26,6 +27,8 @@
#include "video-frame.h"
#include "video-scaler.h"
extern profiler_name_store_t *obs_get_profiler_name_store(void);
#define MAX_CONVERT_BUFFERS 3
#define MAX_CACHE_SIZE 16
@@ -162,16 +165,24 @@ static void *video_thread(void *param)
os_set_thread_name("video-io: video thread");
const char *video_thread_name =
profile_store_name(obs_get_profiler_name_store(),
"video_thread(%s)", video->info.name);
while (os_sem_wait(video->update_semaphore) == 0) {
if (video->stop)
break;
profile_start(video_thread_name);
while (!video->stop && !video_output_cur_frame(video)) {
video->total_frames++;
video->skipped_frames++;
}
video->total_frames++;
profile_end(video_thread_name);
profile_reenable_thread();
}
return NULL;