]> code.delx.au - pulseaudio/blobdiff - src/modules/module-esound-sink.c
simplify latency range by not allowing stored 'wildcard' ranges anymore
[pulseaudio] / src / modules / module-esound-sink.c
index e0c07d563a6dc614d92ec2b9295ad8c680a6bb9d..2b45e302fc137ae8a120b84f9d4d8fa6ca142390 100644 (file)
@@ -5,7 +5,7 @@
 
   PulseAudio 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,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -156,6 +156,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
 
                 case PA_SINK_UNLINKED:
                 case PA_SINK_INIT:
+                case PA_SINK_INVALID_STATE:
                     ;
             }
 
@@ -165,10 +166,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             pa_usec_t w, r;
 
             r = pa_smoother_get(u->smoother, pa_rtclock_usec());
-            w = pa_bytes_to_usec(u->offset + u->memchunk.length, &u->sink->sample_spec);
+            w = pa_bytes_to_usec((uint64_t) u->offset + u->memchunk.length, &u->sink->sample_spec);
 
             *((pa_usec_t*) data) = w > r ? w - r : 0;
-            break;
+            return 0;
         }
 
         case SINK_MESSAGE_PASS_SOCKET: {
@@ -250,8 +251,8 @@ static void thread_func(void *userdata) {
                     } else {
                         u->offset += l;
 
-                        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);
@@ -285,7 +286,7 @@ static void thread_func(void *userdata) {
                 }
 #endif
 
-                usec = pa_bytes_to_usec(n, &u->sink->sample_spec);
+                usec = pa_bytes_to_usec((uint64_t) n, &u->sink->sample_spec);
 
                 if (usec > u->latency)
                     usec -= u->latency;
@@ -296,7 +297,7 @@ static void thread_func(void *userdata) {
             }
 
             /* Hmm, nothing to do. Let's sleep */
-            pollfd->events = PA_SINK_IS_OPENED(u->sink->thread_info.state) ? POLLOUT : 0;
+            pollfd->events = (short) (PA_SINK_IS_OPENED(u->sink->thread_info.state) ? POLLOUT : 0);
         }
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
@@ -342,7 +343,7 @@ static int do_write(struct userdata *u) {
             return -1;
         }
 
-        u->write_index += r;
+        u->write_index += (size_t) r;
         pa_assert(u->write_index <= u->write_length);
 
         if (u->write_index == u->write_length) {
@@ -458,7 +459,7 @@ static int do_read(struct userdata *u) {
             return -1;
         }
 
-        u->read_index += r;
+        u->read_index += (size_t) r;
         pa_assert(u->read_index <= u->read_length);
 
         if (u->read_index == u->read_length)
@@ -545,7 +546,7 @@ int pa__init(pa_module*m) {
     u->format =
         (ss.format == PA_SAMPLE_U8 ? ESD_BITS8 : ESD_BITS16) |
         (ss.channels == 2 ? ESD_STEREO : ESD_MONO);
-    u->rate = ss.rate;
+    u->rate = (int32_t) ss.rate;
     u->block_size = pa_usec_to_bytes(PA_USEC_PER_SEC/20, &ss);
 
     u->read_data = u->write_data = NULL;
@@ -621,6 +622,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;
     pa_assert(m);