[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] null-sink: Change block size to 50 msec when norewinds is set

PulseAudio Marge Bot gitlab at gitlab.freedesktop.org
Fri Nov 27 17:20:44 UTC 2020



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
1e7adb4f by Jaechul Lee at 2020-11-27T17:15:02+00:00
null-sink: Change block size to 50 msec when norewinds is set

playing sound through null sink takes almost 2 seconds at first time
playback when norewinds is set. Because block_usec is set 2 seconds at
initializing time. The value will be changed 50 msec after calling
update_request_latency callback.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/406>

- - - - -


1 changed file:

- src/modules/module-null-sink.c


Changes:

=====================================
src/modules/module-null-sink.c
=====================================
@@ -57,8 +57,8 @@ PA_MODULE_USAGE(
         "norewinds=<disable rewinds>");
 
 #define DEFAULT_SINK_NAME "null"
-#define BLOCK_USEC (PA_USEC_PER_SEC * 2)
-#define NOREWINDS_MAX_LATENCY_USEC (50*PA_USEC_PER_MSEC)
+#define BLOCK_USEC (2 * PA_USEC_PER_SEC)
+#define BLOCK_USEC_NOREWINDS (50 * PA_USEC_PER_MSEC)
 
 struct userdata {
     pa_core *core;
@@ -318,6 +318,7 @@ int pa__init(pa_module*m) {
     u->core = m->core;
     u->module = m;
     u->rtpoll = pa_rtpoll_new();
+    u->block_usec = BLOCK_USEC;
 
     if (pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll) < 0) {
         pa_log("pa_thread_mq_init() failed.");
@@ -381,13 +382,15 @@ int pa__init(pa_module*m) {
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
     pa_sink_set_rtpoll(u->sink, u->rtpoll);
 
-    u->block_usec = BLOCK_USEC;
-    nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
-
     if(pa_modargs_get_value_boolean(ma, "norewinds", &u->norewinds) < 0){
         pa_log("Invalid argument, norewinds expects a boolean value.");
     }
 
+    if (u->norewinds)
+        u->block_usec = BLOCK_USEC_NOREWINDS;
+
+    nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
+
     if(u->norewinds){
         pa_sink_set_max_rewind(u->sink, 0);
     } else {
@@ -401,11 +404,7 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    if(u->norewinds){
-        pa_sink_set_latency_range(u->sink, 0, NOREWINDS_MAX_LATENCY_USEC);
-    } else {
-        pa_sink_set_latency_range(u->sink, 0, BLOCK_USEC);
-    }
+    pa_sink_set_latency_range(u->sink, 0, u->block_usec);
 
     pa_sink_put(u->sink);
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/1e7adb4fdbc7db172482dab23e4509191fe5f45f

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/1e7adb4fdbc7db172482dab23e4509191fe5f45f
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20201127/99b130ff/attachment-0001.htm>


More information about the pulseaudio-commits mailing list