[polypaudio-commits] r858 - in /trunk/src: daemon/ modules/ modules/rtp/ polyp/ polypcore/

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat May 13 17:41:20 PDT 2006


Author: lennart
Date: Sun May 14 02:41:18 2006
New Revision: 858

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=858&root=polypaudio&view=rev
Log:
* 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

Modified:
    trunk/src/daemon/daemon-conf.c
    trunk/src/modules/module-combine.c
    trunk/src/modules/module-match.c
    trunk/src/modules/module-sine.c
    trunk/src/modules/rtp/module-rtp-recv.c
    trunk/src/polyp/client-conf.c
    trunk/src/polypcore/play-memchunk.c
    trunk/src/polypcore/protocol-esound.c
    trunk/src/polypcore/protocol-native.c
    trunk/src/polypcore/protocol-simple.c
    trunk/src/polypcore/sink-input.c
    trunk/src/polypcore/sink-input.h
    trunk/src/polypcore/sound-file-stream.c
    trunk/src/polypcore/util.c
    trunk/src/polypcore/util.h

Modified: trunk/src/daemon/daemon-conf.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/daemon/daemon-conf.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/daemon/daemon-conf.c (original)
+++ trunk/src/daemon/daemon-conf.c Sun May 14 02:41:18 2006
@@ -84,7 +84,7 @@
     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 @@
 
     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));

Modified: trunk/src/modules/module-combine.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-combine.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/modules/module-combine.c (original)
+++ trunk/src/modules/module-combine.c Sun May 14 02:41:18 2006
@@ -238,7 +238,7 @@
             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;

Modified: trunk/src/modules/module-match.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-match.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/modules/module-match.c (original)
+++ trunk/src/modules/module-match.c Sun May 14 02:41:18 2006
@@ -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 @@
 
     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));

Modified: trunk/src/modules/module-sine.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-sine.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/modules/module-sine.c (original)
+++ trunk/src/modules/module-sine.c Sun May 14 02:41:18 2006
@@ -141,7 +141,7 @@
     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;

Modified: trunk/src/modules/rtp/module-rtp-recv.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/rtp/module-rtp-recv.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/modules/rtp/module-rtp-recv.c (original)
+++ trunk/src/modules/rtp/module-rtp-recv.c Sun May 14 02:41:18 2006
@@ -286,7 +286,7 @@
                           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) {

Modified: trunk/src/polyp/client-conf.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/client-conf.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polyp/client-conf.c (original)
+++ trunk/src/polyp/client-conf.c Sun May 14 02:41:18 2006
@@ -119,7 +119,7 @@
 
     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));

Modified: trunk/src/polypcore/play-memchunk.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/play-memchunk.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/play-memchunk.c (original)
+++ trunk/src/polypcore/play-memchunk.c Sun May 14 02:41:18 2006
@@ -98,12 +98,9 @@
     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;

Modified: trunk/src/polypcore/protocol-esound.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/protocol-esound.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/protocol-esound.c (original)
+++ trunk/src/polypcore/protocol-esound.c Sun May 14 02:41:18 2006
@@ -345,7 +345,7 @@
 
     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 @@
         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 @@
     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;

Modified: trunk/src/polypcore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/protocol-native.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/protocol-native.c (original)
+++ trunk/src/polypcore/protocol-native.c Sun May 14 02:41:18 2006
@@ -386,7 +386,7 @@
     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 @@
     
     s->requested_bytes = 0;
     s->drain_request = 0;
-
-    s->sink_input->volume = *volume;
     
     pa_idxset_put(c->output_streams, s, &s->index);
 

Modified: trunk/src/polypcore/protocol-simple.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/protocol-simple.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/protocol-simple.c (original)
+++ trunk/src/polypcore/protocol-simple.c Sun May 14 02:41:18 2006
@@ -346,7 +346,7 @@
             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;
         }

Modified: trunk/src/polypcore/sink-input.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/sink-input.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/sink-input.c (original)
+++ trunk/src/polypcore/sink-input.c Sun May 14 02:41:18 2006
@@ -43,6 +43,7 @@
     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 @@
     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 @@
     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 @@
     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;

Modified: trunk/src/polypcore/sink-input.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/sink-input.h?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/sink-input.h (original)
+++ trunk/src/polypcore/sink-input.h Sun May 14 02:41:18 2006
@@ -75,6 +75,7 @@
     const char *name,
     const pa_sample_spec *spec,
     const pa_channel_map *map,
+    const pa_cvolume *volume,
     int variable_rate,
     int resample_method);
 

Modified: trunk/src/polypcore/sound-file-stream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/sound-file-stream.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/sound-file-stream.c (original)
+++ trunk/src/polypcore/sound-file-stream.c Sun May 14 02:41:18 2006
@@ -158,11 +158,9 @@
         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;

Modified: trunk/src/polypcore/util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.c?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/util.c (original)
+++ trunk/src/polypcore/util.c Sun May 14 02:41:18 2006
@@ -1037,7 +1037,7 @@
  * 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 @@
         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 @@
         fn = buf;
 #endif
 
-        f = fopen(fn, "r");
+        f = fopen(fn, mode);
 
         if (f || errno != ENOENT) {
             if (result)
@@ -1101,7 +1101,7 @@
     if (result)
         *result = pa_xstrdup(global);
     
-    return fopen(global, "r");
+    return fopen(global, mode);
 }
                  
 /* Format the specified data as a hexademical string */

Modified: trunk/src/polypcore/util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/util.h?rev=858&root=polypaudio&r1=857&r2=858&view=diff
==============================================================================
--- trunk/src/polypcore/util.h (original)
+++ trunk/src/polypcore/util.h Sun May 14 02:41:18 2006
@@ -87,7 +87,7 @@
 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);




More information about the pulseaudio-commits mailing list