Root/liballegro/patches/070-use-integer-vorbisdec.patch

1Index: allegro-4.4.2/cmake/FindVorbis.cmake
2===================================================================
3--- allegro-4.4.2.orig/cmake/FindVorbis.cmake 2012-03-30 23:59:08.149052027 +0200
4+++ allegro-4.4.2/cmake/FindVorbis.cmake 2012-03-31 00:02:35.209665654 +0200
5@@ -11,10 +11,10 @@
6         set(VORBIS_FIND_QUIETLY TRUE)
7     endif(VORBIS_INCLUDE_DIR)
8     find_path(OGG_INCLUDE_DIR ogg/ogg.h)
9- find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
10+ find_path(VORBIS_INCLUDE_DIR tremor/ivorbisfile.h)
11     find_library(OGG_LIBRARY NAMES ogg)
12- find_library(VORBIS_LIBRARY NAMES vorbis)
13- find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
14+ find_library(VORBIS_LIBRARY NAMES vorbisidec)
15+ find_library(VORBISFILE_LIBRARY NAMES vorbisidec)
16     # Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
17     # to TRUE if all listed variables are TRUE.
18     include(FindPackageHandleStandardArgs)
19Index: allegro-4.4.2/addons/logg/logg.h
20===================================================================
21--- allegro-4.4.2.orig/addons/logg/logg.h 2012-03-31 00:03:37.965850709 +0200
22+++ allegro-4.4.2/addons/logg/logg.h 2012-03-31 00:05:19.486149188 +0200
23@@ -6,7 +6,7 @@
24 #endif
25 
26 #include <allegro.h>
27-#include <vorbis/vorbisfile.h>
28+#include <tremor/ivorbisfile.h>
29 
30 #define OGG_PAGES_TO_BUFFER 2
31 
32Index: allegro-4.4.2/addons/logg/logg.c
33===================================================================
34--- allegro-4.4.2.orig/addons/logg/logg.c 2012-03-30 23:59:16.901078061 +0200
35+++ allegro-4.4.2/addons/logg/logg.c 2012-03-31 00:52:21.628986644 +0200
36@@ -14,6 +14,20 @@
37 
38 static int logg_bufsize = 1024*64;
39 
40+/* convert samples from signed (tremor) to unsigned (allegro). from and to
41+ * are allowed to refer to the same memory. */
42+static void logg_from_signed(const char *from, char *to, int nbytes)
43+{
44+ const unsigned short *src = (const unsigned short*)from;
45+ unsigned short *dst = (unsigned short*)to;
46+ int i;
47+
48+ for (i = 0; i < nbytes; i += 2)
49+ {
50+ *dst++ = *src++ + 0x8000;
51+ }
52+}
53+
54 SAMPLE* logg_load(const char* filename)
55 {
56     OggVorbis_File ovf;
57@@ -32,7 +46,7 @@
58         return 0;
59     }
60 
61- if (ov_open_callbacks(file, &ovf, 0, 0, OV_CALLBACKS_DEFAULT) != 0) {
62+ if (ov_open(file, &ovf, 0, 0) != 0) {
63         strncpy(allegro_error, "ov_open_callbacks failed.", ALLEGRO_ERROR_SIZE);
64         fclose(file);
65         free(buf);
66@@ -57,9 +71,10 @@
67     samp->loop_end = samp->len;
68     samp->data = _al_malloc(sizeof(unsigned short) * samp->len * 2);
69 
70+ /* todo: need to convert to unsigned samples */
71     while ((numRead = ov_read(&ovf, buf, logg_bufsize,
72- ENDIANNESS, 2, 0, &bitstream)) != 0) {
73- memcpy((unsigned char*)samp->data+offset, buf, numRead);
74+ &bitstream)) != 0) {
75+ logg_from_signed(buf, (unsigned char*)samp->data+offset, numRead);
76         offset += numRead;
77     }
78 
79@@ -91,7 +106,7 @@
80         return 1;
81     }
82 
83- if (ov_open_callbacks(file, &s->ovf, 0, 0, OV_CALLBACKS_DEFAULT) != 0) {
84+ if (ov_open(file, &s->ovf, 0, 0) != 0) {
85         strncpy(allegro_error, "ov_open_callbacks failed.", ALLEGRO_ERROR_SIZE);
86         fclose(file);
87         return 1;
88@@ -119,9 +134,10 @@
89     memset(s->buf[page], 0, logg_bufsize);
90     
91     while (read < logg_bufsize) {
92+ /* todo: need to convert to unsigned samples */
93         int thisRead = ov_read(&s->ovf, s->buf[page]+read,
94- logg_bufsize-read,
95- ENDIANNESS, 2, 0, &bitstream);
96+ logg_bufsize-read, &bitstream);
97+ logg_from_signed(s->buf[page]+read,s->buf[page]+read,thisRead);
98         if (thisRead == 0) {
99             if (s->loop) {
100                 ov_clear(&s->ovf);
101

Archive Download this file



interactive