summaryrefslogtreecommitdiff
path: root/audio/xwave/patches/patch-aj
blob: 9a80c96e0c9fb413ab977bf60fc36f3899087d35 (plain)
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
$NetBSD: patch-aj,v 1.3 2001/11/18 15:03:39 itohy Exp $

--- src/riff.c.orig	Thu Aug 13 08:27:10 1998
+++ src/riff.c	Sun Nov 18 22:19:23 2001
@@ -33,7 +33,7 @@
 
 #ifdef linux
 #include <endian.h>
-#elif defined (FreeBSD)
+#elif defined (FreeBSD) || defined(__NetBSD__)
 #include <machine/endian.h>
 #elif defined (sgi)
 #include <sys/endian.h>
@@ -45,12 +45,12 @@
 
 #include "types.h"
 #include "audio_file.h"
+#include "endian.h"
 #include "riff.h"
 #include "xwave.h"
 #include "ccitt/g711.h"
 #include "ccitt/g72x.h"
 #include "adpcm2pcm/adpcm.h"
-#include "endian.h"
  
 
 extern Main_Data *MD;
@@ -79,9 +79,10 @@
 {
    RiffHeader rh;
    FmtHeader fh;
-   long chunk;
+   int32_t chunk;
    int headoffs,i;
-   ulong length,slength;
+   u_int32_t length;
+   off_t slength;
 
    if (mode==AF_NEW) return(riff_new(af));
    
@@ -112,7 +113,7 @@
       if ((i=read (af->fd,&chunk,sizeof(chunk)))!=sizeof(chunk)) 
 	return(AF_ERROR);
       headoffs+=i;
-      if ((i=read (af->fd,&length,sizeof(ulong)))!=sizeof(ulong)) 
+      if ((i=read (af->fd,&length,sizeof(length)))!=sizeof(length)) 
 	return(AF_ERROR);
       headoffs+=i;
       
@@ -172,8 +173,9 @@
 {
    RiffHeader rh;
    FmtHeader fh;
-   long chunk;
-   ulong length,count;
+   int32_t chunk;
+   u_int32_t length;
+   int count;
 
    length=af->length;
 
@@ -344,19 +346,26 @@
 {
    switch (af.comp) {
     case AF_PCM:
+      break;
       return(lseek(af.fd,pos,mode));
     case AF_ALAW:
     case AF_MULAW:
+      pos /= 2;
+      break;
       return(lseek(af.fd,pos/2,mode));
     case AF_ADPCM:
+      pos /= 4;
+      break;
       return(lseek(af.fd,pos/4,mode));
+    default:
+      return(AF_ERROR);
    }
-   return(AF_ERROR);
+   return(lseek(af.fd, mode == SEEK_SET ? pos + af.headoffs : pos, mode));
 }
    
 int riff_close(Audio_File af)
 {
-   if (riff_seek(af,0,SEEK_SET)==AF_ERROR) return(AF_ERROR);
+   if (lseek(af.fd,0,SEEK_SET)) return(AF_ERROR);
      
    if (riff_new (&af)==AF_ERROR) return(AF_ERROR);
    return(close(af.fd));