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
|
Author: Kamal Mostafa <kamal@whence.com>
Bug-Debian: https://bugs.debian.org/784285
Description: fix pa_simple_write error with mono output
Bug-Debian: https://bugs.debian.org/784285
Bug-Ubuntu: https://launchpad.net/bugs/1461755
* Open a mono (not stereo) PulseAudio output stream and hence avoid
improperly passing non-multiples of the frame size to pa_simple_write
(Closes: #784285, LP: #1461755).
--- a/morse.d/beepPA.c
+++ b/morse.d/beepPA.c
@@ -32,7 +32,7 @@
static pthread_cond_t beep_cv = PTHREAD_COND_INITIALIZER;
static const pa_sample_spec sample_format = {
- .format = PA_SAMPLE_S16LE, .rate = 44100, .channels = 2};
+ .format = PA_SAMPLE_S16LE, .rate = 44100, .channels = 1};
static pa_simple *snddev;
@@ -43,7 +43,7 @@
} beep_info = {0, 0, 0};
static void play_tone() {
- int len = (int)(sample_format.rate * beep_info.time / 1000.0 * 2);
+ int len = (int)(sample_format.rate * beep_info.time / 1000.0);
int16_t *sample;
sample = malloc(len * sizeof(sample[0]));
@@ -57,8 +57,7 @@
int c;
tt = beep_info.time / 1000.0;
for (c = 0; c < len; c += 2) {
- double t = c / ((double)sample_format.rate *
- 2.0); /* Time in s from start */
+ double t = c / ((double)sample_format.rate); /* Time in s from start */
double v = (beep_info.volume / 100.0) *
sin(M_PI * 2 * t * beep_info.pitch);
if (t < 0.01) {
|