Activate user-selected audio devices
- Fix a bug where the initial audio data insertion would cause all audio data to unintentionally clear (mixed up < and > operators, damn human error) - Fixed a potential interdependant lock scenario with channel mutex locks and graphics mutex locks. The main video thread could lock the graphics mutex and then while in the graphics mutex could lock the channels mutex. Meanwhile in another thread, the channel mutex could get locked, and then the graphics mutex would get locked, causing a deadlock. The best way to deal with this is to not let mutexes lock within other mutexes, but sometimes it's difficult to avoid such as in the main video thread. - Audio devices should now be functional, and the devices in the audio settings can now be changed as desired.
This commit is contained in:
@@ -144,21 +144,23 @@ static inline uint64_t conv_frames_to_time(audio_t audio, uint32_t frames)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* this only really happens with the very initial data insertion. can be
|
||||
* ignored safely. */
|
||||
static inline void clear_excess_audio_data(struct audio_line *line,
|
||||
uint64_t prev_time)
|
||||
{
|
||||
size_t size = ts_diff_bytes(line->audio, prev_time,
|
||||
line->base_timestamp);
|
||||
|
||||
blog(LOG_WARNING, "Excess audio data for audio line '%s', somehow "
|
||||
"audio data went back in time by %"PRIu32" bytes. "
|
||||
"prev_time: %"PRIu64", line->base_timestamp: %"PRIu64,
|
||||
line->name, (uint32_t)size,
|
||||
prev_time, line->base_timestamp);
|
||||
/*blog(LOG_DEBUG, "Excess audio data for audio line '%s', somehow "
|
||||
"audio data went back in time by %"PRIu32" bytes. "
|
||||
"prev_time: %"PRIu64", line->base_timestamp: %"PRIu64,
|
||||
line->name, (uint32_t)size,
|
||||
prev_time, line->base_timestamp);*/
|
||||
|
||||
for (size_t i = 0; i < line->audio->planes; i++) {
|
||||
size_t clear_size = (size > line->buffers[i].size) ?
|
||||
(size_t)size : line->buffers[i].size;
|
||||
size_t clear_size = (size < line->buffers[i].size) ?
|
||||
size : line->buffers[i].size;
|
||||
|
||||
circlebuf_pop_front(&line->buffers[i], NULL, clear_size);
|
||||
}
|
||||
|
@@ -94,20 +94,20 @@ void obs_view_setsource(obs_view_t view, uint32_t channel,
|
||||
|
||||
pthread_mutex_lock(&view->channels_mutex);
|
||||
|
||||
obs_source_addref(source);
|
||||
|
||||
prev_source = view->channels[channel];
|
||||
view->channels[channel] = source;
|
||||
|
||||
if (source) {
|
||||
obs_source_addref(source);
|
||||
pthread_mutex_unlock(&view->channels_mutex);
|
||||
|
||||
if (source)
|
||||
obs_source_activate(source, AUX_VIEW);
|
||||
}
|
||||
|
||||
if (prev_source) {
|
||||
obs_source_deactivate(prev_source, AUX_VIEW);
|
||||
obs_source_release(prev_source);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&view->channels_mutex);
|
||||
}
|
||||
|
||||
void obs_view_render(obs_view_t view)
|
||||
|
10
libobs/obs.c
10
libobs/obs.c
@@ -727,6 +727,8 @@ void obs_set_output_source(uint32_t channel, obs_source_t source)
|
||||
|
||||
pthread_mutex_lock(&view->channels_mutex);
|
||||
|
||||
obs_source_addref(source);
|
||||
|
||||
prev_source = view->channels[channel];
|
||||
|
||||
calldata_setint(¶ms, "channel", channel);
|
||||
@@ -738,17 +740,15 @@ void obs_set_output_source(uint32_t channel, obs_source_t source)
|
||||
|
||||
view->channels[channel] = source;
|
||||
|
||||
if (source) {
|
||||
obs_source_addref(source);
|
||||
pthread_mutex_unlock(&view->channels_mutex);
|
||||
|
||||
if (source)
|
||||
obs_source_activate(source, MAIN_VIEW);
|
||||
}
|
||||
|
||||
if (prev_source) {
|
||||
obs_source_deactivate(prev_source, MAIN_VIEW);
|
||||
obs_source_release(prev_source);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&view->channels_mutex);
|
||||
}
|
||||
|
||||
void obs_enum_outputs(bool (*enum_proc)(void*, obs_output_t), void *param)
|
||||
|
Reference in New Issue
Block a user