summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_jack.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out/ao_jack.c')
-rw-r--r--audio/out/ao_jack.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index 767f437895..412e91d626 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -22,6 +22,7 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,7 +34,6 @@
#include "ao.h"
#include "internal.h"
#include "audio/format.h"
-#include "osdep/atomic.h"
#include "osdep/timer.h"
#include "options/m_config.h"
#include "options/m_option.h"
@@ -47,8 +47,8 @@
struct jack_opts {
char *port;
char *client_name;
- int connect;
- int autostart;
+ bool connect;
+ bool autostart;
int stdlayout;
};
@@ -57,15 +57,15 @@ static const struct m_sub_options ao_jack_conf = {
.opts = (const struct m_option[]){
{"jack-port", OPT_STRING(port)},
{"jack-name", OPT_STRING(client_name)},
- {"jack-autostart", OPT_FLAG(autostart)},
- {"jack-connect", OPT_FLAG(connect)},
+ {"jack-autostart", OPT_BOOL(autostart)},
+ {"jack-connect", OPT_BOOL(connect)},
{"jack-std-channel-layout", OPT_CHOICE(stdlayout,
{"waveext", 0}, {"any", 1})},
{0}
},
.defaults = &(const struct jack_opts) {
.client_name = "mpv",
- .connect = 1,
+ .connect = true,
},
.size = sizeof(struct jack_opts),
};
@@ -122,8 +122,8 @@ static int process(jack_nframes_t nframes, void *arg)
jack_nframes_t jack_latency =
atomic_load(&p->graph_latency_max) + atomic_load(&p->buffer_size);
- int64_t end_time = mp_time_us();
- end_time += (jack_latency + nframes) / (double)ao->samplerate * 1000000.0;
+ int64_t end_time = mp_time_ns();
+ end_time += MP_TIME_S_TO_NS((jack_latency + nframes) / (double)ao->samplerate);
ao_read_data(ao, buffers, nframes, end_time);
@@ -246,6 +246,8 @@ static int init(struct ao *ao)
jack_set_process_callback(p->client, process, ao);
ao->samplerate = jack_get_sample_rate(p->client);
+ // The actual device buffer can change, but this is enough for pre-buffer
+ ao->device_buffer = jack_get_buffer_size(p->client);
jack_set_buffer_size_callback(p->client, buffer_size_cb, ao);
jack_set_graph_order_callback(p->client, graph_order_cb, ao);