summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-05-14 00:41:18 +0000
committerLennart Poettering <lennart@poettering.net>2006-05-14 00:41:18 +0000
commitbe05b18c6fb6f0e2e2b74ffdf251692a45eaa045 (patch)
tree7974db8d050c3fd6e19dcd3aaa7dde5875f91168 /src
parente46f8f8eb3fd586f8728e43292509434e0e8b089 (diff)
* add new parameter to pa_open_config_file() to specify open mode
* modify pa_sink_input_new() to take initial volume settings as argument * call pa_sink_input_set_volume() when changing stream volume in protocol-esound.c to make sure that subscribe events are issued properly git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@858 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/daemon/daemon-conf.c4
-rw-r--r--src/modules/module-combine.c2
-rw-r--r--src/modules/module-match.c4
-rw-r--r--src/modules/module-sine.c2
-rw-r--r--src/modules/rtp/module-rtp-recv.c2
-rw-r--r--src/polyp/client-conf.c2
-rw-r--r--src/polypcore/play-memchunk.c5
-rw-r--r--src/polypcore/protocol-esound.c18
-rw-r--r--src/polypcore/protocol-native.c4
-rw-r--r--src/polypcore/protocol-simple.c2
-rw-r--r--src/polypcore/sink-input.c17
-rw-r--r--src/polypcore/sink-input.h1
-rw-r--r--src/polypcore/sound-file-stream.c4
-rw-r--r--src/polypcore/util.c8
-rw-r--r--src/polypcore/util.h2
15 files changed, 43 insertions, 34 deletions
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index ac5fbb16..f41bb4b1 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -84,7 +84,7 @@ pa_daemon_conf* pa_daemon_conf_new(void) {
FILE *f;
pa_daemon_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
- if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file)))
+ if ((f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file, "r")))
fclose(f);
#ifdef DLSEARCHPATH
@@ -233,7 +233,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
f = filename ?
fopen(c->config_file = pa_xstrdup(filename), "r") :
- pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file);
+ pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file, "r");
if (!f && errno != ENOENT) {
pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno));
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 47010497..3b927d13 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -238,7 +238,7 @@ static struct output *output_new(struct userdata *u, pa_sink *sink, int resample
sink->core->memblock_stat);
snprintf(t, sizeof(t), "%s: output #%u", u->sink->name, u->n_outputs+1);
- if (!(o->sink_input = pa_sink_input_new(sink, __FILE__, t, &u->sink->sample_spec, &u->sink->channel_map, 1, resample_method)))
+ if (!(o->sink_input = pa_sink_input_new(sink, __FILE__, t, &u->sink->sample_spec, &u->sink->channel_map, NULL, 1, resample_method)))
goto fail;
o->sink_input->get_latency = sink_input_get_latency_cb;
diff --git a/src/modules/module-match.c b/src/modules/module-match.c
index 59817517..f6316b93 100644
--- a/src/modules/module-match.c
+++ b/src/modules/module-match.c
@@ -43,7 +43,7 @@
#include "module-match-symdef.h"
PA_MODULE_AUTHOR("Lennart Poettering")
-PA_MODULE_DESCRIPTION("Sink input matching module")
+PA_MODULE_DESCRIPTION("Playback stream expression matching module")
PA_MODULE_USAGE("table=<filename>")
PA_MODULE_VERSION(PACKAGE_VERSION)
@@ -81,7 +81,7 @@ static int load_rules(struct userdata *u, const char *filename) {
f = filename ?
fopen(fn = pa_xstrdup(filename), "r") :
- pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn);
+ pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn, "r");
if (!f) {
pa_log(__FILE__": failed to open file '%s': %s", fn, strerror(errno));
diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
index d5a0fa47..3267d49b 100644
--- a/src/modules/module-sine.c
+++ b/src/modules/module-sine.c
@@ -141,7 +141,7 @@ int pa__init(pa_core *c, pa_module*m) {
calc_sine(u->memblock->data, u->memblock->length, frequency);
snprintf(t, sizeof(t), "Sine Generator at %u Hz", frequency);
- if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, t, &ss, NULL, 0, -1)))
+ if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, t, &ss, NULL, NULL, 0, -1)))
goto fail;
u->sink_input->peek = sink_input_peek;
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index cd5f10e6..925a1210 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -286,7 +286,7 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
sdp_info->session_name ? sdp_info->session_name : "",
sdp_info->session_name ? ")" : "");
- s->sink_input = pa_sink_input_new(sink, __FILE__, c, &sdp_info->sample_spec, NULL, 0, PA_RESAMPLER_INVALID);
+ s->sink_input = pa_sink_input_new(sink, __FILE__, c, &sdp_info->sample_spec, NULL, NULL, 0, PA_RESAMPLER_INVALID);
pa_xfree(c);
if (!s->sink_input) {
diff --git a/src/polyp/client-conf.c b/src/polyp/client-conf.c
index 4202b14c..d3ad0767 100644
--- a/src/polyp/client-conf.c
+++ b/src/polyp/client-conf.c
@@ -119,7 +119,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
f = filename ?
fopen((fn = pa_xstrdup(filename)), "r") :
- pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn);
+ pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn, "r");
if (!f && errno != EINTR) {
pa_log(__FILE__": WARNING: failed to open configuration file '%s': %s", filename, strerror(errno));
diff --git a/src/polypcore/play-memchunk.c b/src/polypcore/play-memchunk.c
index ec79254b..37ebdcf1 100644
--- a/src/polypcore/play-memchunk.c
+++ b/src/polypcore/play-memchunk.c
@@ -98,12 +98,9 @@ int pa_play_memchunk(
if (cvolume && pa_cvolume_is_muted(cvolume))
return 0;
- if (!(si = pa_sink_input_new(sink, name, __FILE__, ss, map, 0, PA_RESAMPLER_INVALID)))
+ if (!(si = pa_sink_input_new(sink, name, __FILE__, ss, map, cvolume, 0, PA_RESAMPLER_INVALID)))
return -1;
- if (cvolume)
- si->volume = *cvolume;
-
si->peek = sink_input_peek;
si->drop = sink_input_drop;
si->kill = sink_input_kill;
diff --git a/src/polypcore/protocol-esound.c b/src/polypcore/protocol-esound.c
index 56a11365..50c8b6b5 100644
--- a/src/polypcore/protocol-esound.c
+++ b/src/polypcore/protocol-esound.c
@@ -345,7 +345,7 @@ static int esd_proto_stream_play(struct connection *c, PA_GCC_UNUSED esd_proto_t
assert(!c->sink_input && !c->input_memblockq);
- c->sink_input = pa_sink_input_new(sink, __FILE__, name, &ss, NULL, 0, -1);
+ c->sink_input = pa_sink_input_new(sink, __FILE__, name, &ss, NULL, NULL, 0, -1);
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
@@ -532,9 +532,10 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
assert(t >= k*2+s);
if (conn->sink_input) {
+ pa_cvolume volume = *pa_sink_input_get_volume(conn->sink_input);
rate = conn->sink_input->sample_spec.rate;
- lvolume = (conn->sink_input->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
- rvolume = (conn->sink_input->volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
+ lvolume = (volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
+ rvolume = (volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
format = format_native2esd(&conn->sink_input->sample_spec);
}
@@ -643,11 +644,12 @@ static int esd_proto_stream_pan(struct connection *c, PA_GCC_UNUSED esd_proto_t
rvolume = MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume);
data = (const char*)data + sizeof(uint32_t);
- if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx))) {
- assert(conn->sink_input);
- conn->sink_input->volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
- conn->sink_input->volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
- conn->sink_input->volume.channels = 2;
+ if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx)) && conn->sink_input) {
+ pa_cvolume volume;
+ volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
+ volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
+ volume.channels = 2;
+ pa_sink_input_set_volume(conn->sink_input, &volume);
ok = 1;
} else
ok = 0;
diff --git a/src/polypcore/protocol-native.c b/src/polypcore/protocol-native.c
index a0fc286d..aa636072 100644
--- a/src/polypcore/protocol-native.c
+++ b/src/polypcore/protocol-native.c
@@ -386,7 +386,7 @@ static struct playback_stream* playback_stream_new(
if (ssync && ssync->sink_input->sink != sink)
return NULL;
- if (!(sink_input = pa_sink_input_new(sink, __FILE__, name, ss, map, 0, -1)))
+ if (!(sink_input = pa_sink_input_new(sink, __FILE__, name, ss, map, volume, 0, -1)))
return NULL;
s = pa_xnew(struct playback_stream, 1);
@@ -436,8 +436,6 @@ static struct playback_stream* playback_stream_new(
s->requested_bytes = 0;
s->drain_request = 0;
-
- s->sink_input->volume = *volume;
pa_idxset_put(c->output_streams, s, &s->index);
diff --git a/src/polypcore/protocol-simple.c b/src/polypcore/protocol-simple.c
index c2f53444..1e3b169c 100644
--- a/src/polypcore/protocol-simple.c
+++ b/src/polypcore/protocol-simple.c
@@ -346,7 +346,7 @@ static void on_connection(pa_socket_server*s, pa_iochannel *io, void *userdata)
goto fail;
}
- if (!(c->sink_input = pa_sink_input_new(sink, __FILE__, c->client->name, &p->sample_spec, NULL, 0, -1))) {
+ if (!(c->sink_input = pa_sink_input_new(sink, __FILE__, c->client->name, &p->sample_spec, NULL, NULL, 0, -1))) {
pa_log(__FILE__": Failed to create sink input.");
goto fail;
}
diff --git a/src/polypcore/sink-input.c b/src/polypcore/sink-input.c
index e1703b97..26e63b85 100644
--- a/src/polypcore/sink-input.c
+++ b/src/polypcore/sink-input.c
@@ -43,6 +43,7 @@ pa_sink_input* pa_sink_input_new(
const char *name,
const pa_sample_spec *spec,
const pa_channel_map *map,
+ const pa_cvolume *volume,
int variable_rate,
int resample_method) {
@@ -56,6 +57,7 @@ pa_sink_input* pa_sink_input_new(
assert(spec);
assert(s->state == PA_SINK_RUNNING);
+
if (pa_idxset_size(s->inputs) >= PA_MAX_INPUTS_PER_SINK) {
pa_log_warn(__FILE__": Failed to create sink input: too many inputs per sink.");
return NULL;
@@ -64,8 +66,16 @@ pa_sink_input* pa_sink_input_new(
if (resample_method == PA_RESAMPLER_INVALID)
resample_method = s->core->resample_method;
+ if (map && spec->channels != map->channels)
+ return NULL;
+
+ if (volume && spec->channels != volume->channels)
+ return NULL;
+
if (!map) {
- pa_channel_map_init_auto(&tmap, spec->channels);
+ if (!(pa_channel_map_init_auto(&tmap, spec->channels)))
+ return NULL;
+
map = &tmap;
}
@@ -85,7 +95,10 @@ pa_sink_input* pa_sink_input_new(
i->sample_spec = *spec;
i->channel_map = *map;
- pa_cvolume_reset(&i->volume, spec->channels);
+ if (volume)
+ i->volume = *volume;
+ else
+ pa_cvolume_reset(&i->volume, spec->channels);
i->peek = NULL;
i->drop = NULL;
diff --git a/src/polypcore/sink-input.h b/src/polypcore/sink-input.h
index e4b8bda4..4cf4460a 100644
--- a/src/polypcore/sink-input.h
+++ b/src/polypcore/sink-input.h
@@ -75,6 +75,7 @@ pa_sink_input* pa_sink_input_new(
const char *name,
const pa_sample_spec *spec,
const pa_channel_map *map,
+ const pa_cvolume *volume,
int variable_rate,
int resample_method);
diff --git a/src/polypcore/sound-file-stream.c b/src/polypcore/sound-file-stream.c
index e242cfea..ca762d6a 100644
--- a/src/polypcore/sound-file-stream.c
+++ b/src/polypcore/sound-file-stream.c
@@ -158,11 +158,9 @@ int pa_play_file(pa_sink *sink, const char *fname, const pa_cvolume *volume) {
goto fail;
}
- if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, fname, &ss, NULL, 0, -1)))
+ if (!(u->sink_input = pa_sink_input_new(sink, __FILE__, fname, &ss, NULL, volume, 0, -1)))
goto fail;
- if (volume)
- u->sink_input->volume = *volume;
u->sink_input->peek = sink_input_peek;
u->sink_input->drop = sink_input_drop;
u->sink_input->kill = sink_input_kill;
diff --git a/src/polypcore/util.c b/src/polypcore/util.c
index c1f82a20..6f7f8819 100644
--- a/src/polypcore/util.c
+++ b/src/polypcore/util.c
@@ -1037,7 +1037,7 @@ int pa_unlock_lockfile(const char *fn, int fd) {
* file system. If "result" is non-NULL, a pointer to a newly
* allocated buffer containing the used configuration file is
* stored there.*/
-FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result) {
+FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result, const char *mode) {
const char *fn;
char h[PATH_MAX];
@@ -1058,7 +1058,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
if (result)
*result = pa_xstrdup(fn);
- return fopen(fn, "r");
+ return fopen(fn, mode);
}
if (local && pa_get_home_dir(h, sizeof(h))) {
@@ -1073,7 +1073,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
fn = buf;
#endif
- f = fopen(fn, "r");
+ f = fopen(fn, mode);
if (f || errno != ENOENT) {
if (result)
@@ -1101,7 +1101,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
if (result)
*result = pa_xstrdup(global);
- return fopen(global, "r");
+ return fopen(global, mode);
}
/* Format the specified data as a hexademical string */
diff --git a/src/polypcore/util.h b/src/polypcore/util.h
index 2d5894c3..df71672f 100644
--- a/src/polypcore/util.h
+++ b/src/polypcore/util.h
@@ -87,7 +87,7 @@ int pa_lock_fd(int fd, int b);
int pa_lock_lockfile(const char *fn);
int pa_unlock_lockfile(const char *fn, int fd);
-FILE *pa_open_config_file(const char *env, const char *global, const char *local, char **result);
+FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result, const char *mode);
char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength);
size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength);