Debian Codegraph @

debian/patches/libsonic-bigendian

raw
1 commit c794ef2c9a868e3d901b637f35ef90bd16566ff1
2 Author: Samuel Thibault <[email protected]>
3 Date: Mon Dec 16 01:27:03 2024 +0100
4
5 libsonic: Fix support on big-endian archs
6
7 libsonic reads/writes in host order while espeak-ng works with
8 little-endian order.
9
10 diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c
11 index eb00106f..07e44f57 100644
12 --- a/src/libespeak-ng/wavegen.c
13 +++ b/src/libespeak-ng/wavegen.c
14 @@ -1372,6 +1372,16 @@ static int WavegenFill2(void)
15 sonicFlushStream(sonicSpeedupStream);
16 int length = (out_end - out_ptr);
17 length = sonicReadShortFromStream(sonicSpeedupStream, (short*)out_ptr, length/2);
18 +#ifdef ARCH_BIG
19 + {
20 + unsigned i;
21 + for (i = 0; i < length/2; i++) {
22 + unsigned short v = ((unsigned short *) out_ptr)[i];
23 + out_ptr[i*2] = v & 0xff;
24 + out_ptr[i*2+1] = v >> 8;
25 + }
26 + }
27 +#endif
28 out_ptr += length * 2;
29 }
30 break;
31 @@ -1392,12 +1402,22 @@ static int WavegenFill2(void)
32 // Speed up the audio samples with libsonic.
33 static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
34 {
35 +#ifdef ARCH_BIG
36 + unsigned i;
37 +#endif
38 +
39 if (length_in > 0) {
40 if (sonicSpeedupStream == NULL)
41 sonicSpeedupStream = sonicCreateStream(22050, 1);
42 if (sonicGetSpeed(sonicSpeedupStream) != sonicSpeed)
43 sonicSetSpeed(sonicSpeedupStream, sonicSpeed);
44
45 +#ifdef ARCH_BIG
46 + for (i = 0; i < length_in; i++) {
47 + unsigned short v = ((unsigned char*) outbuf)[i*2] | (((unsigned char *)outbuf)[i*2+1] << 8);
48 + ((unsigned short *) outbuf)[i] = v;
49 + }
50 +#endif
51 sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in);
52 }
53
54 @@ -1406,7 +1426,16 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
55
56 if (end_of_text)
57 sonicFlushStream(sonicSpeedupStream);
58 - return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
59 +
60 + int ret = sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
61 +#ifdef ARCH_BIG
62 + for (i = 0; i < length_out; i++) {
63 + unsigned short v = ((unsigned short *) outbuf)[i];
64 + ((unsigned char *)outbuf)[i*2] = v & 0xff;
65 + ((unsigned char *)outbuf)[i*2+1] = v >> 8;
66 + }
67 +#endif
68 + return ret;
69 }
70 #endif
71