mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-06-30 08:33:32 +00:00
libobs: Replace circlebuf with deque
This commit is contained in:
parent
10a47756b0
commit
2963959e71
|
@ -4,7 +4,7 @@
|
|||
#include <CoreAudio/CoreAudio.h>
|
||||
|
||||
#include "../../media-io/audio-resampler.h"
|
||||
#include "../../util/circlebuf.h"
|
||||
#include "../../util/deque.h"
|
||||
#include "../../util/threading.h"
|
||||
#include "../../util/platform.h"
|
||||
#include "../../obs-internal.h"
|
||||
|
@ -18,8 +18,8 @@ struct audio_monitor {
|
|||
AudioQueueBufferRef buffers[3];
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
struct circlebuf empty_buffers;
|
||||
struct circlebuf new_data;
|
||||
struct deque empty_buffers;
|
||||
struct deque new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t wait_size;
|
||||
|
@ -39,9 +39,9 @@ static inline bool fill_buffer(struct audio_monitor *monitor)
|
|||
return false;
|
||||
}
|
||||
|
||||
circlebuf_pop_front(&monitor->empty_buffers, &buf, sizeof(buf));
|
||||
circlebuf_pop_front(&monitor->new_data, buf->mAudioData,
|
||||
monitor->buffer_size);
|
||||
deque_pop_front(&monitor->empty_buffers, &buf, sizeof(buf));
|
||||
deque_pop_front(&monitor->new_data, buf->mAudioData,
|
||||
monitor->buffer_size);
|
||||
|
||||
buf->mAudioDataByteSize = (UInt32)monitor->buffer_size;
|
||||
|
||||
|
@ -59,7 +59,7 @@ static void on_audio_pause(void *data, calldata_t *calldata)
|
|||
UNUSED_PARAMETER(calldata);
|
||||
struct audio_monitor *monitor = data;
|
||||
pthread_mutex_lock(&monitor->mutex);
|
||||
circlebuf_free(&monitor->new_data);
|
||||
deque_free(&monitor->new_data);
|
||||
pthread_mutex_unlock(&monitor->mutex);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
}
|
||||
|
||||
pthread_mutex_lock(&monitor->mutex);
|
||||
circlebuf_push_back(&monitor->new_data, resample_data[0], bytes);
|
||||
deque_push_back(&monitor->new_data, resample_data[0], bytes);
|
||||
|
||||
if (monitor->new_data.size >= monitor->wait_size) {
|
||||
monitor->wait_size = 0;
|
||||
|
@ -133,7 +133,7 @@ static void buffer_audio(void *data, AudioQueueRef aq, AudioQueueBufferRef buf)
|
|||
struct audio_monitor *monitor = data;
|
||||
|
||||
pthread_mutex_lock(&monitor->mutex);
|
||||
circlebuf_push_back(&monitor->empty_buffers, &buf, sizeof(buf));
|
||||
deque_push_back(&monitor->empty_buffers, &buf, sizeof(buf));
|
||||
while (monitor->empty_buffers.size > 0) {
|
||||
if (!fill_buffer(monitor)) {
|
||||
break;
|
||||
|
@ -231,9 +231,8 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
}
|
||||
|
||||
circlebuf_push_back(&monitor->empty_buffers,
|
||||
&monitor->buffers[i],
|
||||
sizeof(monitor->buffers[i]));
|
||||
deque_push_back(&monitor->empty_buffers, &monitor->buffers[i],
|
||||
sizeof(monitor->buffers[i]));
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&monitor->mutex, NULL) != 0) {
|
||||
|
@ -287,8 +286,8 @@ static void audio_monitor_free(struct audio_monitor *monitor)
|
|||
}
|
||||
|
||||
audio_resampler_destroy(monitor->resampler);
|
||||
circlebuf_free(&monitor->empty_buffers);
|
||||
circlebuf_free(&monitor->new_data);
|
||||
deque_free(&monitor->empty_buffers);
|
||||
deque_free(&monitor->new_data);
|
||||
pthread_mutex_destroy(&monitor->mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ struct audio_monitor {
|
|||
uint_fast32_t packets;
|
||||
uint_fast64_t frames;
|
||||
|
||||
struct circlebuf new_data;
|
||||
struct deque new_data;
|
||||
audio_resampler_t *resampler;
|
||||
|
||||
bool ignore;
|
||||
|
@ -225,7 +225,7 @@ static void do_stream_write(void *param)
|
|||
goto finish;
|
||||
}
|
||||
|
||||
circlebuf_pop_front(&data->new_data, buffer, bytesToFill);
|
||||
deque_pop_front(&data->new_data, buffer, bytesToFill);
|
||||
|
||||
pa_stream_write(data->stream, buffer, bytesToFill, NULL, 0LL,
|
||||
PA_SEEK_RELATIVE);
|
||||
|
@ -273,7 +273,7 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
}
|
||||
}
|
||||
|
||||
circlebuf_push_back(&monitor->new_data, resample_data[0], bytes);
|
||||
deque_push_back(&monitor->new_data, resample_data[0], bytes);
|
||||
monitor->packets++;
|
||||
monitor->frames += resample_frames;
|
||||
|
||||
|
@ -502,7 +502,7 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
monitor->source, on_audio_playback, monitor);
|
||||
|
||||
audio_resampler_destroy(monitor->resampler);
|
||||
circlebuf_free(&monitor->new_data);
|
||||
deque_free(&monitor->new_data);
|
||||
|
||||
if (monitor->stream)
|
||||
pulseaudio_stop_playback(monitor);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "../../media-io/audio-resampler.h"
|
||||
#include "../../util/circlebuf.h"
|
||||
#include "../../util/deque.h"
|
||||
#include "../../util/platform.h"
|
||||
#include "../../util/darray.h"
|
||||
#include "../../util/util_uint64.h"
|
||||
|
@ -43,7 +43,7 @@ struct audio_monitor {
|
|||
bool ignore;
|
||||
|
||||
int64_t lowest_audio_offset;
|
||||
struct circlebuf delay_buffer;
|
||||
struct deque delay_buffer;
|
||||
uint32_t delay_size;
|
||||
|
||||
DARRAY(float) buf;
|
||||
|
@ -65,14 +65,14 @@ static bool process_audio_delay(struct audio_monitor *monitor, float **data,
|
|||
|
||||
/* cut off audio if long-since leftover audio in delay buffer */
|
||||
if (cur_time - monitor->last_recv_time > 1000000000)
|
||||
circlebuf_free(&monitor->delay_buffer);
|
||||
deque_free(&monitor->delay_buffer);
|
||||
monitor->last_recv_time = cur_time;
|
||||
|
||||
ts += monitor->source->sync_offset;
|
||||
|
||||
circlebuf_push_back(&monitor->delay_buffer, &ts, sizeof(ts));
|
||||
circlebuf_push_back(&monitor->delay_buffer, frames, sizeof(*frames));
|
||||
circlebuf_push_back(&monitor->delay_buffer, *data, *frames * blocksize);
|
||||
deque_push_back(&monitor->delay_buffer, &ts, sizeof(ts));
|
||||
deque_push_back(&monitor->delay_buffer, frames, sizeof(*frames));
|
||||
deque_push_back(&monitor->delay_buffer, *data, *frames * blocksize);
|
||||
|
||||
if (!monitor->prev_video_ts) {
|
||||
monitor->prev_video_ts = last_frame_ts;
|
||||
|
@ -88,8 +88,7 @@ static bool process_audio_delay(struct audio_monitor *monitor, float **data,
|
|||
size_t size;
|
||||
bool bad_diff;
|
||||
|
||||
circlebuf_peek_front(&monitor->delay_buffer, &cur_ts,
|
||||
sizeof(ts));
|
||||
deque_peek_front(&monitor->delay_buffer, &cur_ts, sizeof(ts));
|
||||
front_ts = cur_ts - util_mul_div64(pad, 1000000000ULL,
|
||||
monitor->sample_rate);
|
||||
diff = (int64_t)front_ts - (int64_t)last_frame_ts;
|
||||
|
@ -109,14 +108,14 @@ static bool process_audio_delay(struct audio_monitor *monitor, float **data,
|
|||
return false;
|
||||
}
|
||||
|
||||
circlebuf_pop_front(&monitor->delay_buffer, NULL, sizeof(ts));
|
||||
circlebuf_pop_front(&monitor->delay_buffer, frames,
|
||||
sizeof(*frames));
|
||||
deque_pop_front(&monitor->delay_buffer, NULL, sizeof(ts));
|
||||
deque_pop_front(&monitor->delay_buffer, frames,
|
||||
sizeof(*frames));
|
||||
|
||||
size = *frames * blocksize;
|
||||
da_resize(monitor->buf, size);
|
||||
circlebuf_pop_front(&monitor->delay_buffer, monitor->buf.array,
|
||||
size);
|
||||
deque_pop_front(&monitor->delay_buffer, monitor->buf.array,
|
||||
size);
|
||||
|
||||
/* cut audio if dragging */
|
||||
if (!bad_diff && diff < -75000000 &&
|
||||
|
@ -295,7 +294,7 @@ static void audio_monitor_free_for_reconnect(struct audio_monitor *monitor)
|
|||
audio_resampler_destroy(monitor->resampler);
|
||||
monitor->resampler = NULL;
|
||||
|
||||
circlebuf_free(&monitor->delay_buffer);
|
||||
deque_free(&monitor->delay_buffer);
|
||||
da_free(monitor->buf);
|
||||
}
|
||||
|
||||
|
@ -399,7 +398,7 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
safe_release(monitor->client);
|
||||
safe_release(monitor->render);
|
||||
audio_resampler_destroy(monitor->resampler);
|
||||
circlebuf_free(&monitor->delay_buffer);
|
||||
deque_free(&monitor->delay_buffer);
|
||||
da_free(monitor->buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "../util/threading.h"
|
||||
#include "../util/darray.h"
|
||||
#include "../util/circlebuf.h"
|
||||
#include "../util/deque.h"
|
||||
#include "../util/platform.h"
|
||||
#include "../util/profiler.h"
|
||||
#include "../util/util_uint64.h"
|
||||
|
|
|
@ -92,8 +92,8 @@ static bool ignore_audio(obs_source_t *source, size_t channels,
|
|||
name);
|
||||
#endif
|
||||
for (size_t ch = 0; ch < channels; ch++)
|
||||
circlebuf_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
source->audio_input_buf[0].size);
|
||||
deque_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
source->audio_input_buf[0].size);
|
||||
source->last_audio_input_buf_size = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ static bool ignore_audio(obs_source_t *source, size_t channels,
|
|||
(uint64_t)drop, (uint64_t)num_floats);
|
||||
#endif
|
||||
for (size_t ch = 0; ch < channels; ch++)
|
||||
circlebuf_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
drop * sizeof(float));
|
||||
deque_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
drop * sizeof(float));
|
||||
|
||||
source->last_audio_input_buf_size = 0;
|
||||
source->audio_ts +=
|
||||
|
@ -175,8 +175,8 @@ static bool discard_if_stopped(obs_source_t *source, size_t channels)
|
|||
}
|
||||
|
||||
for (size_t ch = 0; ch < channels; ch++)
|
||||
circlebuf_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
source->audio_input_buf[ch].size);
|
||||
deque_pop_front(&source->audio_input_buf[ch], NULL,
|
||||
source->audio_input_buf[ch].size);
|
||||
|
||||
source->pending_stop = false;
|
||||
source->audio_ts = 0;
|
||||
|
@ -279,7 +279,7 @@ static inline void discard_audio(struct obs_core_audio *audio,
|
|||
}
|
||||
|
||||
for (size_t ch = 0; ch < channels; ch++)
|
||||
circlebuf_pop_front(&source->audio_input_buf[ch], NULL, size);
|
||||
deque_pop_front(&source->audio_input_buf[ch], NULL, size);
|
||||
|
||||
source->last_audio_input_buf_size = 0;
|
||||
|
||||
|
@ -340,8 +340,8 @@ static void set_fixed_audio_buffering(struct obs_core_audio *audio,
|
|||
new_ts.start, new_ts.end);
|
||||
#endif
|
||||
|
||||
circlebuf_push_front(&audio->buffered_timestamps, &new_ts,
|
||||
sizeof(new_ts));
|
||||
deque_push_front(&audio->buffered_timestamps, &new_ts,
|
||||
sizeof(new_ts));
|
||||
}
|
||||
|
||||
*ts = new_ts;
|
||||
|
@ -414,8 +414,8 @@ static void add_audio_buffering(struct obs_core_audio *audio,
|
|||
new_ts.start, new_ts.end);
|
||||
#endif
|
||||
|
||||
circlebuf_push_front(&audio->buffered_timestamps, &new_ts,
|
||||
sizeof(new_ts));
|
||||
deque_push_front(&audio->buffered_timestamps, &new_ts,
|
||||
sizeof(new_ts));
|
||||
}
|
||||
|
||||
*ts = new_ts;
|
||||
|
@ -507,7 +507,7 @@ static inline void execute_audio_tasks(void)
|
|||
pthread_mutex_lock(&audio->task_mutex);
|
||||
if (audio->tasks.size) {
|
||||
struct obs_task_info info;
|
||||
circlebuf_pop_front(&audio->tasks, &info, sizeof(info));
|
||||
deque_pop_front(&audio->tasks, &info, sizeof(info));
|
||||
info.task(info.param);
|
||||
}
|
||||
tasks_remaining = !!audio->tasks.size;
|
||||
|
@ -531,8 +531,8 @@ bool audio_callback(void *param, uint64_t start_ts_in, uint64_t end_ts_in,
|
|||
da_resize(audio->render_order, 0);
|
||||
da_resize(audio->root_nodes, 0);
|
||||
|
||||
circlebuf_push_back(&audio->buffered_timestamps, &ts, sizeof(ts));
|
||||
circlebuf_peek_front(&audio->buffered_timestamps, &ts, sizeof(ts));
|
||||
deque_push_back(&audio->buffered_timestamps, &ts, sizeof(ts));
|
||||
deque_peek_front(&audio->buffered_timestamps, &ts, sizeof(ts));
|
||||
min_ts = ts.start;
|
||||
|
||||
audio_size = AUDIO_OUTPUT_FRAMES * sizeof(float);
|
||||
|
@ -676,7 +676,7 @@ bool audio_callback(void *param, uint64_t start_ts_in, uint64_t end_ts_in,
|
|||
/* release audio sources */
|
||||
release_audio_sources(audio);
|
||||
|
||||
circlebuf_pop_front(&audio->buffered_timestamps, NULL, sizeof(ts));
|
||||
deque_pop_front(&audio->buffered_timestamps, NULL, sizeof(ts));
|
||||
|
||||
*out_ts = ts.start;
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ static void remove_connection(struct obs_encoder *encoder, bool shutdown)
|
|||
static inline void free_audio_buffers(struct obs_encoder *encoder)
|
||||
{
|
||||
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
|
||||
circlebuf_free(&encoder->audio_input_buffer[i]);
|
||||
deque_free(&encoder->audio_input_buffer[i]);
|
||||
bfree(encoder->audio_output_buffer[i]);
|
||||
encoder->audio_output_buffer[i] = NULL;
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ wait_for_audio:
|
|||
static void clear_audio(struct obs_encoder *encoder)
|
||||
{
|
||||
for (size_t i = 0; i < encoder->planes; i++)
|
||||
circlebuf_free(&encoder->audio_input_buffer[i]);
|
||||
deque_free(&encoder->audio_input_buffer[i]);
|
||||
}
|
||||
|
||||
static inline void push_back_audio(struct obs_encoder *encoder,
|
||||
|
@ -1429,8 +1429,8 @@ static inline void push_back_audio(struct obs_encoder *encoder,
|
|||
|
||||
/* push in to the circular buffer */
|
||||
for (size_t i = 0; i < encoder->planes; i++)
|
||||
circlebuf_push_back(&encoder->audio_input_buffer[i],
|
||||
data->data[i] + offset_size, size);
|
||||
deque_push_back(&encoder->audio_input_buffer[i],
|
||||
data->data[i] + offset_size, size);
|
||||
}
|
||||
|
||||
static inline size_t calc_offset_size(struct obs_encoder *encoder,
|
||||
|
@ -1450,7 +1450,7 @@ static void start_from_buffer(struct obs_encoder *encoder, uint64_t v_start_ts)
|
|||
for (size_t i = 0; i < MAX_AV_PLANES; i++) {
|
||||
audio.data[i] = encoder->audio_input_buffer[i].data;
|
||||
memset(&encoder->audio_input_buffer[i], 0,
|
||||
sizeof(struct circlebuf));
|
||||
sizeof(struct deque));
|
||||
}
|
||||
|
||||
if (encoder->first_raw_ts < v_start_ts)
|
||||
|
@ -1528,9 +1528,9 @@ static bool send_audio_data(struct obs_encoder *encoder)
|
|||
memset(&enc_frame, 0, sizeof(struct encoder_frame));
|
||||
|
||||
for (size_t i = 0; i < encoder->planes; i++) {
|
||||
circlebuf_pop_front(&encoder->audio_input_buffer[i],
|
||||
encoder->audio_output_buffer[i],
|
||||
encoder->framesize_bytes);
|
||||
deque_pop_front(&encoder->audio_input_buffer[i],
|
||||
encoder->audio_output_buffer[i],
|
||||
encoder->framesize_bytes);
|
||||
|
||||
enc_frame.data[i] = encoder->audio_output_buffer[i];
|
||||
enc_frame.linesize[i] = (uint32_t)encoder->framesize_bytes;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "util/c99defs.h"
|
||||
#include "util/darray.h"
|
||||
#include "util/circlebuf.h"
|
||||
#include "util/deque.h"
|
||||
#include "util/dstr.h"
|
||||
#include "util/threading.h"
|
||||
#include "util/platform.h"
|
||||
|
@ -281,8 +281,8 @@ struct obs_core_video_mix {
|
|||
bool texture_converted;
|
||||
bool using_nv12_tex;
|
||||
bool using_p010_tex;
|
||||
struct circlebuf vframe_info_buffer;
|
||||
struct circlebuf vframe_info_buffer_gpu;
|
||||
struct deque vframe_info_buffer;
|
||||
struct deque vframe_info_buffer_gpu;
|
||||
gs_stagesurf_t *mapped_surfaces[NUM_CHANNELS];
|
||||
int cur_texture;
|
||||
volatile long raw_active;
|
||||
|
@ -291,8 +291,8 @@ struct obs_core_video_mix {
|
|||
bool raw_was_active;
|
||||
bool was_active;
|
||||
pthread_mutex_t gpu_encoder_mutex;
|
||||
struct circlebuf gpu_encoder_queue;
|
||||
struct circlebuf gpu_encoder_avail_queue;
|
||||
struct deque gpu_encoder_queue;
|
||||
struct deque gpu_encoder_avail_queue;
|
||||
DARRAY(obs_encoder_t *) gpu_encoders;
|
||||
os_sem_t *gpu_encode_semaphore;
|
||||
os_event_t *gpu_encode_inactive;
|
||||
|
@ -359,7 +359,7 @@ struct obs_core_video {
|
|||
float hdr_nominal_peak_level;
|
||||
|
||||
pthread_mutex_t task_mutex;
|
||||
struct circlebuf tasks;
|
||||
struct deque tasks;
|
||||
|
||||
pthread_mutex_t mixes_mutex;
|
||||
DARRAY(struct obs_core_video_mix *) mixes;
|
||||
|
@ -375,7 +375,7 @@ struct obs_core_audio {
|
|||
DARRAY(struct obs_source *) root_nodes;
|
||||
|
||||
uint64_t buffered_ts;
|
||||
struct circlebuf buffered_timestamps;
|
||||
struct deque buffered_timestamps;
|
||||
uint64_t buffering_wait_ticks;
|
||||
int total_buffering_ticks;
|
||||
int max_buffering_ticks;
|
||||
|
@ -387,7 +387,7 @@ struct obs_core_audio {
|
|||
char *monitoring_device_id;
|
||||
|
||||
pthread_mutex_t task_mutex;
|
||||
struct circlebuf tasks;
|
||||
struct deque tasks;
|
||||
};
|
||||
|
||||
/* user sources, output channels, and displays */
|
||||
|
@ -768,7 +768,7 @@ struct obs_source {
|
|||
struct obs_source *next_audio_source;
|
||||
struct obs_source **prev_next_audio_source;
|
||||
uint64_t audio_ts;
|
||||
struct circlebuf audio_input_buf[MAX_AUDIO_CHANNELS];
|
||||
struct deque audio_input_buf[MAX_AUDIO_CHANNELS];
|
||||
size_t last_audio_input_buf_size;
|
||||
DARRAY(struct audio_action) audio_actions;
|
||||
float *audio_output_buf[MAX_AUDIO_MIXES][MAX_AUDIO_CHANNELS];
|
||||
|
@ -1136,7 +1136,7 @@ struct obs_output {
|
|||
|
||||
struct pause_data pause;
|
||||
|
||||
struct circlebuf audio_buffer[MAX_AUDIO_MIXES][MAX_AV_PLANES];
|
||||
struct deque audio_buffer[MAX_AUDIO_MIXES][MAX_AV_PLANES];
|
||||
uint64_t audio_start_ts;
|
||||
uint64_t video_start_ts;
|
||||
size_t audio_size;
|
||||
|
@ -1157,13 +1157,13 @@ struct obs_output {
|
|||
struct caption_text *caption_head;
|
||||
struct caption_text *caption_tail;
|
||||
|
||||
struct circlebuf caption_data;
|
||||
struct deque caption_data;
|
||||
|
||||
bool valid;
|
||||
|
||||
uint64_t active_delay_ns;
|
||||
encoded_callback_t delay_callback;
|
||||
struct circlebuf delay_data; /* struct delay_data */
|
||||
struct deque delay_data; /* struct delay_data */
|
||||
pthread_mutex_t delay_mutex;
|
||||
uint32_t delay_sec;
|
||||
uint32_t delay_flags;
|
||||
|
@ -1270,7 +1270,7 @@ struct obs_encoder {
|
|||
|
||||
int64_t cur_pts;
|
||||
|
||||
struct circlebuf audio_input_buffer[MAX_AV_PLANES];
|
||||
struct deque audio_input_buffer[MAX_AV_PLANES];
|
||||
uint8_t *audio_output_buffer[MAX_AV_PLANES];
|
||||
|
||||
/* if a video encoder is paired with an audio encoder, make it start
|
||||
|
|
|
@ -54,7 +54,7 @@ static inline void push_packet(struct obs_output *output,
|
|||
obs_encoder_packet_create_instance(&dd.packet, packet);
|
||||
|
||||
pthread_mutex_lock(&output->delay_mutex);
|
||||
circlebuf_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
deque_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
pthread_mutex_unlock(&output->delay_mutex);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ void obs_output_cleanup_delay(obs_output_t *output)
|
|||
struct delay_data dd;
|
||||
|
||||
while (output->delay_data.size) {
|
||||
circlebuf_pop_front(&output->delay_data, &dd, sizeof(dd));
|
||||
deque_pop_front(&output->delay_data, &dd, sizeof(dd));
|
||||
if (dd.msg == DELAY_MSG_PACKET) {
|
||||
obs_encoder_packet_release(&dd.packet);
|
||||
}
|
||||
|
@ -106,15 +106,14 @@ static inline bool pop_packet(struct obs_output *output, uint64_t t)
|
|||
pthread_mutex_lock(&output->delay_mutex);
|
||||
|
||||
if (output->delay_data.size) {
|
||||
circlebuf_peek_front(&output->delay_data, &dd, sizeof(dd));
|
||||
deque_peek_front(&output->delay_data, &dd, sizeof(dd));
|
||||
elapsed_time = (t - dd.ts);
|
||||
|
||||
if (preserve && output->reconnecting) {
|
||||
output->active_delay_ns = elapsed_time;
|
||||
|
||||
} else if (elapsed_time > output->active_delay_ns) {
|
||||
circlebuf_pop_front(&output->delay_data, NULL,
|
||||
sizeof(dd));
|
||||
deque_pop_front(&output->delay_data, NULL, sizeof(dd));
|
||||
popped = true;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ bool obs_output_delay_start(obs_output_t *output)
|
|||
}
|
||||
|
||||
pthread_mutex_lock(&output->delay_mutex);
|
||||
circlebuf_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
deque_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
pthread_mutex_unlock(&output->delay_mutex);
|
||||
|
||||
os_atomic_inc_long(&output->delay_restart_refs);
|
||||
|
@ -191,7 +190,7 @@ void obs_output_delay_stop(obs_output_t *output)
|
|||
};
|
||||
|
||||
pthread_mutex_lock(&output->delay_mutex);
|
||||
circlebuf_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
deque_push_back(&output->delay_data, &dd, sizeof(dd));
|
||||
pthread_mutex_unlock(&output->delay_mutex);
|
||||
|
||||
do_output_signal(output, "stopping");
|
||||
|
|
|
@ -250,7 +250,7 @@ static inline void clear_raw_audio_buffers(obs_output_t *output)
|
|||
{
|
||||
for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {
|
||||
for (size_t j = 0; j < MAX_AV_PLANES; j++) {
|
||||
circlebuf_free(&output->audio_buffer[i][j]);
|
||||
deque_free(&output->audio_buffer[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ void obs_output_destroy(obs_output_t *output)
|
|||
pthread_mutex_destroy(&output->delay_mutex);
|
||||
os_event_destroy(output->reconnect_stop_event);
|
||||
obs_context_data_free(&output->context);
|
||||
circlebuf_free(&output->delay_data);
|
||||
circlebuf_free(&output->caption_data);
|
||||
deque_free(&output->delay_data);
|
||||
deque_free(&output->caption_data);
|
||||
if (output->owns_info_id)
|
||||
bfree((void *)output->info.id);
|
||||
if (output->last_error_message)
|
||||
|
@ -340,8 +340,8 @@ bool obs_output_actual_start(obs_output_t *output)
|
|||
|
||||
output->caption_timestamp = 0;
|
||||
|
||||
circlebuf_free(&output->caption_data);
|
||||
circlebuf_init(&output->caption_data);
|
||||
deque_free(&output->caption_data);
|
||||
deque_init(&output->caption_data);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -1491,8 +1491,8 @@ static bool add_caption(struct obs_output *output, struct encoder_packet *out)
|
|||
void *caption_buf = bzalloc(3 * sizeof(uint8_t));
|
||||
|
||||
while (output->caption_data.size > 0) {
|
||||
circlebuf_pop_front(&output->caption_data, caption_buf,
|
||||
3 * sizeof(uint8_t));
|
||||
deque_pop_front(&output->caption_data, caption_buf,
|
||||
3 * sizeof(uint8_t));
|
||||
|
||||
if ((((uint8_t *)caption_buf)[0] & 0x3) != 0) {
|
||||
// only send cea 608
|
||||
|
@ -2157,17 +2157,16 @@ static void default_raw_audio_callback(void *param, size_t mix_idx,
|
|||
frame_size_bytes = AUDIO_OUTPUT_FRAMES * output->audio_size;
|
||||
|
||||
for (size_t i = 0; i < output->planes; i++)
|
||||
circlebuf_push_back(&output->audio_buffer[mix_idx][i],
|
||||
out.data[i],
|
||||
out.frames * output->audio_size);
|
||||
deque_push_back(&output->audio_buffer[mix_idx][i], out.data[i],
|
||||
out.frames * output->audio_size);
|
||||
|
||||
/* -------------- */
|
||||
|
||||
while (output->audio_buffer[mix_idx][0].size > frame_size_bytes) {
|
||||
for (size_t i = 0; i < output->planes; i++) {
|
||||
circlebuf_pop_front(&output->audio_buffer[mix_idx][i],
|
||||
output->audio_data[i],
|
||||
frame_size_bytes);
|
||||
deque_pop_front(&output->audio_buffer[mix_idx][i],
|
||||
output->audio_data[i],
|
||||
frame_size_bytes);
|
||||
out.data[i] = (uint8_t *)output->audio_data[i];
|
||||
}
|
||||
|
||||
|
@ -2856,9 +2855,8 @@ void obs_output_caption(obs_output_t *output,
|
|||
{
|
||||
pthread_mutex_lock(&output->caption_mutex);
|
||||
for (size_t i = 0; i < captions->packets; i++) {
|
||||
circlebuf_push_back(&output->caption_data,
|
||||
captions->data + (i * 3),
|
||||
3 * sizeof(uint8_t));
|
||||
deque_push_back(&output->caption_data, captions->data + (i * 3),
|
||||
3 * sizeof(uint8_t));
|
||||
}
|
||||
pthread_mutex_unlock(&output->caption_mutex);
|
||||
}
|
||||
|
|
|
@ -724,7 +724,7 @@ static void obs_source_destroy_defer(struct obs_source *source)
|
|||
for (i = 0; i < MAX_AV_PLANES; i++)
|
||||
bfree(source->audio_data.data[i]);
|
||||
for (i = 0; i < MAX_AUDIO_CHANNELS; i++)
|
||||
circlebuf_free(&source->audio_input_buf[i]);
|
||||
deque_free(&source->audio_input_buf[i]);
|
||||
audio_resampler_destroy(source->resampler);
|
||||
bfree(source->audio_output_buf[0][0]);
|
||||
bfree(source->audio_mix_buf[0]);
|
||||
|
@ -1410,8 +1410,8 @@ static void reset_audio_data(obs_source_t *source, uint64_t os_time)
|
|||
{
|
||||
for (size_t i = 0; i < MAX_AUDIO_CHANNELS; i++) {
|
||||
if (source->audio_input_buf[i].size)
|
||||
circlebuf_pop_front(&source->audio_input_buf[i], NULL,
|
||||
source->audio_input_buf[i].size);
|
||||
deque_pop_front(&source->audio_input_buf[i], NULL,
|
||||
source->audio_input_buf[i].size);
|
||||
}
|
||||
|
||||
source->last_audio_input_buf_size = 0;
|
||||
|
@ -1485,11 +1485,11 @@ static void source_output_audio_place(obs_source_t *source,
|
|||
return;
|
||||
|
||||
for (size_t i = 0; i < channels; i++) {
|
||||
circlebuf_place(&source->audio_input_buf[i], buf_placement,
|
||||
in->data[i], size);
|
||||
circlebuf_pop_back(&source->audio_input_buf[i], NULL,
|
||||
source->audio_input_buf[i].size -
|
||||
(buf_placement + size));
|
||||
deque_place(&source->audio_input_buf[i], buf_placement,
|
||||
in->data[i], size);
|
||||
deque_pop_back(&source->audio_input_buf[i], NULL,
|
||||
source->audio_input_buf[i].size -
|
||||
(buf_placement + size));
|
||||
}
|
||||
|
||||
source->last_audio_input_buf_size = 0;
|
||||
|
@ -1507,8 +1507,7 @@ static inline void source_output_audio_push_back(obs_source_t *source,
|
|||
return;
|
||||
|
||||
for (size_t i = 0; i < channels; i++)
|
||||
circlebuf_push_back(&source->audio_input_buf[i], in->data[i],
|
||||
size);
|
||||
deque_push_back(&source->audio_input_buf[i], in->data[i], size);
|
||||
|
||||
/* reset audio input buffer size to ensure that audio doesn't get
|
||||
* perpetually cut */
|
||||
|
@ -5728,8 +5727,8 @@ static inline void process_audio_source_tick(obs_source_t *source,
|
|||
}
|
||||
|
||||
for (size_t ch = 0; ch < channels; ch++)
|
||||
circlebuf_peek_front(&source->audio_input_buf[ch],
|
||||
source->audio_output_buf[0][ch], size);
|
||||
deque_peek_front(&source->audio_input_buf[ch],
|
||||
source->audio_output_buf[0][ch], size);
|
||||
|
||||
pthread_mutex_unlock(&source->audio_buf_mutex);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static void *gpu_encode_thread(struct obs_core_video_mix *video)
|
|||
|
||||
pthread_mutex_lock(&video->gpu_encoder_mutex);
|
||||
|
||||
circlebuf_pop_front(&video->gpu_encoder_queue, &tf, sizeof(tf));
|
||||
deque_pop_front(&video->gpu_encoder_queue, &tf, sizeof(tf));
|
||||
timestamp = tf.timestamp;
|
||||
lock_key = tf.lock_key;
|
||||
next_key = tf.lock_key;
|
||||
|
@ -146,13 +146,13 @@ static void *gpu_encode_thread(struct obs_core_video_mix *video)
|
|||
|
||||
if (--tf.count) {
|
||||
tf.timestamp += interval;
|
||||
circlebuf_push_front(&video->gpu_encoder_queue, &tf,
|
||||
sizeof(tf));
|
||||
deque_push_front(&video->gpu_encoder_queue, &tf,
|
||||
sizeof(tf));
|
||||
|
||||
video_output_inc_texture_skipped_frames(video->video);
|
||||
} else {
|
||||
circlebuf_push_back(&video->gpu_encoder_avail_queue,
|
||||
&tf, sizeof(tf));
|
||||
deque_push_back(&video->gpu_encoder_avail_queue, &tf,
|
||||
sizeof(tf));
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&video->gpu_encoder_mutex);
|
||||
|
@ -179,7 +179,7 @@ bool init_gpu_encoding(struct obs_core_video_mix *video)
|
|||
|
||||
video->gpu_encode_stop = false;
|
||||
|
||||
circlebuf_reserve(&video->gpu_encoder_avail_queue, NUM_ENCODE_TEXTURES);
|
||||
deque_reserve(&video->gpu_encoder_avail_queue, NUM_ENCODE_TEXTURES);
|
||||
for (size_t i = 0; i < NUM_ENCODE_TEXTURES; i++) {
|
||||
gs_texture_t *tex;
|
||||
gs_texture_t *tex_uv;
|
||||
|
@ -203,8 +203,8 @@ bool init_gpu_encoding(struct obs_core_video_mix *video)
|
|||
.tex_uv = tex_uv,
|
||||
.handle = handle};
|
||||
|
||||
circlebuf_push_back(&video->gpu_encoder_avail_queue, &frame,
|
||||
sizeof(frame));
|
||||
deque_push_back(&video->gpu_encoder_avail_queue, &frame,
|
||||
sizeof(frame));
|
||||
}
|
||||
|
||||
if (os_sem_init(&video->gpu_encode_semaphore, 0) != 0)
|
||||
|
@ -247,18 +247,18 @@ void free_gpu_encoding(struct obs_core_video_mix *video)
|
|||
video->gpu_encode_inactive = NULL;
|
||||
}
|
||||
|
||||
#define free_circlebuf(x) \
|
||||
do { \
|
||||
while (x.size) { \
|
||||
struct obs_tex_frame frame; \
|
||||
circlebuf_pop_front(&x, &frame, sizeof(frame)); \
|
||||
gs_texture_destroy(frame.tex); \
|
||||
gs_texture_destroy(frame.tex_uv); \
|
||||
} \
|
||||
circlebuf_free(&x); \
|
||||
#define free_deque(x) \
|
||||
do { \
|
||||
while (x.size) { \
|
||||
struct obs_tex_frame frame; \
|
||||
deque_pop_front(&x, &frame, sizeof(frame)); \
|
||||
gs_texture_destroy(frame.tex); \
|
||||
gs_texture_destroy(frame.tex_uv); \
|
||||
} \
|
||||
deque_free(&x); \
|
||||
} while (false)
|
||||
|
||||
free_circlebuf(video->gpu_encoder_queue);
|
||||
free_circlebuf(video->gpu_encoder_avail_queue);
|
||||
#undef free_circlebuf
|
||||
free_deque(video->gpu_encoder_queue);
|
||||
free_deque(video->gpu_encoder_avail_queue);
|
||||
#undef free_deque
|
||||
}
|
||||
|
|
|
@ -487,9 +487,9 @@ static inline bool queue_frame(struct obs_core_video_mix *video,
|
|||
(video->gpu_encoder_queue.size && vframe_info->count > 1);
|
||||
|
||||
if (duplicate) {
|
||||
struct obs_tex_frame *tf = circlebuf_data(
|
||||
&video->gpu_encoder_queue,
|
||||
video->gpu_encoder_queue.size - sizeof(*tf));
|
||||
struct obs_tex_frame *tf =
|
||||
deque_data(&video->gpu_encoder_queue,
|
||||
video->gpu_encoder_queue.size - sizeof(*tf));
|
||||
|
||||
/* texture-based encoding is stopping */
|
||||
if (!tf) {
|
||||
|
@ -502,7 +502,7 @@ static inline bool queue_frame(struct obs_core_video_mix *video,
|
|||
}
|
||||
|
||||
struct obs_tex_frame tf;
|
||||
circlebuf_pop_front(&video->gpu_encoder_avail_queue, &tf, sizeof(tf));
|
||||
deque_pop_front(&video->gpu_encoder_avail_queue, &tf, sizeof(tf));
|
||||
|
||||
if (tf.released) {
|
||||
gs_texture_acquire_sync(tf.tex, tf.lock_key, GS_WAIT_INFINITE);
|
||||
|
@ -531,7 +531,7 @@ static inline bool queue_frame(struct obs_core_video_mix *video,
|
|||
tf.released = true;
|
||||
tf.handle = gs_texture_get_shared_handle(tf.tex);
|
||||
gs_texture_release_sync(tf.tex, ++tf.lock_key);
|
||||
circlebuf_push_back(&video->gpu_encoder_queue, &tf, sizeof(tf));
|
||||
deque_push_back(&video->gpu_encoder_queue, &tf, sizeof(tf));
|
||||
|
||||
os_sem_post(video->gpu_encode_semaphore);
|
||||
|
||||
|
@ -560,8 +560,8 @@ static void output_gpu_encoders(struct obs_core_video_mix *video,
|
|||
goto end;
|
||||
|
||||
struct obs_vframe_info vframe_info;
|
||||
circlebuf_pop_front(&video->vframe_info_buffer_gpu, &vframe_info,
|
||||
sizeof(vframe_info));
|
||||
deque_pop_front(&video->vframe_info_buffer_gpu, &vframe_info,
|
||||
sizeof(vframe_info));
|
||||
|
||||
pthread_mutex_lock(&video->gpu_encoder_mutex);
|
||||
encode_gpu(video, raw_active, &vframe_info);
|
||||
|
@ -915,11 +915,11 @@ static inline void video_sleep(struct obs_core_video *video, uint64_t *p_time,
|
|||
bool gpu_active = video->gpu_was_active;
|
||||
|
||||
if (raw_active)
|
||||
circlebuf_push_back(&video->vframe_info_buffer,
|
||||
&vframe_info, sizeof(vframe_info));
|
||||
deque_push_back(&video->vframe_info_buffer,
|
||||
&vframe_info, sizeof(vframe_info));
|
||||
if (gpu_active)
|
||||
circlebuf_push_back(&video->vframe_info_buffer_gpu,
|
||||
&vframe_info, sizeof(vframe_info));
|
||||
deque_push_back(&video->vframe_info_buffer_gpu,
|
||||
&vframe_info, sizeof(vframe_info));
|
||||
}
|
||||
pthread_mutex_unlock(&obs->video.mixes_mutex);
|
||||
}
|
||||
|
@ -967,8 +967,8 @@ static inline void output_frame(struct obs_core_video_mix *video)
|
|||
|
||||
if (raw_active && frame_ready) {
|
||||
struct obs_vframe_info vframe_info;
|
||||
circlebuf_pop_front(&video->vframe_info_buffer, &vframe_info,
|
||||
sizeof(vframe_info));
|
||||
deque_pop_front(&video->vframe_info_buffer, &vframe_info,
|
||||
sizeof(vframe_info));
|
||||
|
||||
frame.timestamp = vframe_info.timestamp;
|
||||
profile_start(output_frame_output_video_data_name);
|
||||
|
@ -1004,20 +1004,20 @@ static void clear_base_frame_data(struct obs_core_video_mix *video)
|
|||
{
|
||||
video->texture_rendered = false;
|
||||
video->texture_converted = false;
|
||||
circlebuf_free(&video->vframe_info_buffer);
|
||||
deque_free(&video->vframe_info_buffer);
|
||||
video->cur_texture = 0;
|
||||
}
|
||||
|
||||
static void clear_raw_frame_data(struct obs_core_video_mix *video)
|
||||
{
|
||||
memset(video->textures_copied, 0, sizeof(video->textures_copied));
|
||||
circlebuf_free(&video->vframe_info_buffer);
|
||||
deque_free(&video->vframe_info_buffer);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static void clear_gpu_frame_data(struct obs_core_video_mix *video)
|
||||
{
|
||||
circlebuf_free(&video->vframe_info_buffer_gpu);
|
||||
deque_free(&video->vframe_info_buffer_gpu);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ static void execute_graphics_tasks(void)
|
|||
pthread_mutex_lock(&video->task_mutex);
|
||||
if (video->tasks.size) {
|
||||
struct obs_task_info info;
|
||||
circlebuf_pop_front(&video->tasks, &info, sizeof(info));
|
||||
deque_pop_front(&video->tasks, &info, sizeof(info));
|
||||
info.task(info.param);
|
||||
}
|
||||
tasks_remaining = !!video->tasks.size;
|
||||
|
|
16
libobs/obs.c
16
libobs/obs.c
|
@ -853,8 +853,8 @@ void obs_free_video_mix(struct obs_core_video_mix *video)
|
|||
|
||||
obs_free_render_textures(video);
|
||||
|
||||
circlebuf_free(&video->vframe_info_buffer);
|
||||
circlebuf_free(&video->vframe_info_buffer_gpu);
|
||||
deque_free(&video->vframe_info_buffer);
|
||||
deque_free(&video->vframe_info_buffer_gpu);
|
||||
|
||||
video->texture_rendered = false;
|
||||
memset(video->textures_copied, 0,
|
||||
|
@ -892,7 +892,7 @@ static void obs_free_video(void)
|
|||
|
||||
pthread_mutex_destroy(&obs->video.task_mutex);
|
||||
pthread_mutex_init_value(&obs->video.task_mutex);
|
||||
circlebuf_free(&obs->video.tasks);
|
||||
deque_free(&obs->video.tasks);
|
||||
}
|
||||
|
||||
static void obs_free_graphics(void)
|
||||
|
@ -940,7 +940,7 @@ static bool obs_init_audio(struct audio_output_info *ai)
|
|||
return false;
|
||||
|
||||
struct obs_task_info audio_init = {.task = set_audio_thread};
|
||||
circlebuf_push_back(&audio->tasks, &audio_init, sizeof(audio_init));
|
||||
deque_push_back(&audio->tasks, &audio_init, sizeof(audio_init));
|
||||
|
||||
audio->monitoring_device_name = bstrdup("Default");
|
||||
audio->monitoring_device_id = bstrdup("default");
|
||||
|
@ -972,14 +972,14 @@ static void obs_free_audio(void)
|
|||
if (audio->audio)
|
||||
audio_output_close(audio->audio);
|
||||
|
||||
circlebuf_free(&audio->buffered_timestamps);
|
||||
deque_free(&audio->buffered_timestamps);
|
||||
da_free(audio->render_order);
|
||||
da_free(audio->root_nodes);
|
||||
|
||||
da_free(audio->monitors);
|
||||
bfree(audio->monitoring_device_name);
|
||||
bfree(audio->monitoring_device_id);
|
||||
circlebuf_free(&audio->tasks);
|
||||
deque_free(&audio->tasks);
|
||||
pthread_mutex_destroy(&audio->task_mutex);
|
||||
pthread_mutex_destroy(&audio->monitoring_mutex);
|
||||
|
||||
|
@ -3353,7 +3353,7 @@ void obs_queue_task(enum obs_task_type type, obs_task_t task, void *param,
|
|||
struct obs_task_info info = {task, param};
|
||||
|
||||
pthread_mutex_lock(&video->task_mutex);
|
||||
circlebuf_push_back(&video->tasks, &info, sizeof(info));
|
||||
deque_push_back(&video->tasks, &info, sizeof(info));
|
||||
pthread_mutex_unlock(&video->task_mutex);
|
||||
|
||||
} else if (type == OBS_TASK_AUDIO) {
|
||||
|
@ -3361,7 +3361,7 @@ void obs_queue_task(enum obs_task_type type, obs_task_t task, void *param,
|
|||
struct obs_task_info info = {task, param};
|
||||
|
||||
pthread_mutex_lock(&audio->task_mutex);
|
||||
circlebuf_push_back(&audio->tasks, &info, sizeof(info));
|
||||
deque_push_back(&audio->tasks, &info, sizeof(info));
|
||||
pthread_mutex_unlock(&audio->task_mutex);
|
||||
|
||||
} else if (type == OBS_TASK_DESTROY) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "task.h"
|
||||
#include "bmem.h"
|
||||
#include "threading.h"
|
||||
#include "circlebuf.h"
|
||||
#include "deque.h"
|
||||
|
||||
struct os_task_queue {
|
||||
pthread_t thread;
|
||||
|
@ -13,7 +13,7 @@ struct os_task_queue {
|
|||
os_event_t *wait_event;
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
struct circlebuf tasks;
|
||||
struct deque tasks;
|
||||
};
|
||||
|
||||
struct os_task_info {
|
||||
|
@ -66,7 +66,7 @@ bool os_task_queue_queue_task(os_task_queue_t *tq, os_task_t task, void *param)
|
|||
return false;
|
||||
|
||||
pthread_mutex_lock(&tq->mutex);
|
||||
circlebuf_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
pthread_mutex_unlock(&tq->mutex);
|
||||
os_sem_post(tq->sem);
|
||||
return true;
|
||||
|
@ -94,7 +94,7 @@ void os_task_queue_destroy(os_task_queue_t *tq)
|
|||
os_event_destroy(tq->wait_event);
|
||||
os_sem_destroy(tq->sem);
|
||||
pthread_mutex_destroy(&tq->mutex);
|
||||
circlebuf_free(&tq->tasks);
|
||||
deque_free(&tq->tasks);
|
||||
bfree(tq);
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ bool os_task_queue_wait(os_task_queue_t *tq)
|
|||
pthread_mutex_lock(&tq->mutex);
|
||||
tq->waiting = true;
|
||||
tq->tasks_processed = false;
|
||||
circlebuf_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
pthread_mutex_unlock(&tq->mutex);
|
||||
|
||||
os_sem_post(tq->sem);
|
||||
|
@ -140,14 +140,14 @@ static void *tiny_tubular_task_thread(void *param)
|
|||
struct os_task_info ti;
|
||||
|
||||
pthread_mutex_lock(&tq->mutex);
|
||||
circlebuf_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
if (tq->tasks.size && ti.task == wait_for_thread) {
|
||||
circlebuf_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
circlebuf_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
}
|
||||
if (tq->tasks.size && ti.task == stop_thread) {
|
||||
circlebuf_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
circlebuf_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_push_back(&tq->tasks, &ti, sizeof(ti));
|
||||
deque_pop_front(&tq->tasks, &ti, sizeof(ti));
|
||||
}
|
||||
if (tq->waiting) {
|
||||
if (ti.task == wait_for_thread) {
|
||||
|
|
Loading…
Reference in a new issue