[polypaudio-commits] r560 - in /trunk/src: Makefile.am polyp/introspect.c polyp/introspect.h polypcore/cli-command.c polypcore/core-def.h polypcore/native-common.h polypcore/pdispatch.c polypcore/protocol-native.c polypcore/sink.h polypcore/source.c polypcore/source.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Feb 22 06:11:25 PST 2006


Author: ossman
Date: Wed Feb 22 15:11:23 2006
New Revision: 560

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=560&root=polypaudio&view=rev
Log:
Support for setting volume on sources.

Added:
    trunk/src/polypcore/core-def.h   (with props)
Modified:
    trunk/src/Makefile.am
    trunk/src/polyp/introspect.c
    trunk/src/polyp/introspect.h
    trunk/src/polypcore/cli-command.c
    trunk/src/polypcore/native-common.h
    trunk/src/polypcore/pdispatch.c
    trunk/src/polypcore/protocol-native.c
    trunk/src/polypcore/sink.h
    trunk/src/polypcore/source.c
    trunk/src/polypcore/source.h

Modified: trunk/src/Makefile.am
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/Makefile.am?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Feb 22 15:11:23 2006
@@ -425,6 +425,7 @@
 		polypcore/cli-text.h \
 		polypcore/client.h \
 		polypcore/core.h \
+		polypcore/core-def.h \
 		polypcore/core-scache.h \
 		polypcore/core-subscribe.h \
 		polypcore/conf-parser.h \

Modified: trunk/src/polyp/introspect.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/introspect.c?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polyp/introspect.c (original)
+++ trunk/src/polyp/introspect.c Wed Feb 22 15:11:23 2006
@@ -252,6 +252,7 @@
                 pa_tagstruct_get_sample_spec(t, &i.sample_spec) < 0 ||
                 pa_tagstruct_get_channel_map(t, &i.channel_map) < 0 ||
                 pa_tagstruct_getu32(t, &i.owner_module) < 0 ||
+                pa_tagstruct_get_cvolume(t, &i.volume) < 0 ||
                 pa_tagstruct_getu32(t, &i.monitor_of_sink) < 0 ||
                 pa_tagstruct_gets(t, &i.monitor_of_sink_name) < 0 ||
                 pa_tagstruct_get_usec(t, &i.latency) < 0 ||
@@ -727,6 +728,60 @@
     return o;
 }
 
+pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
+    pa_operation *o;
+    pa_tagstruct *t;
+    uint32_t tag;
+
+    assert(c);
+    assert(c->ref >= 1);
+    assert(volume);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+    t = pa_tagstruct_new(NULL, 0);
+    pa_tagstruct_putu32(t, PA_COMMAND_SET_SOURCE_VOLUME);
+    pa_tagstruct_putu32(t, tag = c->ctag++);
+    pa_tagstruct_putu32(t, idx);
+    pa_tagstruct_puts(t, NULL);
+    pa_tagstruct_put_cvolume(t, volume);
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o));
+
+    return o;
+}
+
+pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata) {
+    pa_operation *o;
+    pa_tagstruct *t;
+    uint32_t tag;
+
+    assert(c);
+    assert(c->ref >= 1);
+    assert(name);
+    assert(volume);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
+    
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+    t = pa_tagstruct_new(NULL, 0);
+    pa_tagstruct_putu32(t, PA_COMMAND_SET_SOURCE_VOLUME);
+    pa_tagstruct_putu32(t, tag = c->ctag++);
+    pa_tagstruct_putu32(t, PA_INVALID_INDEX);
+    pa_tagstruct_puts(t, name);
+    pa_tagstruct_put_cvolume(t, volume);
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o));
+
+    return o;
+}
+
 /** Sample Cache **/
 
 static void context_get_sample_info_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) {

Modified: trunk/src/polyp/introspect.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/introspect.h?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polyp/introspect.h (original)
+++ trunk/src/polyp/introspect.h Wed Feb 22 15:11:23 2006
@@ -84,6 +84,7 @@
     pa_sample_spec sample_spec;         /**< Sample spec of this source */
     pa_channel_map channel_map;         /**< Channel map \since 0.9 */
     uint32_t owner_module;              /**< Owning module index, or PA_INVALID_INDEX */
+    pa_cvolume volume;                  /**< Volume of the source \since 0.8 */
     uint32_t monitor_of_sink;           /**< If this is a monitor source the index of the owning sink, otherwise PA_INVALID_INDEX */
     const char *monitor_of_sink_name;   /**< Name of the owning sink, or PA_INVALID_INDEX */
     pa_usec_t latency;                  /**< Length of filled record buffer of this source. \since 0.5 */
@@ -213,6 +214,12 @@
 /** Set the volume of a sink input stream */
 pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
 
+/** Set the volume of a source device specified by its index \since 0.8 */
+pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
+
+/** Set the volume of a source device specified by its name \since 0.8 */
+pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *name, const pa_cvolume *volume, pa_context_success_cb_t cb, void *userdata);
+
 /** Memory block statistics */
 typedef struct pa_stat_info {
     uint32_t memblock_total;           /**< Currently allocated memory blocks */

Modified: trunk/src/polypcore/cli-command.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/cli-command.c?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/cli-command.c (original)
+++ trunk/src/polypcore/cli-command.c Wed Feb 22 15:11:23 2006
@@ -77,6 +77,7 @@
 static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
 static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
 static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
+static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
 static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
 static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
 static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, int *fail);
@@ -114,6 +115,7 @@
     { "unload-module",           pa_cli_command_unload,             "Unload a module (args: index)",                             2},
     { "set-sink-volume",         pa_cli_command_sink_volume,        "Set the volume of a sink (args: index|name, volume)",             3},
     { "set-sink-input-volume",   pa_cli_command_sink_input_volume,  "Set the volume of a sink input (args: index|name, volume)", 3},
+    { "set-source-volume",       pa_cli_command_source_volume,      "Set the volume of a source (args: index|name, volume)", 3},
     { "set-default-sink",        pa_cli_command_sink_default,       "Set the default sink (args: index|name)", 2},
     { "set-default-source",      pa_cli_command_source_default,     "Set the default source (args: index|name)", 2},
     { "kill-client",             pa_cli_command_kill_client,        "Kill a client (args: index)", 2},
@@ -376,6 +378,37 @@
     return 0;
 }
 
+static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
+    const char *n, *v;
+    pa_source *source;
+    uint32_t volume;
+    pa_cvolume cvolume;
+
+    if (!(n = pa_tokenizer_get(t, 1))) {
+        pa_strbuf_puts(buf, "You need to specify a source either by its name or its index.\n");
+        return -1;
+    }
+
+    if (!(v = pa_tokenizer_get(t, 2))) {
+        pa_strbuf_puts(buf, "You need to specify a volume >= 0. (0 is muted, 0x100 is normal volume)\n");
+        return -1;
+    }
+
+    if (pa_atou(v, &volume) < 0) {
+        pa_strbuf_puts(buf, "Failed to parse volume.\n");
+        return -1;
+    }
+
+    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE, 1))) {
+        pa_strbuf_puts(buf, "No source found by this name or index.\n");
+        return -1;
+    }
+
+    pa_cvolume_set(&cvolume, source->sample_spec.channels, volume);
+    pa_source_set_volume(source, PA_MIXER_HARDWARE, &cvolume);
+    return 0;
+}
+
 static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
     const char *n;
     assert(c && t);
@@ -633,7 +666,8 @@
 
 static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, PA_GCC_UNUSED int *fail) {
     pa_module *m;
-    pa_sink *s;
+    pa_sink *sink;
+    pa_source *source;
     int nl;
     const char *p;
     uint32_t idx;
@@ -667,8 +701,8 @@
 
     nl = 0;
 
-    for (s = pa_idxset_first(c->sinks, &idx); s; s = pa_idxset_next(c->sinks, &idx)) {
-        if (s->owner && s->owner->auto_unload)
+    for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx)) {
+        if (sink->owner && sink->owner->auto_unload)
             continue;
 
         if (!nl) {
@@ -676,7 +710,19 @@
             nl = 1;
         }
 
-        pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", s->name, pa_cvolume_avg(pa_sink_get_volume(s, PA_MIXER_HARDWARE)));
+        pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", sink->name, pa_cvolume_avg(pa_sink_get_volume(sink, PA_MIXER_HARDWARE)));
+    }
+
+    for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) {
+        if (source->owner && source->owner->auto_unload)
+            continue;
+
+        if (!nl) {
+            pa_strbuf_puts(buf, "\n");
+            nl = 1;
+        }
+
+        pa_strbuf_printf(buf, "set-source-volume %s 0x%03x\n", source->name, pa_cvolume_avg(pa_source_get_volume(source, PA_MIXER_HARDWARE)));
     }
 
 

Added: trunk/src/polypcore/core-def.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/core-def.h?rev=560&root=polypaudio&view=auto
==============================================================================
--- trunk/src/polypcore/core-def.h (added)
+++ trunk/src/polypcore/core-def.h Wed Feb 22 15:11:23 2006
@@ -1,0 +1,30 @@
+#ifndef foocoredefhfoo
+#define foocoredefhfoo
+
+/* $Id$ */
+
+/***
+  This file is part of polypaudio.
+ 
+  polypaudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+ 
+  polypaudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+ 
+  You should have received a copy of the GNU Lesser General Public License
+  along with polypaudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+typedef enum pa_mixer {
+    PA_MIXER_SOFTWARE,
+    PA_MIXER_HARDWARE
+} pa_mixer_t;
+
+#endif

Propchange: trunk/src/polypcore/core-def.h
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: trunk/src/polypcore/native-common.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/native-common.h?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/native-common.h (original)
+++ trunk/src/polypcore/native-common.h Wed Feb 22 15:11:23 2006
@@ -71,6 +71,8 @@
     
     PA_COMMAND_SET_SINK_VOLUME,
     PA_COMMAND_SET_SINK_INPUT_VOLUME,
+    PA_COMMAND_SET_SOURCE_VOLUME,
+    
     PA_COMMAND_CORK_PLAYBACK_STREAM,
     PA_COMMAND_FLUSH_PLAYBACK_STREAM,
     PA_COMMAND_TRIGGER_PLAYBACK_STREAM,

Modified: trunk/src/polypcore/pdispatch.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/pdispatch.c?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/pdispatch.c (original)
+++ trunk/src/polypcore/pdispatch.c Wed Feb 22 15:11:23 2006
@@ -82,6 +82,7 @@
     [PA_COMMAND_SUBSCRIBE_EVENT] = "SUBSCRIBE_EVENT",
     [PA_COMMAND_SET_SINK_VOLUME] = "SET_SINK_VOLUME",
     [PA_COMMAND_SET_SINK_INPUT_VOLUME] = "SET_SINK_INPUT_VOLUME",
+    [PA_COMMAND_SET_SOURCE_VOLUME] = "SET_SOURCE_VOLME",
     [PA_COMMAND_TRIGGER_PLAYBACK_STREAM] = "TRIGGER_PLAYBACK_STREAM",
     [PA_COMMAND_FLUSH_PLAYBACK_STREAM] = "FLUSH_PLAYBACK_STREAM",
     [PA_COMMAND_CORK_PLAYBACK_STREAM] = "CORK_PLAYBACK_STREAM",

Modified: trunk/src/polypcore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/protocol-native.c?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/protocol-native.c (original)
+++ trunk/src/polypcore/protocol-native.c Wed Feb 22 15:11:23 2006
@@ -216,6 +216,7 @@
 
     [PA_COMMAND_SET_SINK_VOLUME] = command_set_volume,
     [PA_COMMAND_SET_SINK_INPUT_VOLUME] = command_set_volume,
+    [PA_COMMAND_SET_SOURCE_VOLUME] = command_set_volume,
     
     [PA_COMMAND_CORK_PLAYBACK_STREAM] = command_cork_playback_stream,
     [PA_COMMAND_FLUSH_PLAYBACK_STREAM] = command_flush_playback_stream,
@@ -1254,16 +1255,20 @@
 
 static void source_fill_tagstruct(pa_tagstruct *t, pa_source *source) {
     assert(t && source);
-    pa_tagstruct_putu32(t, source->index);
-    pa_tagstruct_puts(t, source->name);
-    pa_tagstruct_puts(t, source->description);
-    pa_tagstruct_put_sample_spec(t, &source->sample_spec);
-    pa_tagstruct_put_channel_map(t, &source->channel_map);
-    pa_tagstruct_putu32(t, source->owner ? source->owner->index : (uint32_t) -1);
-    pa_tagstruct_putu32(t, source->monitor_of ? source->monitor_of->index : (uint32_t) -1);
-    pa_tagstruct_puts(t, source->monitor_of ? source->monitor_of->name : NULL);
-    pa_tagstruct_put_usec(t, pa_source_get_latency(source));
-    pa_tagstruct_puts(t, source->driver);
+    pa_tagstruct_put(
+        t,
+        PA_TAG_U32, source->index,
+        PA_TAG_STRING, source->name,
+        PA_TAG_STRING, source->description,
+        PA_TAG_SAMPLE_SPEC, &source->sample_spec,
+        PA_TAG_CHANNEL_MAP, &source->channel_map,
+        PA_TAG_U32, source->owner ? source->owner->index : PA_INVALID_INDEX,
+        PA_TAG_CVOLUME, pa_source_get_volume(source, PA_MIXER_HARDWARE),
+        PA_TAG_U32, source->monitor_of ? source->monitor_of->index : PA_INVALID_INDEX,
+        PA_TAG_STRING, source->monitor_of ? source->monitor_of->name : NULL,
+        PA_TAG_USEC, pa_source_get_latency(source),
+        PA_TAG_STRING, source->driver,
+        PA_TAG_INVALID);
 }
 
 static void client_fill_tagstruct(pa_tagstruct *t, pa_client *client) {
@@ -1558,12 +1563,14 @@
     uint32_t idx;
     pa_cvolume volume;
     pa_sink *sink = NULL;
+    pa_source *source = NULL;
     pa_sink_input *si = NULL;
     const char *name = NULL;
     assert(c && t);
 
     if (pa_tagstruct_getu32(t, &idx) < 0 ||
         (command == PA_COMMAND_SET_SINK_VOLUME && pa_tagstruct_gets(t, &name) < 0) ||
+        (command == PA_COMMAND_SET_SOURCE_VOLUME && pa_tagstruct_gets(t, &name) < 0) ||
         pa_tagstruct_get_cvolume(t, &volume) ||
         !pa_tagstruct_eof(t)) {
         protocol_error(c);
@@ -1580,18 +1587,25 @@
             sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
         else
             sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1);
+    } else if (command == PA_COMMAND_SET_SOURCE_VOLUME) {
+        if (idx != (uint32_t) -1)
+            source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+        else
+            source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1);
     }  else {
         assert(command == PA_COMMAND_SET_SINK_INPUT_VOLUME);
         si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
     }
 
-    if (!si && !sink) {
+    if (!si && !sink && !source) {
         pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY);
         return;
     }
 
     if (sink)
         pa_sink_set_volume(sink, PA_MIXER_HARDWARE, &volume);
+    else if (source)
+        pa_source_set_volume(source, PA_MIXER_HARDWARE, &volume);
     else if (si)
         pa_sink_input_set_volume(si, &volume);
 

Modified: trunk/src/polypcore/sink.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/sink.h?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/sink.h (original)
+++ trunk/src/polypcore/sink.h Wed Feb 22 15:11:23 2006
@@ -29,6 +29,7 @@
 #include <polyp/sample.h>
 #include <polyp/channelmap.h>
 #include <polyp/volume.h>
+#include <polypcore/core-def.h>
 #include <polypcore/core.h>
 #include <polypcore/idxset.h>
 #include <polypcore/source.h>
@@ -40,11 +41,6 @@
     PA_SINK_RUNNING,
     PA_SINK_DISCONNECTED
 } pa_sink_state_t;
-
-typedef enum pa_mixer {
-    PA_MIXER_SOFTWARE,
-    PA_MIXER_HARDWARE
-} pa_mixer_t;
 
 struct pa_sink {
     int ref;

Modified: trunk/src/polypcore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/source.c?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/source.c (original)
+++ trunk/src/polypcore/source.c Wed Feb 22 15:11:23 2006
@@ -77,8 +77,13 @@
     s->outputs = pa_idxset_new(NULL, NULL);
     s->monitor_of = NULL;
 
+    pa_cvolume_reset(&s->sw_volume, spec->channels);
+    pa_cvolume_reset(&s->hw_volume, spec->channels);
+
     s->get_latency = NULL;
     s->notify = NULL;
+    s->set_hw_volume = NULL;
+    s->get_hw_volume = NULL;
     s->userdata = NULL;
 
     r = pa_idxset_put(core->sources, s, &s->index);
@@ -110,6 +115,8 @@
 
     s->get_latency = NULL;
     s->notify = NULL;
+    s->get_hw_volume = NULL;
+    s->set_hw_volume = NULL;
     
     s->state = PA_SOURCE_DISCONNECTED;
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
@@ -173,7 +180,14 @@
     assert(chunk);
 
     pa_source_ref(s);
+
+    if (!pa_cvolume_is_norm(&s->sw_volume)) {
+        pa_memchunk_make_writable(chunk, s->core->memblock_stat, 0);
+        pa_volume_memchunk(chunk, &s->sample_spec, &s->sw_volume);
+    }
+
     pa_idxset_foreach(s->outputs, do_post, (void*) chunk);
+
     pa_source_unref(s);
 }
 
@@ -194,3 +208,40 @@
     return s->get_latency(s);
 }
 
+void pa_source_set_volume(pa_source *s, pa_mixer_t m, const pa_cvolume *volume) {
+    pa_cvolume *v;
+    
+    assert(s);
+    assert(s->ref >= 1);
+    assert(volume);
+
+    if (m == PA_MIXER_HARDWARE && s->set_hw_volume) 
+        v = &s->hw_volume;
+    else
+        v = &s->sw_volume;
+
+    if (pa_cvolume_equal(v, volume))
+        return;
+        
+    *v = *volume;
+
+    if (v == &s->hw_volume)
+        if (s->set_hw_volume(s) < 0)
+            s->sw_volume =  *volume;
+
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+}
+
+const pa_cvolume *pa_source_get_volume(pa_source *s, pa_mixer_t m) {
+    assert(s);
+    assert(s->ref >= 1);
+
+    if (m == PA_MIXER_HARDWARE && s->set_hw_volume) {
+
+        if (s->get_hw_volume)
+            s->get_hw_volume(s);
+        
+        return &s->hw_volume;
+    } else
+        return &s->sw_volume;
+}

Modified: trunk/src/polypcore/source.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/source.h?rev=560&root=polypaudio&r1=559&r2=560&view=diff
==============================================================================
--- trunk/src/polypcore/source.h (original)
+++ trunk/src/polypcore/source.h Wed Feb 22 15:11:23 2006
@@ -28,6 +28,8 @@
 
 #include <polyp/sample.h>
 #include <polyp/channelmap.h>
+#include <polyp/volume.h>
+#include <polypcore/core-def.h>
 #include <polypcore/core.h>
 #include <polypcore/idxset.h>
 #include <polypcore/memblock.h>
@@ -56,9 +58,13 @@
 
     pa_idxset *outputs;
     pa_sink *monitor_of;
+
+    pa_cvolume hw_volume, sw_volume;
     
     void (*notify)(pa_source*source);
     pa_usec_t (*get_latency)(pa_source *s);
+    int (*set_hw_volume)(pa_source *s);
+    int (*get_hw_volume)(pa_source *s);
     
     void *userdata;
 };
@@ -84,4 +90,7 @@
 
 pa_usec_t pa_source_get_latency(pa_source *s);
 
+void pa_source_set_volume(pa_source *source, pa_mixer_t m, const pa_cvolume *volume);
+const pa_cvolume *pa_source_get_volume(pa_source *source, pa_mixer_t m);
+
 #endif




More information about the pulseaudio-commits mailing list