Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/file.c @ 867:86e8224baa0e trunk
[svn] fixed multiple spawns of flac aboutbox
author | giacomo |
---|---|
date | Fri, 24 Mar 2006 08:00:06 -0800 |
parents | d539e5c5f730 |
children | 3d4af4890339 |
rev | line source |
---|---|
137 | 1 /* |
2 * Buffered file io for ffmpeg system | |
3 * Copyright (c) 2001 Fabrice Bellard | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 #include "avformat.h" | |
255
ad1e65c6a854
[svn] Create some proper headers and include them. No more implicit declarations.
chainsaw
parents:
218
diff
changeset
|
20 #include "cutils.h" |
137 | 21 #include <fcntl.h> |
22 #include <unistd.h> | |
23 #include <sys/ioctl.h> | |
24 #include <sys/time.h> | |
25 | |
26 /* standard file protocol */ | |
27 | |
28 static int file_open(URLContext *h, const char *filename, int flags) | |
29 { | |
30 int access; | |
31 int fd; | |
32 | |
33 strstart(filename, "file:", &filename); | |
34 | |
35 if (flags & URL_WRONLY) { | |
36 access = O_CREAT | O_TRUNC | O_WRONLY; | |
37 } else { | |
38 access = O_RDONLY; | |
39 } | |
218
0bea7509d6ba
[svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents:
210
diff
changeset
|
40 |
137 | 41 fd = open(filename, access, 0666); |
42 if (fd < 0) | |
43 return -ENOENT; | |
258 | 44 h->priv_data = (void *)(long)fd; |
137 | 45 return 0; |
46 } | |
47 | |
48 static int file_read(URLContext *h, unsigned char *buf, int size) | |
49 { | |
258 | 50 int fd = (int)(long)h->priv_data; |
137 | 51 return read(fd, buf, size); |
52 } | |
53 | |
54 static int file_write(URLContext *h, unsigned char *buf, int size) | |
55 { | |
258 | 56 int fd = (int)(long)h->priv_data; |
137 | 57 return write(fd, buf, size); |
58 } | |
59 | |
60 /* XXX: use llseek */ | |
61 static offset_t file_seek(URLContext *h, offset_t pos, int whence) | |
62 { | |
258 | 63 int fd = (int)(long)h->priv_data; |
137 | 64 return lseek(fd, pos, whence); |
65 } | |
66 | |
67 static int file_close(URLContext *h) | |
68 { | |
258 | 69 int fd = (int)(long)h->priv_data; |
137 | 70 return close(fd); |
71 } | |
72 | |
73 URLProtocol file_protocol = { | |
74 "file", | |
75 file_open, | |
76 file_read, | |
77 file_write, | |
78 file_seek, | |
79 file_close, | |
701
d539e5c5f730
[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents:
258
diff
changeset
|
80 NULL |
137 | 81 }; |
82 | |
83 /* pipe protocol */ | |
84 | |
85 static int pipe_open(URLContext *h, const char *filename, int flags) | |
86 { | |
87 int fd; | |
88 | |
89 if (flags & URL_WRONLY) { | |
90 fd = 1; | |
91 } else { | |
92 fd = 0; | |
93 } | |
258 | 94 h->priv_data = (void *)(long)fd; |
137 | 95 return 0; |
96 } | |
97 | |
98 static int pipe_read(URLContext *h, unsigned char *buf, int size) | |
99 { | |
258 | 100 int fd = (int)(long)h->priv_data; |
137 | 101 return read(fd, buf, size); |
102 } | |
103 | |
104 static int pipe_write(URLContext *h, unsigned char *buf, int size) | |
105 { | |
258 | 106 int fd = (int)(long)h->priv_data; |
137 | 107 return write(fd, buf, size); |
108 } | |
109 | |
110 static int pipe_close(URLContext *h) | |
111 { | |
112 return 0; | |
113 } | |
114 | |
115 URLProtocol pipe_protocol = { | |
116 "pipe", | |
117 pipe_open, | |
118 pipe_read, | |
119 pipe_write, | |
120 NULL, | |
121 pipe_close, | |
701
d539e5c5f730
[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents:
258
diff
changeset
|
122 NULL |
137 | 123 }; |