Revert #3856
It's a bit too close to release, so revert #3856 for now until there's an open PR window instead.master
parent
a602fa8797
commit
00f0d5eb4e
|
@ -61,15 +61,11 @@ static enum speaker_layout jack_channels_to_obs_speakers(uint_fast32_t channels)
|
|||
int jack_process_callback(jack_nframes_t nframes, void *arg)
|
||||
{
|
||||
struct jack_data *data = (struct jack_data *)arg;
|
||||
jack_nframes_t current_frames;
|
||||
jack_time_t current_usecs, next_usecs;
|
||||
float period_usecs;
|
||||
|
||||
uint64_t now = os_gettime_ns();
|
||||
|
||||
if (data == 0)
|
||||
return 0;
|
||||
|
||||
pthread_mutex_lock(&data->jack_mutex);
|
||||
|
||||
struct obs_source_audio out;
|
||||
out.speakers = jack_channels_to_obs_speakers(data->channels);
|
||||
out.samples_per_sec = jack_get_sample_rate(data->jack_client);
|
||||
|
@ -84,19 +80,11 @@ int jack_process_callback(jack_nframes_t nframes, void *arg)
|
|||
}
|
||||
|
||||
out.frames = nframes;
|
||||
if (!jack_get_cycle_times(data->jack_client, ¤t_frames,
|
||||
¤t_usecs, &next_usecs, &period_usecs)) {
|
||||
out.timestamp = now - (int64_t)(period_usecs * 1000);
|
||||
} else {
|
||||
out.timestamp = now - util_mul_div64(nframes, 1000000000ULL,
|
||||
data->samples_per_sec);
|
||||
blog(LOG_WARNING,
|
||||
"jack_get_cycle_times error: guessing timestamp");
|
||||
}
|
||||
out.timestamp = os_gettime_ns() -
|
||||
jack_frames_to_time(data->jack_client, nframes);
|
||||
|
||||
/* FIXME: this function is not realtime-safe, we should do something
|
||||
* about this */
|
||||
obs_source_output_audio(data->source, &out);
|
||||
pthread_mutex_unlock(&data->jack_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -127,7 +115,7 @@ int_fast32_t jack_init(struct jack_data *data)
|
|||
|
||||
data->jack_ports[i] = jack_port_register(
|
||||
data->jack_client, port_name, JACK_DEFAULT_AUDIO_TYPE,
|
||||
JackPortIsInput | JackPortIsTerminal, 0);
|
||||
JackPortIsInput, 0);
|
||||
if (data->jack_ports[i] == NULL) {
|
||||
blog(LOG_ERROR,
|
||||
"jack_port_register Error:"
|
||||
|
@ -163,11 +151,17 @@ void deactivate_jack(struct jack_data *data)
|
|||
pthread_mutex_lock(&data->jack_mutex);
|
||||
|
||||
if (data->jack_client) {
|
||||
jack_client_close(data->jack_client);
|
||||
if (data->jack_ports != NULL) {
|
||||
for (int i = 0; i < data->channels; ++i) {
|
||||
if (data->jack_ports[i] != NULL)
|
||||
jack_port_unregister(
|
||||
data->jack_client,
|
||||
data->jack_ports[i]);
|
||||
}
|
||||
bfree(data->jack_ports);
|
||||
data->jack_ports = NULL;
|
||||
}
|
||||
jack_client_close(data->jack_client);
|
||||
data->jack_client = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&data->jack_mutex);
|
||||
|
|
Loading…
Reference in New Issue