1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
|
From 876624e3147cf3deac847b11bde4b04988971eee Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Sun, 19 Apr 2009 19:02:16 +0200
Subject: [PATCH 02/28] util: if NULL is passed to pa_path_get_filename() just hand it through
---
src/pulse/util.c | 3 ++-
src/pulse/util.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git src/pulse/util.c src/pulse/util.c
index 54a188d..6f1e40a 100644
--- src/pulse/util.c
+++ src/pulse/util.c
@@ -219,7 +219,8 @@ char *pa_get_binary_name(char *s, size_t l) {
char *pa_path_get_filename(const char *p) {
char *fn;
- pa_assert(p);
+ if (!p)
+ return NULL;
if ((fn = strrchr(p, PA_PATH_SEP_CHAR)))
return fn+1;
diff --git src/pulse/util.h src/pulse/util.h
index f6dd40c..ad85653 100644
--- src/pulse/util.h
+++ src/pulse/util.h
@@ -51,7 +51,7 @@ char *pa_get_home_dir(char *s, size_t l);
char *pa_get_binary_name(char *s, size_t l);
/** Return a pointer to the filename inside a path (which is the last
- * component). */
+ * component). If passed NULL will return NULL. */
char *pa_path_get_filename(const char *p);
/** Wait t milliseconds */
From 7f17882bae9d2b694f440d28dc9bb3fcf133fa1a Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 1 May 2009 04:13:15 +0200
Subject: [PATCH 08/28] endian: fix LE/BE order for 24 bit accessor functions
---
src/pulsecore/endianmacros.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git src/pulsecore/endianmacros.h src/pulsecore/endianmacros.h
index 2257937..2b18cf8 100644
--- src/pulsecore/endianmacros.h
+++ src/pulsecore/endianmacros.h
@@ -45,27 +45,27 @@
#define PA_UINT32_SWAP(x) ( (uint32_t) ( ((uint32_t) (x) >> 24) | ((uint32_t) (x) << 24) | (((uint32_t) (x) & 0xFF00) << 8) | ((((uint32_t) (x)) >> 8) & 0xFF00) ) )
#endif
-static inline uint32_t PA_READ24LE(const uint8_t *p) {
+static inline uint32_t PA_READ24BE(const uint8_t *p) {
return
((uint32_t) p[0] << 16) |
((uint32_t) p[1] << 8) |
((uint32_t) p[2]);
}
-static inline uint32_t PA_READ24BE(const uint8_t *p) {
+static inline uint32_t PA_READ24LE(const uint8_t *p) {
return
((uint32_t) p[2] << 16) |
((uint32_t) p[1] << 8) |
((uint32_t) p[0]);
}
-static inline void PA_WRITE24LE(uint8_t *p, uint32_t u) {
+static inline void PA_WRITE24BE(uint8_t *p, uint32_t u) {
p[0] = (uint8_t) (u >> 16);
p[1] = (uint8_t) (u >> 8);
p[2] = (uint8_t) u;
}
-static inline void PA_WRITE24BE(uint8_t *p, uint32_t u) {
+static inline void PA_WRITE24LE(uint8_t *p, uint32_t u) {
p[2] = (uint8_t) (u >> 16);
p[1] = (uint8_t) (u >> 8);
p[0] = (uint8_t) u;
From 11c17636d1d6c7eb4d6278869d3fa91715433ab2 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Sun, 19 Apr 2009 19:04:50 +0200
Subject: [PATCH 09/28] log: print file name only when we have it
---
src/pulsecore/log.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git src/pulsecore/log.c src/pulsecore/log.c
index 60ea9c5..919ebe1 100644
--- src/pulsecore/log.c
+++ src/pulsecore/log.c
@@ -285,7 +285,7 @@ void pa_log_levelv_meta(
if ((_flags & PA_LOG_PRINT_META) && file && line > 0 && func)
pa_snprintf(location, sizeof(location), "[%s:%i %s()] ", file, line, func);
- else if (_flags & (PA_LOG_PRINT_META|PA_LOG_PRINT_FILE))
+ else if ((_flags & (PA_LOG_PRINT_META|PA_LOG_PRINT_FILE)) && file)
pa_snprintf(location, sizeof(location), "%s: ", pa_path_get_filename(file));
else
location[0] = 0;
From 977f59368ba55fac3fe21d7549bc0552daf07d91 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 21 Apr 2009 21:24:33 +0200
Subject: [PATCH 13/28] mutex: when we fail to fill in mutex into static mutex ptr free it again
---
src/pulsecore/mutex-posix.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git src/pulsecore/mutex-posix.c src/pulsecore/mutex-posix.c
index b3e5256..0ff4bee 100644
--- src/pulsecore/mutex-posix.c
+++ src/pulsecore/mutex-posix.c
@@ -153,6 +153,8 @@ pa_mutex* pa_static_mutex_get(pa_static_mutex *s, pa_bool_t recursive, pa_bool_t
if ((pa_atomic_ptr_cmpxchg(&s->ptr, NULL, m)))
return m;
+ pa_mutex_free(m);
+
/* Him, filling in failed, so someone else must have filled in
* already */
pa_assert_se(m = pa_atomic_ptr_load(&s->ptr));
From 776b0817f79b475c9725b53c185484b5e3ff6fbb Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 May 2009 22:30:36 +0200
Subject: [PATCH 14/28] oss: don't deadlock when we try to resume an OSS device that lacks a mixer
---
src/modules/oss/module-oss.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git src/modules/oss/module-oss.c src/modules/oss/module-oss.c
index 9f7863f..aa5f918 100644
--- src/modules/oss/module-oss.c
+++ src/modules/oss/module-oss.c
@@ -477,6 +477,7 @@ static void build_pollfd(struct userdata *u) {
pollfd->revents = 0;
}
+/* Called from IO context */
static int suspend(struct userdata *u) {
pa_assert(u);
pa_assert(u->fd >= 0);
@@ -526,6 +527,7 @@ static int suspend(struct userdata *u) {
return 0;
}
+/* Called from IO context */
static int unsuspend(struct userdata *u) {
int m;
pa_sample_spec ss, *ss_original;
@@ -616,10 +618,10 @@ static int unsuspend(struct userdata *u) {
build_pollfd(u);
- if (u->sink)
- pa_sink_get_volume(u->sink, TRUE, FALSE);
- if (u->source)
- pa_source_get_volume(u->source, TRUE);
+ if (u->sink && u->sink->get_volume)
+ u->sink->get_volume(u->sink);
+ if (u->source && u->source->get_volume)
+ u->source->get_volume(u->source);
pa_log_info("Resumed successfully...");
@@ -631,6 +633,7 @@ fail:
return -1;
}
+/* Called from IO context */
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
struct userdata *u = PA_SINK(o)->userdata;
int ret;
From b8e05f113a44f46a91d3343e3e4a1eb15c98e1c9 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 29 Apr 2009 04:13:07 +0200
Subject: [PATCH 15/28] simple-protocol: don't hit an assert when we call connection_unlink() early
---
src/pulsecore/protocol-simple.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git src/pulsecore/protocol-simple.c src/pulsecore/protocol-simple.c
index 44fe597..776d74b 100644
--- src/pulsecore/protocol-simple.c
+++ src/pulsecore/protocol-simple.c
@@ -130,7 +130,7 @@ static void connection_unlink(connection *c) {
c->io = NULL;
}
- pa_assert_se(pa_idxset_remove_by_data(c->protocol->connections, c, NULL) == c);
+ pa_idxset_remove_by_data(c->protocol->connections, c, NULL);
c->protocol = NULL;
connection_unref(c);
}
From bee02ee03fc82f447a358a564a4d922c0f29cfcf Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 29 Apr 2009 01:46:12 +0200
Subject: [PATCH 16/28] idxset: add enumeration macro PA_IDXSET_FOREACH
---
src/pulsecore/idxset.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git src/pulsecore/idxset.h src/pulsecore/idxset.h
index 7531ea3..6b9ff47 100644
--- src/pulsecore/idxset.h
+++ src/pulsecore/idxset.h
@@ -103,4 +103,8 @@ unsigned pa_idxset_size(pa_idxset*s);
/* Return TRUE of the idxset is empty */
pa_bool_t pa_idxset_isempty(pa_idxset *s);
+
+#define PA_IDXSET_FOREACH(e, s, idx) \
+ for ((e) = pa_idxset_first((s), &(idx)); (e); (e) = pa_idxset_next((s), &(idx)))
+
#endif
From b7eff401100af0de381fba66293d21aca7ff36fa Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 17 Apr 2009 20:30:09 +0200
Subject: [PATCH 17/28] rescue-streams: when one stream move fails try to continue with the remaining ones
---
src/modules/module-rescue-streams.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git src/modules/module-rescue-streams.c src/modules/module-rescue-streams.c
index 4f616e0..7c99a9b 100644
--- src/modules/module-rescue-streams.c
+++ src/modules/module-rescue-streams.c
@@ -77,12 +77,10 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
}
while ((i = pa_idxset_first(sink->inputs, NULL))) {
- if (pa_sink_input_move_to(i, target, FALSE) < 0) {
+ if (pa_sink_input_move_to(i, target, FALSE) < 0)
pa_log_warn("Failed to move sink input %u \"%s\" to %s.", i->index, pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME), target->name);
- return PA_HOOK_OK;
- }
-
- pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index, pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ else
+ pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index, pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME), target->name);
}
@@ -121,12 +119,10 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
pa_assert(target != source);
while ((o = pa_idxset_first(source->outputs, NULL))) {
- if (pa_source_output_move_to(o, target, FALSE) < 0) {
+ if (pa_source_output_move_to(o, target, FALSE) < 0)
pa_log_warn("Failed to move source output %u \"%s\" to %s.", o->index, pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME), target->name);
- return PA_HOOK_OK;
- }
-
- pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index, pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ else
+ pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index, pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME), target->name);
}
From 79510a3b15652b04bffbb798221d27e8d16f4ce2 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 1 May 2009 04:12:24 +0200
Subject: [PATCH 18/28] sample: correctly pass s24-32 formats
---
src/pulse/sample.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git src/pulse/sample.c src/pulse/sample.c
index 1e67b03..ed7b1b0 100644
--- src/pulse/sample.c
+++ src/pulse/sample.c
@@ -231,13 +231,13 @@ pa_sample_format_t pa_parse_sample_format(const char *format) {
else if (strcasecmp(format, "s24re") == 0)
return PA_SAMPLE_S24RE;
else if (strcasecmp(format, "s24-32le") == 0)
- return PA_SAMPLE_S24LE;
+ return PA_SAMPLE_S24_32LE;
else if (strcasecmp(format, "s24-32be") == 0)
- return PA_SAMPLE_S24BE;
+ return PA_SAMPLE_S24_32BE;
else if (strcasecmp(format, "s24-32ne") == 0 || strcasecmp(format, "s24-32") == 0)
- return PA_SAMPLE_S24NE;
+ return PA_SAMPLE_S24_32NE;
else if (strcasecmp(format, "s24-32re") == 0)
- return PA_SAMPLE_S24RE;
+ return PA_SAMPLE_S24_32RE;
return -1;
}
From 397f517aafda4efd00532ba7f19e7045aa853c2a Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 1 May 2009 04:14:40 +0200
Subject: [PATCH 19/28] sample-util: fix iteration loop when adjusting volume of s24 samples
---
src/pulsecore/sample-util.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git src/pulsecore/sample-util.c src/pulsecore/sample-util.c
index 3a9b384..a3e490b 100644
--- src/pulsecore/sample-util.c
+++ src/pulsecore/sample-util.c
@@ -831,9 +831,9 @@ void pa_volume_memchunk(
calc_linear_integer_volume(linear, volume);
- e = (uint8_t*) ptr + c->length/3;
+ e = (uint8_t*) ptr + c->length;
- for (channel = 0, d = ptr; d < e; d++) {
+ for (channel = 0, d = ptr; d < e; d += 3) {
int64_t t;
t = (int64_t)((int32_t) (PA_READ24NE(d) << 8));
@@ -854,9 +854,9 @@ void pa_volume_memchunk(
calc_linear_integer_volume(linear, volume);
- e = (uint8_t*) ptr + c->length/3;
+ e = (uint8_t*) ptr + c->length;
- for (channel = 0, d = ptr; d < e; d++) {
+ for (channel = 0, d = ptr; d < e; d += 3) {
int64_t t;
t = (int64_t)((int32_t) (PA_READ24RE(d) << 8));
From 55244f7a07335115caf2b9cc57aecc0f8cd08030 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 1 May 2009 04:14:02 +0200
Subject: [PATCH 20/28] sample-util: properly allocate silence block for s24-32 formats
---
src/pulsecore/sample-util.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git src/pulsecore/sample-util.c src/pulsecore/sample-util.c
index a3e490b..dda3883 100644
--- src/pulsecore/sample-util.c
+++ src/pulsecore/sample-util.c
@@ -1181,6 +1181,8 @@ pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool,
case PA_SAMPLE_S32BE:
case PA_SAMPLE_S24LE:
case PA_SAMPLE_S24BE:
+ case PA_SAMPLE_S24_32LE:
+ case PA_SAMPLE_S24_32RE:
case PA_SAMPLE_FLOAT32LE:
case PA_SAMPLE_FLOAT32BE:
cache->blocks[PA_SAMPLE_S16LE] = b = silence_memblock_new(pool, 0);
@@ -1189,6 +1191,8 @@ pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool,
cache->blocks[PA_SAMPLE_S32BE] = pa_memblock_ref(b);
cache->blocks[PA_SAMPLE_S24LE] = pa_memblock_ref(b);
cache->blocks[PA_SAMPLE_S24BE] = pa_memblock_ref(b);
+ cache->blocks[PA_SAMPLE_S24_32LE] = pa_memblock_ref(b);
+ cache->blocks[PA_SAMPLE_S24_32BE] = pa_memblock_ref(b);
cache->blocks[PA_SAMPLE_FLOAT32LE] = pa_memblock_ref(b);
cache->blocks[PA_SAMPLE_FLOAT32BE] = pa_memblock_ref(b);
break;
From 100af7efac584be9f229f4daf663dbb939f5d929 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 1 May 2009 04:22:08 +0200
Subject: [PATCH 21/28] sconv: fix a few minor conversion issues
---
src/pulsecore/sconv-s16le.c | 10 +++++-----
src/pulsecore/sconv.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git src/pulsecore/sconv-s16le.c src/pulsecore/sconv-s16le.c
index 307ce7b..43b8cb3 100644
--- src/pulsecore/sconv-s16le.c
+++ src/pulsecore/sconv-s16le.c
@@ -370,7 +370,7 @@ void pa_sconv_s24_32le_to_s16ne(unsigned n, const uint32_t *a, int16_t *b) {
pa_assert(b);
for (; n > 0; n--) {
- *b = (int16_t) ((int32_t) (UINT32_FROM(*a) << 8) >> 16);
+ *b = (int16_t) (((int32_t) (UINT32_FROM(*a) << 8)) >> 16);
a++;
b++;
}
@@ -416,8 +416,8 @@ void pa_sconv_s24_32le_to_float32ne(unsigned n, const uint32_t *a, float *b) {
pa_assert(b);
for (; n > 0; n--) {
- int32_t s = (int16_t) ((int32_t) (UINT32_FROM(*a) << 8));
- *b = ((float) s) / 0x7FFFFFFF;
+ int32_t s = (int32_t) (UINT32_FROM(*a) << 8);
+ *b = (float) s / (float) 0x7FFFFFFF;
a ++;
b ++;
}
@@ -428,8 +428,8 @@ void pa_sconv_s24_32le_to_float32re(unsigned n, const uint32_t *a, float *b) {
pa_assert(b);
for (; n > 0; n--) {
- int32_t s = (int16_t) ((int32_t) (UINT32_FROM(*a) << 8));
- float k = ((float) s) / 0x7FFFFFFF;
+ int32_t s = (int32_t) (UINT32_FROM(*a) << 8);
+ float k = (float) s / (float) 0x7FFFFFFF;
*b = PA_FLOAT32_SWAP(k);
a ++;
b ++;
diff --git src/pulsecore/sconv.c src/pulsecore/sconv.c
index 29a9a45..d89f428 100644
--- src/pulsecore/sconv.c
+++ src/pulsecore/sconv.c
@@ -75,7 +75,7 @@ static void u8_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) {
pa_assert(b);
for (; n > 0; n--, a++, b++)
- *b = (uint8_t) (*a / 0x100 + 0x80);
+ *b = (uint8_t) ((uint16_t) *a >> 8) + (uint8_t) 0x80U;
}
/* float32 */
From 1ab53c43c17943d49fc80c86ef2b513354eddc63 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 14 May 2009 03:52:13 +0200
Subject: [PATCH 23/28] rescue: make we don't end up in an endless loop when we can't move a sink input
---
src/modules/module-rescue-streams.c | 38 +++++++++++++++++++---------------
1 files changed, 21 insertions(+), 17 deletions(-)
diff --git src/modules/module-rescue-streams.c src/modules/module-rescue-streams.c
index 7c99a9b..c22711a 100644
--- src/modules/module-rescue-streams.c
+++ src/modules/module-rescue-streams.c
@@ -31,6 +31,7 @@
#include <pulsecore/modargs.h>
#include <pulsecore/log.h>
#include <pulsecore/namereg.h>
+#include <pulsecore/core-util.h>
#include "module-rescue-streams-symdef.h"
@@ -49,6 +50,7 @@ struct userdata {
static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* userdata) {
pa_sink_input *i;
+ uint32_t idx;
pa_sink *target;
pa_assert(c);
@@ -58,15 +60,14 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
if (c->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- if (!pa_idxset_size(sink->inputs)) {
+ if (pa_idxset_size(sink->inputs) <= 0) {
pa_log_debug("No sink inputs to move away.");
return PA_HOOK_OK;
}
if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SINK)) || target == sink) {
- uint32_t idx;
- for (target = pa_idxset_first(c->sinks, &idx); target; target = pa_idxset_next(c->sinks, &idx))
+ PA_IDXSET_FOREACH(target, c->sinks, idx)
if (target != sink)
break;
@@ -76,20 +77,24 @@ static pa_hook_result_t sink_hook_callback(pa_core *c, pa_sink *sink, void* user
}
}
- while ((i = pa_idxset_first(sink->inputs, NULL))) {
+ pa_assert(target != sink);
+
+ PA_IDXSET_FOREACH(i, sink->inputs, idx) {
if (pa_sink_input_move_to(i, target, FALSE) < 0)
- pa_log_warn("Failed to move sink input %u \"%s\" to %s.", i->index, pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ pa_log_info("Failed to move sink input %u \"%s\" to %s.", i->index,
+ pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), target->name);
else
- pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index, pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ pa_log_info("Sucessfully moved sink input %u \"%s\" to %s.", i->index,
+ pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), target->name);
}
-
return PA_HOOK_OK;
}
static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void* userdata) {
pa_source_output *o;
pa_source *target;
+ uint32_t idx;
pa_assert(c);
pa_assert(source);
@@ -98,15 +103,14 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
if (c->state == PA_CORE_SHUTDOWN)
return PA_HOOK_OK;
- if (!pa_idxset_size(source->outputs)) {
+ if (pa_idxset_size(source->outputs) <= 0) {
pa_log_debug("No source outputs to move away.");
return PA_HOOK_OK;
}
if (!(target = pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE)) || target == source) {
- uint32_t idx;
- for (target = pa_idxset_first(c->sources, &idx); target; target = pa_idxset_next(c->sources, &idx))
+ PA_IDXSET_FOREACH(target, c->sources, idx)
if (target != source && !target->monitor_of == !source->monitor_of)
break;
@@ -118,19 +122,20 @@ static pa_hook_result_t source_hook_callback(pa_core *c, pa_source *source, void
pa_assert(target != source);
- while ((o = pa_idxset_first(source->outputs, NULL))) {
+ PA_IDXSET_FOREACH(o, source->outputs, idx) {
if (pa_source_output_move_to(o, target, FALSE) < 0)
- pa_log_warn("Failed to move source output %u \"%s\" to %s.", o->index, pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ pa_log_info("Failed to move source output %u \"%s\" to %s.", o->index,
+ pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), target->name);
else
- pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index, pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME), target->name);
+ pa_log_info("Sucessfully moved source output %u \"%s\" to %s.", o->index,
+ pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_APPLICATION_NAME)), target->name);
}
-
return PA_HOOK_OK;
}
int pa__init(pa_module*m) {
- pa_modargs *ma = NULL;
+ pa_modargs *ma;
struct userdata *u;
pa_assert(m);
@@ -153,10 +158,9 @@ void pa__done(pa_module*m) {
pa_assert(m);
- if (!m->userdata)
+ if (!(u = m->userdata))
return;
- u = m->userdata;
if (u->sink_slot)
pa_hook_slot_free(u->sink_slot);
if (u->source_slot)
From c41d9c71667de6d6e9aab077ac58b7371594bbef Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 8 May 2009 01:56:21 +0200
Subject: [PATCH 24/28] core: introduce pa_{sink,source}_set_fixed_latency()
This allows us to forward the fixed latency directly from the sink to
the monitor source withut having to wait for pa_sink_put().
---
src/modules/alsa/alsa-sink.c | 4 ++--
src/modules/alsa/alsa-source.c | 4 ++--
src/modules/bluetooth/module-bluetooth-device.c | 12 ++++++------
src/modules/module-pipe-sink.c | 2 +-
src/modules/module-pipe-source.c | 2 +-
src/modules/module-sine-source.c | 3 +--
src/modules/oss/module-oss.c | 4 ++--
src/pulsecore/sink.c | 16 ++++++++++++++++
src/pulsecore/sink.h | 1 +
src/pulsecore/source.c | 15 +++++++++++++++
src/pulsecore/source.h | 1 +
11 files changed, 48 insertions(+), 16 deletions(-)
diff --git src/modules/alsa/alsa-sink.c src/modules/alsa/alsa-sink.c
index a544b58..94e15df 100644
--- src/modules/alsa/alsa-sink.c
+++ src/modules/alsa/alsa-sink.c
@@ -473,7 +473,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
u->since_start += frames * u->frame_size;
#ifdef DEBUG_TIMING
- pa_log_debug("Wrote %lu bytes", (unsigned long) (frames * u->frame_size));
+ pa_log_debug("Wrote %lu bytes (of possible %lu bytes)", (unsigned long) (frames * u->frame_size), (unsigned long) n_bytes);
#endif
if ((size_t) frames * u->frame_size >= n_bytes)
@@ -1730,7 +1730,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
pa_log_info("Time scheduling watermark is %0.2fms",
(double) pa_bytes_to_usec(u->tsched_watermark, &ss) / PA_USEC_PER_MSEC);
} else
- u->sink->fixed_latency = pa_bytes_to_usec(u->hwbuf_size, &ss);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->hwbuf_size, &ss));
reserve_update(u);
diff --git src/modules/alsa/alsa-source.c src/modules/alsa/alsa-source.c
index 5d8e349..c2f905a 100644
--- src/modules/alsa/alsa-source.c
+++ src/modules/alsa/alsa-source.c
@@ -455,7 +455,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
u->read_count += frames * u->frame_size;
#ifdef DEBUG_TIMING
- pa_log_debug("Read %lu bytes", (unsigned long) (frames * u->frame_size));
+ pa_log_debug("Read %lu bytes (of possible %lu bytes)", (unsigned long) (frames * u->frame_size), (unsigned long) n_bytes);
#endif
if ((size_t) frames * u->frame_size >= n_bytes)
@@ -1582,7 +1582,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
pa_log_info("Time scheduling watermark is %0.2fms",
(double) pa_bytes_to_usec(u->tsched_watermark, &ss) / PA_USEC_PER_MSEC);
} else
- u->source->fixed_latency = pa_bytes_to_usec(u->hwbuf_size, &ss);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->hwbuf_size, &ss));
reserve_update(u);
diff --git src/modules/bluetooth/module-bluetooth-device.c src/modules/bluetooth/module-bluetooth-device.c
index 90f6486..3465b80 100644
--- src/modules/bluetooth/module-bluetooth-device.c
+++ src/modules/bluetooth/module-bluetooth-device.c
@@ -1608,9 +1608,9 @@ static int add_sink(struct userdata *u) {
u->sink->parent.process_msg = sink_process_msg;
pa_sink_set_max_request(u->sink, u->block_size);
- u->sink->fixed_latency =
- (u->profile == PROFILE_A2DP ? FIXED_LATENCY_PLAYBACK_A2DP : FIXED_LATENCY_PLAYBACK_HSP) +
- pa_bytes_to_usec(u->block_size, &u->sample_spec);
+ pa_sink_set_fixed_latency(u->sink,
+ (u->profile == PROFILE_A2DP ? FIXED_LATENCY_PLAYBACK_A2DP : FIXED_LATENCY_PLAYBACK_HSP) +
+ pa_bytes_to_usec(u->block_size, &u->sample_spec));
}
if (u->profile == PROFILE_HSP) {
@@ -1659,9 +1659,9 @@ static int add_source(struct userdata *u) {
u->source->userdata = u;
u->source->parent.process_msg = source_process_msg;
- u->source->fixed_latency =
- (/* u->profile == PROFILE_A2DP ? FIXED_LATENCY_RECORD_A2DP : */ FIXED_LATENCY_RECORD_HSP) +
- pa_bytes_to_usec(u->block_size, &u->sample_spec);
+ pa_source_set_fixed_latency(u->source,
+ (/* u->profile == PROFILE_A2DP ? FIXED_LATENCY_RECORD_A2DP : */ FIXED_LATENCY_RECORD_HSP) +
+ pa_bytes_to_usec(u->block_size, &u->sample_spec));
}
if (u->profile == PROFILE_HSP) {
diff --git src/modules/module-pipe-sink.c src/modules/module-pipe-sink.c
index 9d3e55d..304d01c 100644
--- src/modules/module-pipe-sink.c
+++ src/modules/module-pipe-sink.c
@@ -293,7 +293,7 @@ int pa__init(pa_module*m) {
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_max_request(u->sink, PIPE_BUF);
- u->sink->fixed_latency = pa_bytes_to_usec(PIPE_BUF, &u->sink->sample_spec);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(PIPE_BUF, &u->sink->sample_spec));
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
diff --git src/modules/module-pipe-source.c src/modules/module-pipe-source.c
index df72d79..6ed4fbf 100644
--- src/modules/module-pipe-source.c
+++ src/modules/module-pipe-source.c
@@ -277,7 +277,7 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
- u->source->fixed_latency = pa_bytes_to_usec(PIPE_BUF, &u->source->sample_spec);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(PIPE_BUF, &u->source->sample_spec));
u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
diff --git src/modules/module-sine-source.c src/modules/module-sine-source.c
index a5f1ce7..a6e15d8 100644
--- src/modules/module-sine-source.c
+++ src/modules/module-sine-source.c
@@ -264,8 +264,7 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
- u->source->fixed_latency = u->block_usec;
-
+ pa_source_set_fixed_latency(u->source, u->block_usec);
if (!(u->thread = pa_thread_new(thread_func, u))) {
pa_log("Failed to create thread.");
diff --git src/modules/oss/module-oss.c src/modules/oss/module-oss.c
index aa5f918..d6f549c 100644
--- src/modules/oss/module-oss.c
+++ src/modules/oss/module-oss.c
@@ -1328,8 +1328,8 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
pa_source_set_rtpoll(u->source, u->rtpoll);
+ pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->in_hwbuf_size, &u->source->sample_spec));
u->source->refresh_volume = TRUE;
- u->source->fixed_latency = pa_bytes_to_usec(u->in_hwbuf_size, &u->source->sample_spec);
if (use_mmap)
u->in_mmap_memblocks = pa_xnew0(pa_memblock*, u->in_nfrags);
@@ -1390,8 +1390,8 @@ int pa__init(pa_module*m) {
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll);
+ pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->out_hwbuf_size, &u->sink->sample_spec));
u->sink->refresh_volume = TRUE;
- u->sink->fixed_latency = pa_bytes_to_usec(u->out_hwbuf_size, &u->sink->sample_spec);
pa_sink_set_max_request(u->sink, u->out_hwbuf_size);
diff --git src/pulsecore/sink.c src/pulsecore/sink.c
index c99f9a8..2225886 100644
--- src/pulsecore/sink.c
+++ src/pulsecore/sink.c
@@ -2054,6 +2054,22 @@ void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency,
pa_source_set_latency_range_within_thread(s->monitor_source, min_latency, max_latency);
}
+/* Called from main thread, before the sink is put */
+void pa_sink_set_fixed_latency(pa_sink *s, pa_usec_t latency) {
+ pa_sink_assert_ref(s);
+
+ pa_assert(pa_sink_get_state(s) == PA_SINK_INIT);
+
+ if (latency < ABSOLUTE_MIN_LATENCY)
+ latency = ABSOLUTE_MIN_LATENCY;
+
+ if (latency > ABSOLUTE_MAX_LATENCY)
+ latency = ABSOLUTE_MAX_LATENCY;
+
+ s->fixed_latency = latency;
+ pa_source_set_fixed_latency(s->monitor_source, latency);
+}
+
/* Called from main context */
size_t pa_sink_get_max_rewind(pa_sink *s) {
size_t r;
diff --git src/pulsecore/sink.h src/pulsecore/sink.h
index 352282b..e33b3cf 100644
--- src/pulsecore/sink.h
+++ src/pulsecore/sink.h
@@ -229,6 +229,7 @@ void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p);
void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind);
void pa_sink_set_max_request(pa_sink *s, size_t max_request);
void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_sink_set_fixed_latency(pa_sink *s, pa_usec_t latency);
void pa_sink_detach(pa_sink *s);
void pa_sink_attach(pa_sink *s);
diff --git src/pulsecore/source.c src/pulsecore/source.c
index 0baaed1..e8deaf7 100644
--- src/pulsecore/source.c
+++ src/pulsecore/source.c
@@ -1280,6 +1280,21 @@ void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_laten
pa_source_invalidate_requested_latency(s);
}
+/* Called from main thread, before the source is put */
+void pa_source_set_fixed_latency(pa_source *s, pa_usec_t latency) {
+ pa_source_assert_ref(s);
+
+ pa_assert(pa_source_get_state(s) == PA_SOURCE_INIT);
+
+ if (latency < ABSOLUTE_MIN_LATENCY)
+ latency = ABSOLUTE_MIN_LATENCY;
+
+ if (latency > ABSOLUTE_MAX_LATENCY)
+ latency = ABSOLUTE_MAX_LATENCY;
+
+ s->fixed_latency = latency;
+}
+
/* Called from main thread */
size_t pa_source_get_max_rewind(pa_source *s) {
size_t r;
diff --git src/pulsecore/source.h src/pulsecore/source.h
index b502c22..2978f57 100644
--- src/pulsecore/source.h
+++ src/pulsecore/source.h
@@ -210,6 +210,7 @@ void pa_source_set_rtpoll(pa_source *s, pa_rtpoll *p);
void pa_source_set_max_rewind(pa_source *s, size_t max_rewind);
void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_source_set_fixed_latency(pa_source *s, pa_usec_t latency);
void pa_source_detach(pa_source *s);
void pa_source_attach(pa_source *s);
From c73733777f11080373264ed4e992c6860809898e Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 8 May 2009 02:02:36 +0200
Subject: [PATCH 25/28] core: cache requested latency only when we are running, not while we are still constructing
---
src/pulsecore/sink.c | 7 +++++--
src/pulsecore/source.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git src/pulsecore/sink.c src/pulsecore/sink.c
index 2225886..161b7c9 100644
--- src/pulsecore/sink.c
+++ src/pulsecore/sink.c
@@ -1867,8 +1867,11 @@ pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s) {
if (result != (pa_usec_t) -1)
result = PA_CLAMP(result, s->thread_info.min_latency, s->thread_info.max_latency);
- s->thread_info.requested_latency = result;
- s->thread_info.requested_latency_valid = TRUE;
+ if (PA_SINK_IS_LINKED(s->thread_info.state)) {
+ /* Only cache if properly initialized */
+ s->thread_info.requested_latency = result;
+ s->thread_info.requested_latency_valid = TRUE;
+ }
return result;
}
diff --git src/pulsecore/source.c src/pulsecore/source.c
index e8deaf7..8a4c8c4 100644
--- src/pulsecore/source.c
+++ src/pulsecore/source.c
@@ -1122,8 +1122,11 @@ pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s) {
if (result != (pa_usec_t) -1)
result = PA_CLAMP(result, s->thread_info.min_latency, s->thread_info.max_latency);
- s->thread_info.requested_latency = result;
- s->thread_info.requested_latency_valid = TRUE;
+ if (PA_SOURCE_IS_LINKED(s->thread_info.state)) {
+ /* Only cache this if we are fully set up */
+ s->thread_info.requested_latency = result;
+ s->thread_info.requested_latency_valid = TRUE;
+ }
return result;
}
From 85fb360fe3b9d3b3fb4e537373f4dc9202ca5e13 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Mon, 8 Jun 2009 18:22:19 +0200
Subject: [PATCH 26/28] sample: fix build on BE archs
---
src/pulsecore/sample-util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git src/pulsecore/sample-util.c src/pulsecore/sample-util.c
index dda3883..5b8ccf5 100644
--- src/pulsecore/sample-util.c
+++ src/pulsecore/sample-util.c
@@ -1182,7 +1182,7 @@ pa_memchunk* pa_silence_memchunk_get(pa_silence_cache *cache, pa_mempool *pool,
case PA_SAMPLE_S24LE:
case PA_SAMPLE_S24BE:
case PA_SAMPLE_S24_32LE:
- case PA_SAMPLE_S24_32RE:
+ case PA_SAMPLE_S24_32BE:
case PA_SAMPLE_FLOAT32LE:
case PA_SAMPLE_FLOAT32BE:
cache->blocks[PA_SAMPLE_S16LE] = b = silence_memblock_new(pool, 0);
Index: pulseaudio-0.9.14/src/daemon/daemon.conf.in
===================================================================
--- src/daemon/daemon.conf.in 2009-03-07 05:01:11.000000000 -0500
+++ src/daemon/daemon.conf.in 2009-03-07 05:01:54.000000000 -0500
@@ -46,7 +46,7 @@
; log-target = auto
; log-level = notice
-; resample-method = speex-float-3
+resample-method = speex-float-1
; disable-remixing = no
; disable-lfe-remixing = yes
@@ -72,5 +72,5 @@
; default-sample-rate = 44100
; default-sample-channels = 2
-; default-fragments = 4
-; default-fragment-size-msec = 25
+default-fragments = 8
+default-fragment-size-msec = 10
===================================================================
--- src/daemon/default.pa.in 2009-02-13 19:12:33.000000000 -0500
+++ src/daemon/default.pa.in 2009-02-13 19:13:03.000000000 -0500
@@ -58,7 +58,7 @@
### Automatically load driver modules depending on the hardware available
.ifexists module-hal-detect@PA_SOEXT@
-load-module module-hal-detect
+load-module module-hal-detect tsched=0
.else
### Alternatively use the static hardware detection module (for systems that
### lack HAL support)
|