summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-09-07 19:53:39 +0200
committerLennart Poettering <lennart@poettering.net>2009-09-07 19:53:39 +0200
commit3bbc5e6a4d0211d8cedd2fe6698c2e2c07d1c4b9 (patch)
tree0700543a84101f753bc47ca5c56cf147a9956505 /src
parent5cf0c1e544a5fce97d514c793256b2e301277136 (diff)
volume: fix definition of PA_VOLUME_MAX and introduce PA_VOLUME_INVALID and use it wherever applicable
Diffstat (limited to 'src')
-rw-r--r--src/pulse/scache.c4
-rw-r--r--src/pulse/scache.h4
-rw-r--r--src/pulse/volume.c10
-rw-r--r--src/pulse/volume.h9
-rw-r--r--src/pulsecore/core-scache.c4
5 files changed, 17 insertions, 14 deletions
diff --git a/src/pulse/scache.c b/src/pulse/scache.c
index 77f60d72..43dc5296 100644
--- a/src/pulse/scache.c
+++ b/src/pulse/scache.c
@@ -187,7 +187,7 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
pa_tagstruct_puts(t, dev);
- if (volume == (pa_volume_t) -1 && c->version < 15)
+ if (volume == PA_VOLUME_INVALID && c->version < 15)
volume = PA_VOLUME_NORM;
pa_tagstruct_putu32(t, volume);
@@ -228,7 +228,7 @@ pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *na
pa_tagstruct_putu32(t, PA_INVALID_INDEX);
pa_tagstruct_puts(t, dev);
- if (volume == (pa_volume_t) -1 && c->version < 15)
+ if (volume == PA_VOLUME_INVALID && c->version < 15)
volume = PA_VOLUME_NORM;
pa_tagstruct_putu32(t, volume);
diff --git a/src/pulse/scache.h b/src/pulse/scache.h
index cd579d2e..31cf7b01 100644
--- a/src/pulse/scache.h
+++ b/src/pulse/scache.h
@@ -101,7 +101,7 @@ pa_operation* pa_context_play_sample(
pa_context *c /**< Context */,
const char *name /**< Name of the sample to play */,
const char *dev /**< Sink to play this sample on */,
- pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here (pa_volume_t) -1 which will leave the decision about the volume to the server side which is a good idea. */ ,
+ pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,
pa_context_success_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
void *userdata /**< Userdata to pass to the callback */);
@@ -113,7 +113,7 @@ pa_operation* pa_context_play_sample_with_proplist(
pa_context *c /**< Context */,
const char *name /**< Name of the sample to play */,
const char *dev /**< Sink to play this sample on */,
- pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here (pa_volume_t) -1 which will leave the decision about the volume to the server side which is a good idea. */ ,
+ pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side which is a good idea. */ ,
pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will be merged into this property list */,
pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
void *userdata /**< Userdata to pass to the callback */);
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 234c3f72..4991e5c8 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -64,7 +64,7 @@ pa_cvolume* pa_cvolume_init(pa_cvolume *a) {
a->channels = 0;
for (c = 0; c < PA_CHANNELS_MAX; c++)
- a->values[c] = (pa_volume_t) -1;
+ a->values[c] = PA_VOLUME_INVALID;
return a;
}
@@ -307,7 +307,7 @@ char *pa_volume_snprint(char *s, size_t l, pa_volume_t v) {
pa_init_i18n();
- if (v == (pa_volume_t) -1) {
+ if (v == PA_VOLUME_INVALID) {
pa_snprintf(s, l, _("(invalid)"));
return s;
}
@@ -357,7 +357,7 @@ char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v) {
pa_init_i18n();
- if (v == (pa_volume_t) -1) {
+ if (v == PA_VOLUME_INVALID) {
pa_snprintf(s, l, _("(invalid)"));
return s;
}
@@ -459,7 +459,7 @@ int pa_cvolume_valid(const pa_cvolume *v) {
return 0;
for (c = 0; c < v->channels; c++)
- if (v->values[c] == (pa_volume_t) -1)
+ if (v->values[c] == PA_VOLUME_INVALID)
return 0;
return 1;
@@ -679,7 +679,7 @@ pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max) {
pa_assert(v);
pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
- pa_return_val_if_fail(max != (pa_volume_t) -1, NULL);
+ pa_return_val_if_fail(max != PA_VOLUME_INVALID, NULL);
t = pa_cvolume_max(v);
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index 543b0af1..c964020a 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -106,11 +106,14 @@ typedef uint32_t pa_volume_t;
/** Normal volume (100%, 0 dB) */
#define PA_VOLUME_NORM ((pa_volume_t) 0x10000U)
-/** Muted volume (0%, -inf dB) */
+/** Muted (minimal valid) volume (0%, -inf dB) */
#define PA_VOLUME_MUTED ((pa_volume_t) 0U)
-/** Maximum volume we can store. \since 0.9.15 */
-#define PA_VOLUME_MAX ((pa_volume_t) UINT32_MAX)
+/** Maximum valid volume we can store. \since 0.9.15 */
+#define PA_VOLUME_MAX ((pa_volume_t) UINT32_MAX-1)
+
+/** Special 'invalid' volume. \since 0.9.16 */
+#define PA_VOLUME_INVALID ((pa_volume_t) UINT32_MAX)
/** A structure encapsulating a per-channel volume */
typedef struct pa_cvolume {
diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c
index fde12ecf..1fb81d0d 100644
--- a/src/pulsecore/core-scache.c
+++ b/src/pulsecore/core-scache.c
@@ -335,12 +335,12 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t
pass_volume = TRUE;
- if (e->volume_is_set && volume != (pa_volume_t) -1) {
+ if (e->volume_is_set && volume != PA_VOLUME_INVALID) {
pa_cvolume_set(&r, e->sample_spec.channels, volume);
pa_sw_cvolume_multiply(&r, &r, &e->volume);
} else if (e->volume_is_set)
r = e->volume;
- else if (volume != (pa_volume_t) -1)
+ else if (volume != PA_VOLUME_INVALID)
pa_cvolume_set(&r, e->sample_spec.channels, volume);
else
pass_volume = FALSE;