View | Details | Raw Unified | Return to bug 156467
Collapse All | Expand All

(-)ruby-audiofile/files/patch-audiofile.c (+96 lines)
Line 0 Link Here
1
--- audiofile.c.orig	2003-08-10 00:29:57.000000000 +0100
2
+++ audiofile.c	2011-04-18 06:58:15.000000000 +0100
3
@@ -161,7 +161,7 @@
4
 
5
             /* get mode into a C-string */
6
             mode = malloc(2);
7
-            mode[0] = *(RSTRING(v_mode)->ptr);
8
+            mode[0] = *(RSTRING_PTR(v_mode));
9
             mode[1] = '\0';
10
 
11
             switch(*mode) {
12
@@ -188,7 +188,7 @@
13
     switch(*mode) {
14
         case 'r':
15
 
16
-            fh = afOpenFile(RSTRING(v_fn)->ptr, mode, AF_NULL_FILESETUP);
17
+            fh = afOpenFile(RSTRING_PTR(v_fn), mode, AF_NULL_FILESETUP);
18
             if(fh != AF_NULL_FILEHANDLE) {
19
                 afp = ALLOC(struct af_data);
20
                 DATA_PTR(obj) = afp;
21
@@ -212,8 +212,8 @@
22
 
23
         case 'w':
24
             
25
-            fn = malloc(RSTRING(v_fn)->len+1);
26
-            strcpy(fn, RSTRING(v_fn)->ptr);
27
+            fn = malloc(RSTRING_LEN(v_fn)+1);
28
+            strcpy(fn, RSTRING_PTR(v_fn));
29
 
30
             afp = ALLOC(struct af_data);
31
             DATA_PTR(obj) = afp;
32
@@ -335,8 +335,8 @@
33
     
34
 
35
     Check_Type(readIntoString, T_STRING);
36
-    bytes = RSTRING(readIntoString)->len;
37
-    buf = RSTRING(readIntoString)->ptr;
38
+    bytes = RSTRING_LEN(readIntoString);
39
+    buf = RSTRING_PTR(readIntoString);
40
 
41
     frame_size = afGetFrameSize(afp->handle, AF_DEFAULT_TRACK, EXPAND_3TO4);
42
     frames = bytes / frame_size;
43
@@ -357,8 +357,8 @@
44
     GetAFP(obj, afp);
45
 
46
     Check_Type(writeFromString, T_STRING);
47
-    bytes = RSTRING(writeFromString)->len;
48
-    buf = RSTRING(writeFromString)->ptr;
49
+    bytes = RSTRING_LEN(writeFromString);
50
+    buf = RSTRING_PTR(writeFromString);
51
 
52
     frame_size = afGetFrameSize(afp->handle, AF_DEFAULT_TRACK, EXPAND_3TO4);
53
     frames = bytes / frame_size;
54
@@ -679,18 +679,18 @@
55
     struct af_data *afp;
56
 
57
     Check_Type(args, T_ARRAY);
58
-    if(RARRAY(args)->len != 1) {
59
+    if(RARRAY_LEN(args) != 1) {
60
         rb_raise(rb_eArgError, "incorrect argument(s) to AudioFile#pcm_mapping=");
61
     }
62
-    args = *(RARRAY(args)->ptr);
63
-    if(RARRAY(args)->len != 4) {
64
+    args = *(RARRAY_PTR(args));
65
+    if(RARRAY_LEN(args) != 4) {
66
         rb_raise(rb_eArgError, "incorrect argument(s) to AudioFile#pcm_mapping=");
67
     }
68
 
69
-    v_slope     = RARRAY(args)->ptr[0];
70
-    v_intercept = RARRAY(args)->ptr[1];
71
-    v_min_clip  = RARRAY(args)->ptr[2];
72
-    v_max_clip  = RARRAY(args)->ptr[3];
73
+    v_slope     = RARRAY_PTR(args)[0];
74
+    v_intercept = RARRAY_PTR(args)[1];
75
+    v_min_clip  = RARRAY_PTR(args)[2];
76
+    v_max_clip  = RARRAY_PTR(args)[3];
77
     Check_Type(v_slope, T_FLOAT);
78
     Check_Type(v_intercept, T_FLOAT);
79
     Check_Type(v_min_clip, T_FLOAT);
80
@@ -700,12 +700,12 @@
81
 
82
     if(af_is_open(afp)) {
83
         afSetTrackPCMMapping(afp->handle, AF_DEFAULT_TRACK, 
84
-                RFLOAT(v_slope)->value, RFLOAT(v_intercept)->value,
85
-                RFLOAT(v_min_clip)->value, RFLOAT(v_max_clip)->value);
86
+                RFLOAT_VALUE(v_slope), RFLOAT_VALUE(v_intercept),
87
+                RFLOAT_VALUE(v_min_clip), RFLOAT_VALUE(v_max_clip));
88
     } else {
89
         afInitPCMMapping(afp->setup, AF_DEFAULT_TRACK, 
90
-                RFLOAT(v_slope)->value, RFLOAT(v_intercept)->value,
91
-                RFLOAT(v_min_clip)->value, RFLOAT(v_max_clip)->value);
92
+                RFLOAT_VALUE(v_slope), RFLOAT_VALUE(v_intercept),
93
+                RFLOAT_VALUE(v_min_clip), RFLOAT_VALUE(v_max_clip));
94
     }
95
 
96
     return Qnil;

Return to bug 156467