summaryrefslogtreecommitdiffstats
path: root/src/pulse
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse')
-rw-r--r--src/pulse/client-conf.c2
-rw-r--r--src/pulse/context.c17
-rw-r--r--src/pulse/context.h22
-rw-r--r--src/pulse/def.h10
-rw-r--r--src/pulse/ext-device-manager.h24
-rw-r--r--src/pulse/mainloop-signal.c4
-rw-r--r--src/pulse/mainloop.c4
-rw-r--r--src/pulse/stream.c69
-rw-r--r--src/pulse/stream.h17
-rw-r--r--src/pulse/util.c11
-rw-r--r--src/pulse/volume.c10
-rw-r--r--src/pulse/volume.h4
12 files changed, 162 insertions, 32 deletions
diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c
index 62c06f6a..3eaca4d9 100644
--- a/src/pulse/client-conf.c
+++ b/src/pulse/client-conf.c
@@ -110,7 +110,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
if (filename) {
- if (!(f = fopen(filename, "r"))) {
+ if (!(f = pa_fopen_cloexec(filename, "r"))) {
pa_log(_("Failed to open configuration file '%s': %s"), fn, pa_cstrerror(errno));
goto finish;
}
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 7468d0a9..e33143d9 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1488,6 +1488,7 @@ pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_even
struct timeval tv;
pa_assert(c);
+ pa_assert(PA_REFCNT_VALUE(c) >= 1);
pa_assert(c->mainloop);
if (usec == PA_USEC_INVALID)
@@ -1502,8 +1503,10 @@ void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec)
struct timeval tv;
pa_assert(c);
+ pa_assert(PA_REFCNT_VALUE(c) >= 1);
pa_assert(c->mainloop);
+
if (usec == PA_USEC_INVALID)
c->mainloop->time_restart(e, NULL);
else {
@@ -1511,3 +1514,17 @@ void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec)
c->mainloop->time_restart(e, &tv);
}
}
+
+size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss) {
+ size_t fs, mbs;
+
+ pa_assert(c);
+ pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+ PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, (size_t) -1);
+ PA_CHECK_VALIDITY_RETURN_ANY(c, !ss || pa_sample_spec_valid(ss), PA_ERR_INVALID, (size_t) -1);
+
+ fs = ss ? pa_frame_size(ss) : 1;
+ mbs = PA_ROUND_DOWN(pa_mempool_block_size_max(c->mempool), fs);
+ return PA_MAX(mbs, fs);
+}
diff --git a/src/pulse/context.h b/src/pulse/context.h
index ecff58df..6ac8ee56 100644
--- a/src/pulse/context.h
+++ b/src/pulse/context.h
@@ -255,12 +255,28 @@ pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[]
uint32_t pa_context_get_index(pa_context *s);
/** Create a new timer event source for the specified time (wrapper
- for mainloop->time_new). \since 0.9.16 */
+ * for mainloop->time_new). \since 0.9.16 */
pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata);
-/** Restart a running or expired timer event source (wrapper
- for mainloop->time_restart). \since 0.9.16 */
+
+/** Restart a running or expired timer event source (wrapper for
+ * mainloop->time_restart). \since 0.9.16 */
void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec);
+/* Return the optimal block size for passing around audio buffers. It
+ * is recommended to allocate buffers of the size returned here when
+ * writing audio data to playback streams, if the latency constraints
+ * permit this. It is not recommended writing larger blocks than this
+ * because usually they will then be split up internally into chunks
+ * of this size. It is not recommended writing smaller blocks than
+ * this (unless required due to latency demands) because this
+ * increases CPU usage. If ss is NULL you will be returned the
+ * byte-exact tile size. If you pass a valid ss, then the tile size
+ * will be rounded down to multiple of the frame size. This is
+ * supposed to be used in a construct such as
+ * pa_context_get_tile_size(pa_stream_get_context(s),
+ * pa_stream_get_sample_spec(ss)); \since 0.9.20 */
+size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss);
+
PA_C_DECL_END
#endif
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 5d0a0b4b..30a076d5 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -276,11 +276,18 @@ typedef enum pa_stream_flags {
* whether to create the stream in muted or in unmuted
* state. \since 0.9.15 */
- PA_STREAM_FAIL_ON_SUSPEND = 0x20000U
+ PA_STREAM_FAIL_ON_SUSPEND = 0x20000U,
/**< If the sink/source this stream is connected to is suspended
* during the creation of this stream, cause it to fail. If the
* sink/source is being suspended during creation of this stream,
* make sure this stream is terminated. \since 0.9.15 */
+
+ PA_STREAM_RELATIVE_VOLUME = 0x40000U,
+ /**< If a volume is passed when this stream is created, consider
+ * it relative to the sink's current volume, never as absolute
+ * device volume. If this is not specified the volume will be
+ * consider absolute when the sink is in flat volume mode,
+ * relative otherwise. \since 0.9.20 */
} pa_stream_flags_t;
/** \cond fulldocs */
@@ -307,6 +314,7 @@ typedef enum pa_stream_flags {
#define PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
#define PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED
#define PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND
+#define PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME
/** \endcond */
diff --git a/src/pulse/ext-device-manager.h b/src/pulse/ext-device-manager.h
index 1442a1a9..df0ab92f 100644
--- a/src/pulse/ext-device-manager.h
+++ b/src/pulse/ext-device-manager.h
@@ -39,7 +39,7 @@ typedef struct pa_ext_device_manager_role_priority_info {
} pa_ext_device_manager_role_priority_info;
/** Stores information about one device in the device database that is
- * maintained by module-device-manager. \since 0.9.19 */
+ * maintained by module-device-manager. \since 0.9.21 */
typedef struct pa_ext_device_manager_info {
const char *name; /**< Identifier string of the device. A string like "sink:" or similar followed by the name of the device. */
const char *description; /**< The description of the device when it was last seen, if applicable and saved */
@@ -49,32 +49,32 @@ typedef struct pa_ext_device_manager_info {
pa_ext_device_manager_role_priority_info *role_priorities; /**< An array of role priority structures or NULL */
} pa_ext_device_manager_info;
-/** Callback prototype for pa_ext_device_manager_test(). \since 0.9.19 */
+/** Callback prototype for pa_ext_device_manager_test(). \since 0.9.21 */
typedef void (*pa_ext_device_manager_test_cb_t)(
pa_context *c,
uint32_t version,
void *userdata);
-/** Test if this extension module is available in the server. \since 0.9.19 */
+/** Test if this extension module is available in the server. \since 0.9.21 */
pa_operation *pa_ext_device_manager_test(
pa_context *c,
pa_ext_device_manager_test_cb_t cb,
void *userdata);
-/** Callback prototype for pa_ext_device_manager_read(). \since 0.9.19 */
+/** Callback prototype for pa_ext_device_manager_read(). \since 0.9.21 */
typedef void (*pa_ext_device_manager_read_cb_t)(
pa_context *c,
const pa_ext_device_manager_info *info,
int eol,
void *userdata);
-/** Read all entries from the device database. \since 0.9.19 */
+/** Read all entries from the device database. \since 0.9.21 */
pa_operation *pa_ext_device_manager_read(
pa_context *c,
pa_ext_device_manager_read_cb_t cb,
void *userdata);
-/** Sets the description for a device. \since 0.9.19 */
+/** Sets the description for a device. \since 0.9.21 */
pa_operation *pa_ext_device_manager_set_device_description(
pa_context *c,
const char* device,
@@ -82,21 +82,21 @@ pa_operation *pa_ext_device_manager_set_device_description(
pa_context_success_cb_t cb,
void *userdata);
-/** Delete entries from the device database. \since 0.9.19 */
+/** Delete entries from the device database. \since 0.9.21 */
pa_operation *pa_ext_device_manager_delete(
pa_context *c,
const char *const s[],
pa_context_success_cb_t cb,
void *userdata);
-/** Enable the role-based device-priority routing mode. \since 0.9.19 */
+/** Enable the role-based device-priority routing mode. \since 0.9.21 */
pa_operation *pa_ext_device_manager_enable_role_device_priority_routing(
pa_context *c,
int enable,
pa_context_success_cb_t cb,
void *userdata);
-/** Prefer a given device in the priority list. \since 0.9.19 */
+/** Prefer a given device in the priority list. \since 0.9.21 */
pa_operation *pa_ext_device_manager_reorder_devices_for_role(
pa_context *c,
const char* role,
@@ -104,20 +104,20 @@ pa_operation *pa_ext_device_manager_reorder_devices_for_role(
pa_context_success_cb_t cb,
void *userdata);
-/** Subscribe to changes in the device database. \since 0.9.19 */
+/** Subscribe to changes in the device database. \since 0.9.21 */
pa_operation *pa_ext_device_manager_subscribe(
pa_context *c,
int enable,
pa_context_success_cb_t cb,
void *userdata);
-/** Callback prototype for pa_ext_device_manager_set_subscribe_cb(). \since 0.9.19 */
+/** Callback prototype for pa_ext_device_manager_set_subscribe_cb(). \since 0.9.21 */
typedef void (*pa_ext_device_manager_subscribe_cb_t)(
pa_context *c,
void *userdata);
/** Set the subscription callback that is called when
- * pa_ext_device_manager_subscribe() was called. \since 0.9.19 */
+ * pa_ext_device_manager_subscribe() was called. \since 0.9.21 */
void pa_ext_device_manager_set_subscribe_cb(
pa_context *c,
pa_ext_device_manager_subscribe_cb_t cb,
diff --git a/src/pulse/mainloop-signal.c b/src/pulse/mainloop-signal.c
index 3dc74398..70c0122c 100644
--- a/src/pulse/mainloop-signal.c
+++ b/src/pulse/mainloop-signal.c
@@ -124,15 +124,13 @@ int pa_signal_init(pa_mainloop_api *a) {
pa_assert(signal_pipe[1] == -1);
pa_assert(!io_event);
- if (pipe(signal_pipe) < 0) {
+ if (pa_pipe_cloexec(signal_pipe) < 0) {
pa_log("pipe(): %s", pa_cstrerror(errno));
return -1;
}
pa_make_fd_nonblock(signal_pipe[0]);
pa_make_fd_nonblock(signal_pipe[1]);
- pa_make_fd_cloexec(signal_pipe[0]);
- pa_make_fd_cloexec(signal_pipe[1]);
api = a;
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 090ac8c2..6cd089ef 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -482,7 +482,7 @@ pa_mainloop *pa_mainloop_new(void) {
m = pa_xnew0(pa_mainloop, 1);
- if (pipe(m->wakeup_pipe) < 0) {
+ if (pa_pipe_cloexec(m->wakeup_pipe) < 0) {
pa_log_error("ERROR: cannot create wakeup pipe");
pa_xfree(m);
return NULL;
@@ -490,8 +490,6 @@ pa_mainloop *pa_mainloop_new(void) {
pa_make_fd_nonblock(m->wakeup_pipe[0]);
pa_make_fd_nonblock(m->wakeup_pipe[1]);
- pa_make_fd_cloexec(m->wakeup_pipe[0]);
- pa_make_fd_cloexec(m->wakeup_pipe[1]);
m->rebuild_pollfds = TRUE;
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 2bc2b1e4..4dea5670 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -387,9 +387,26 @@ static void check_smoother_status(pa_stream *s, pa_bool_t aposteriori, pa_bool_t
if (s->suspended || s->corked || force_stop)
pa_smoother_pause(s->smoother, x);
- else if (force_start || s->buffer_attr.prebuf == 0)
- pa_smoother_resume(s->smoother, x, TRUE);
+ else if (force_start || s->buffer_attr.prebuf == 0) {
+
+ if (!s->timing_info_valid &&
+ !aposteriori &&
+ !force_start &&
+ !force_stop &&
+ s->context->version >= 13) {
+
+ /* If the server supports STARTED events we take them as
+ * indications when audio really starts/stops playing, if
+ * we don't have any timing info yet -- instead of trying
+ * to be smart and guessing the server time. Otherwise the
+ * unknown transport delay add too much noise to our time
+ * calculations. */
+
+ return;
+ }
+ pa_smoother_resume(s->smoother, x, TRUE);
+ }
/* Please note that we have no idea if playback actually started
* if prebuf is non-zero! */
@@ -1025,7 +1042,8 @@ static int create_stream(
PA_STREAM_EARLY_REQUESTS|
PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND|
PA_STREAM_START_UNMUTED|
- PA_STREAM_FAIL_ON_SUSPEND)), PA_ERR_INVALID);
+ PA_STREAM_FAIL_ON_SUSPEND|
+ PA_STREAM_RELATIVE_VOLUME)), PA_ERR_INVALID);
PA_CHECK_VALIDITY(s->context, s->context->version >= 12 || !(flags & PA_STREAM_VARIABLE_RATE), PA_ERR_NOTSUPPORTED);
PA_CHECK_VALIDITY(s->context, s->context->version >= 13 || !(flags & PA_STREAM_PEAK_DETECT), PA_ERR_NOTSUPPORTED);
@@ -1158,6 +1176,13 @@ static int create_stream(
pa_tagstruct_put_boolean(t, flags & PA_STREAM_FAIL_ON_SUSPEND);
}
+ if (s->context->version >= 17) {
+
+ if (s->direction == PA_STREAM_PLAYBACK)
+ pa_tagstruct_put_boolean(t, flags & PA_STREAM_RELATIVE_VOLUME);
+
+ }
+
pa_pstream_send_tagstruct(s->context->pstream, t);
pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
@@ -1457,6 +1482,11 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
+ /* Ask for a timing update before we cork/uncork to get the best
+ * accuracy for the transport latency suitable for the
+ * check_smoother_status() call in the started callback */
+ request_auto_timing_update(s, TRUE);
+
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(s->context, PA_COMMAND_DRAIN_PLAYBACK_STREAM, &tag);
@@ -1464,6 +1494,10 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us
pa_pstream_send_tagstruct(s->context->pstream, t);
pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_stream_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+ /* This might cause the read index to conitnue again, hence
+ * let's request a timing update */
+ request_auto_timing_update(s, TRUE);
+
return o;
}
@@ -2012,6 +2046,11 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
+ /* Ask for a timing update before we cork/uncork to get the best
+ * accuracy for the transport latency suitable for the
+ * check_smoother_status() call in the started callback */
+ request_auto_timing_update(s, TRUE);
+
s->corked = b;
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
@@ -2027,8 +2066,8 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
check_smoother_status(s, FALSE, FALSE, FALSE);
- /* This might cause the indexes to hang/start again, hence
- * let's request a timing update */
+ /* This might cause the indexes to hang/start again, hence let's
+ * request a timing update, after the cork/uncork, too */
request_auto_timing_update(s, TRUE);
return o;
@@ -2065,6 +2104,11 @@ pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *use
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
+ /* Ask for a timing update *before* the flush, so that the
+ * transport usec is as up to date as possible when we get the
+ * underflow message and update the smoother status*/
+ request_auto_timing_update(s, TRUE);
+
if (!(o = stream_send_simple_command(s, (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM), cb, userdata)))
return NULL;
@@ -2099,6 +2143,11 @@ pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *us
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
+ /* Ask for a timing update before we cork/uncork to get the best
+ * accuracy for the transport latency suitable for the
+ * check_smoother_status() call in the started callback */
+ request_auto_timing_update(s, TRUE);
+
if (!(o = stream_send_simple_command(s, PA_COMMAND_PREBUF_PLAYBACK_STREAM, cb, userdata)))
return NULL;
@@ -2120,6 +2169,11 @@ pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *u
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE);
+ /* Ask for a timing update before we cork/uncork to get the best
+ * accuracy for the transport latency suitable for the
+ * check_smoother_status() call in the started callback */
+ request_auto_timing_update(s, TRUE);
+
if (!(o = stream_send_simple_command(s, PA_COMMAND_TRIGGER_PLAYBACK_STREAM, cb, userdata)))
return NULL;
@@ -2371,6 +2425,11 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED);
+ /* Ask for a timing update before we cork/uncork to get the best
+ * accuracy for the transport latency suitable for the
+ * check_smoother_status() call in the started callback */
+ request_auto_timing_update(s, TRUE);
+
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(
diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index 2e8e71a0..bc54a118 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -401,7 +401,22 @@ int pa_stream_is_suspended(pa_stream *s);
* not, and negative on error. \since 0.9.11 */
int pa_stream_is_corked(pa_stream *s);
-/** Connect the stream to a sink */
+/** Connect the stream to a sink. It is strongly recommended to pass
+ * NULL in both dev and volume and not to set either
+ * PA_STREAM_START_MUTED nor PA_STREAM_START_UNMUTED -- unless these
+ * options are directly dependant on user input or configuration. If
+ * you follow this rule then the sound server will have the full
+ * flexibility to choose the device, volume and mute status
+ * automatically, based on server-side policies, heuristics and stored
+ * information from previous uses. Also the server may choose to
+ * reconfigure audio devices to make other sinks/sources or
+ * capabilities available to be able to accept the stream. Before
+ * 0.9.20 it was not defined whether the 'volume' parameter was
+ * interpreted relative to the sink's current volume or treated as
+ * absolute device volume. Since 0.9.20 it is an absolute volume when
+ * the sink is in flat volume mode, and relative otherwise, thus
+ * making sure the volume passed here has always the same semantics as
+ * the volume passed to pa_context_set_sink_input_volume(). */
int pa_stream_connect_playback(
pa_stream *s /**< The stream to connect to a sink */,
const char *dev /**< Name of the sink to connect to, or NULL for default */ ,
diff --git a/src/pulse/util.c b/src/pulse/util.c
index 9440f5de..ca766dab 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -189,7 +189,18 @@ char *pa_get_binary_name(char *s, size_t l) {
return s;
}
}
+#endif
+#ifdef __FreeBSD__
+ {
+ char *rp;
+
+ if ((rp = pa_readlink("/proc/curproc/file"))) {
+ pa_strlcpy(s, pa_path_get_filename(rp), l);
+ pa_xfree(rp);
+ return s;
+ }
+ }
#endif
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_GET_NAME)
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 2d2bba25..59e9a189 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -885,7 +885,7 @@ pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvo
return dest;
}
-pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc) {
+pa_cvolume* pa_cvolume_inc_clamp(pa_cvolume *v, pa_volume_t inc, pa_volume_t limit) {
pa_volume_t m;
pa_assert(v);
@@ -895,14 +895,18 @@ pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc) {
m = pa_cvolume_max(v);
- if (m >= PA_VOLUME_MAX - inc)
- m = PA_VOLUME_MAX;
+ if (m >= limit - inc)
+ m = limit;
else
m += inc;
return pa_cvolume_scale(v, m);
}
+pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc){
+ return pa_cvolume_inc_clamp(v, inc, PA_VOLUME_MAX);
+}
+
pa_cvolume* pa_cvolume_dec(pa_cvolume *v, pa_volume_t dec) {
pa_volume_t m;
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index c964020a..ded4422e 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -348,6 +348,10 @@ pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, p
* and dest may point to the same structure. \since 0.9.16 */
pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
+/** Increase the volume passed in by 'inc', but not exceeding 'limit'.
+ * The proportions between the channels are kept. \since 0.9.19 */
+pa_cvolume* pa_cvolume_inc_clamp(pa_cvolume *v, pa_volume_t inc, pa_volume_t limit);
+
/** Increase the volume passed in by 'inc'. The proportions between
* the channels are kept. \since 0.9.16 */
pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc);