[polypaudio-commits] r584 - /trunk/src/modules/module-solaris.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Feb 23 01:44:50 PST 2006


Author: ossman
Date: Thu Feb 23 10:44:50 2006
New Revision: 584

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=584&root=polypaudio&view=rev
Log:
Hardware source volume support.

Modified:
    trunk/src/modules/module-solaris.c

Modified: trunk/src/modules/module-solaris.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-solaris.c?rev=584&root=polypaudio&r1=583&r2=584&view=diff
==============================================================================
--- trunk/src/modules/module-solaris.c (original)
+++ trunk/src/modules/module-solaris.c Thu Feb 23 10:44:50 2006
@@ -292,6 +292,40 @@
     return 0;
 }
 
+static int source_get_hw_volume_cb(pa_source *s) {
+    struct userdata *u = s->userdata;
+    audio_info_t info;
+    int err;
+
+    err = ioctl(u->fd, AUDIO_GETINFO, &info);
+    assert(err >= 0);
+
+    pa_cvolume_set(&s->hw_volume, s->hw_volume.channels,
+        info.record.gain * PA_VOLUME_NORM / AUDIO_MAX_GAIN);
+
+    return 0;
+}
+
+static int source_set_hw_volume_cb(pa_source *s) {
+    struct userdata *u = s->userdata;
+    audio_info_t info;
+
+    AUDIO_INITINFO(&info);
+
+    info.record.gain = pa_cvolume_avg(&s->hw_volume) * AUDIO_MAX_GAIN / PA_VOLUME_NORM;
+    assert(info.record.gain <= AUDIO_MAX_GAIN);
+
+    if (ioctl(u->fd, AUDIO_SETINFO, &info) < 0) {
+        if (errno == EINVAL)
+            pa_log(__FILE__": AUDIO_SETINFO: Unsupported volume.");
+        else
+            pa_log(__FILE__": AUDIO_SETINFO: %s", strerror(errno));
+        return -1;
+    }
+
+    return 0;
+}
+
 static int pa_solaris_auto_format(int fd, int mode, pa_sample_spec *ss) {
     audio_info_t info;
 
@@ -436,6 +470,8 @@
         assert(u->source);
         u->source->userdata = u;
         u->source->get_latency = source_get_latency_cb;
+        u->source->get_hw_volume = source_get_hw_volume_cb;
+        u->source->set_hw_volume = source_set_hw_volume_cb;
         pa_source_set_owner(u->source, m);
         u->source->description = pa_sprintf_malloc("Solaris PCM on '%s'", p);
     } else
@@ -483,6 +519,8 @@
     pa_modargs_free(ma);
 
     /* Read mixer settings */
+    if (u->source)
+        sink_get_hw_volume_cb(u->source);
     if (u->sink)
         sink_get_hw_volume_cb(u->sink);
 




More information about the pulseaudio-commits mailing list