Skip to content

Commit 6c678a2

Browse files
committed
codec: Add hint for real-time devices (e.g. sound cards).
1 parent d8e4a89 commit 6c678a2

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

alsa.c

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ struct codec * alsa_codec_init(const struct codec_params *p)
293293
c->prec = enc_info->prec;
294294
if (enc_info->can_dither) c->hints |= CODEC_HINT_CAN_DITHER;
295295
if (p->mode == CODEC_MODE_WRITE) c->hints |= CODEC_HINT_INTERACTIVE;
296+
c->hints |= CODEC_HINT_REALTIME;
296297
c->buf_ratio = buf_frames / p->block_frames;
297298
c->frames = -1;
298299
if (p->mode == CODEC_MODE_READ) c->read = alsa_read;

ao.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -150,6 +150,7 @@ struct codec * ao_codec_init(const struct codec_params *p)
150150
c->prec = enc_info->prec;
151151
c->hints |= CODEC_HINT_CAN_DITHER; /* all formats are fixed-point LPCM */
152152
c->hints |= CODEC_HINT_INTERACTIVE;
153+
c->hints |= CODEC_HINT_REALTIME;
153154
c->buf_ratio = p->buf_ratio;
154155
c->frames = -1;
155156
c->write = ao_write;

codec.h

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum {
3737
CODEC_HINT_INTERACTIVE = 1<<0,
3838
CODEC_HINT_CAN_DITHER = 1<<1,
3939
CODEC_HINT_NO_OUT_BUF = 1<<2,
40+
CODEC_HINT_REALTIME = 1<<3,
4041
};
4142

4243
struct codec {

dsp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static ssize_t do_seek(struct codec *in, ssize_t pos, ssize_t offset, int whence
533533
}
534534
if ((s = in->seek(in, s)) >= 0) {
535535
reset_effects_chain(&chain);
536-
codec_write_buf_drop(out_codec_buf, pause_state, pause_state);
536+
codec_write_buf_drop(out_codec_buf, pause_state || (in->hints & CODEC_HINT_REALTIME), pause_state);
537537
return s;
538538
}
539539
return pos;

pulse.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of dsp.
33
*
4-
* Copyright (c) 2014-2024 Michael Barbour <[email protected]>
4+
* Copyright (c) 2014-2025 Michael Barbour <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -163,6 +163,7 @@ struct codec * pulse_codec_init(const struct codec_params *p)
163163
c->prec = enc_info->prec;
164164
if (enc_info->can_dither) c->hints |= CODEC_HINT_CAN_DITHER;
165165
if (p->mode == CODEC_MODE_WRITE) c->hints |= CODEC_HINT_INTERACTIVE;
166+
c->hints |= CODEC_HINT_REALTIME;
166167
c->buf_ratio = p->buf_ratio;
167168
c->frames = -1;
168169
if (p->mode == CODEC_MODE_READ) c->read = pulse_read;

0 commit comments

Comments
 (0)