]> code.delx.au - pulseaudio/blobdiff - src/modules/module-pipe-sink.c
introduce default channel map in addition to the default sample spec
[pulseaudio] / src / modules / module-pipe-sink.c
index f389cd064ef5ce5c84bb8b20c664b66b7b704d4a..f3b0e8b0e6297d819c737e60414931f7fd741015 100644 (file)
@@ -101,8 +101,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             size_t n = 0;
             int l;
 
-#ifdef TIOCINQ
-            if (ioctl(u->fd, TIOCINQ, &l) >= 0 && l > 0)
+#ifdef FIONREAD
+            if (ioctl(u->fd, FIONREAD, &l) >= 0 && l > 0)
                 n = (size_t) l;
 #endif
 
@@ -138,15 +138,17 @@ static int process_render(struct userdata *u) {
 
             if (errno == EINTR)
                 continue;
-            else if (errno != EAGAIN) {
+            else if (errno == EAGAIN)
+                return 0;
+            else {
                 pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
                 return -1;
             }
 
         } else {
 
-            u->memchunk.index += l;
-            u->memchunk.length -= l;
+            u->memchunk.index += (size_t) l;
+            u->memchunk.length -= (size_t) l;
 
             if (u->memchunk.length <= 0) {
                 pa_memblock_unref(u->memchunk.memblock);
@@ -189,7 +191,7 @@ static void thread_func(void *userdata) {
         }
 
         /* Hmm, nothing to do. Let's sleep */
-        pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
+        pollfd->events = (short) (u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0);
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
             goto fail;
@@ -232,6 +234,7 @@ int pa__init(pa_module*m) {
     }
 
     ss = m->core->default_sample_spec;
+    map = m->core->default_channel_map;
     if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
         pa_log("Invalid sample format specification or channel map");
         goto fail;
@@ -315,6 +318,15 @@ fail:
     return -1;
 }
 
+int pa__get_n_used(pa_module *m) {
+    struct userdata *u;
+
+    pa_assert(m);
+    pa_assert_se(u = m->userdata);
+
+    return pa_sink_linked_by(u->sink);
+}
+
 void pa__done(pa_module*m) {
     struct userdata *u;