Mercurial > audlegacy-plugins
annotate src/wma/libffwma/avio.h @ 3167:9739ba93fd79
alsa-ng: Don't try to join threads that have already exited.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 15 May 2009 00:05:17 -0500 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
878 | 1 #ifndef AVIO_H |
2 #define AVIO_H | |
3 | |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
878
diff
changeset
|
4 #include <audlegacy/vfs.h> |
878 | 5 |
6 /* output byte stream handling */ | |
7 | |
8 typedef int64_t offset_t; | |
9 | |
10 /* unbuffered I/O */ | |
11 | |
12 struct URLContext { | |
13 struct URLProtocol *prot; | |
14 int flags; | |
15 int is_streamed; /* true if streamed (no seek possible), default = false */ | |
16 int max_packet_size; /* if non zero, the stream is packetized with this max packet size */ | |
17 void *priv_data; | |
18 char filename[1]; /* specified filename */ | |
19 }; | |
20 | |
21 typedef struct URLContext URLContext; | |
22 | |
23 typedef struct URLPollEntry { | |
24 URLContext *handle; | |
25 int events; | |
26 int revents; | |
27 } URLPollEntry; | |
28 | |
29 #define URL_RDONLY 0 | |
30 #define URL_WRONLY 1 | |
31 #define URL_RDWR 2 | |
32 | |
33 typedef int URLInterruptCB(void); | |
34 | |
35 int url_vopen(URLContext **h, VFSFile *fd); | |
36 int url_open(URLContext **h, const char *filename, int flags); | |
37 int url_read(URLContext *h, unsigned char *buf, int size); | |
38 int url_write(URLContext *h, unsigned char *buf, int size); | |
39 offset_t url_seek(URLContext *h, offset_t pos, int whence); | |
40 int url_close(URLContext *h); | |
41 int url_exist(const char *filename); | |
42 offset_t url_filesize(URLContext *h); | |
43 int url_get_max_packet_size(URLContext *h); | |
44 void url_get_filename(URLContext *h, char *buf, int buf_size); | |
45 | |
46 /* the callback is called in blocking functions to test regulary if | |
47 asynchronous interruption is needed. -EINTR is returned in this | |
48 case by the interrupted function. 'NULL' means no interrupt | |
49 callback is given. */ | |
50 void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); | |
51 | |
52 /* not implemented */ | |
53 int url_poll(URLPollEntry *poll_table, int n, int timeout); | |
54 | |
55 typedef struct URLProtocol { | |
56 const char *name; | |
57 int (*url_open)(URLContext *h, const char *filename, int flags); | |
58 int (*url_read)(URLContext *h, unsigned char *buf, int size); | |
59 int (*url_write)(URLContext *h, unsigned char *buf, int size); | |
60 offset_t (*url_seek)(URLContext *h, offset_t pos, int whence); | |
61 int (*url_close)(URLContext *h); | |
62 struct URLProtocol *next; | |
63 } URLProtocol; | |
64 | |
65 extern URLProtocol *first_protocol; | |
66 extern URLInterruptCB *url_interrupt_cb; | |
67 | |
68 int register_protocol(URLProtocol *protocol); | |
69 | |
70 typedef struct { | |
71 unsigned char *buffer; | |
72 int buffer_size; | |
73 unsigned char *buf_ptr, *buf_end; | |
74 void *opaque; | |
75 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); | |
76 void (*write_packet)(void *opaque, uint8_t *buf, int buf_size); | |
77 int (*seek)(void *opaque, offset_t offset, int whence); | |
78 offset_t pos; /* position in the file of the current buffer */ | |
79 int must_flush; /* true if the next seek should flush */ | |
80 int eof_reached; /* true if eof reached */ | |
81 int write_flag; /* true if open for writing */ | |
82 int is_streamed; | |
83 int max_packet_size; | |
84 } ByteIOContext; | |
85 | |
86 int init_put_byte(ByteIOContext *s, | |
87 unsigned char *buffer, | |
88 int buffer_size, | |
89 int write_flag, | |
90 void *opaque, | |
91 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), | |
92 void (*write_packet)(void *opaque, uint8_t *buf, int buf_size), | |
93 int (*seek)(void *opaque, offset_t offset, int whence)); | |
94 | |
95 void put_byte(ByteIOContext *s, int b); | |
96 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size); | |
97 void put_le64(ByteIOContext *s, uint64_t val); | |
98 void put_be64(ByteIOContext *s, uint64_t val); | |
99 void put_le32(ByteIOContext *s, unsigned int val); | |
100 void put_be32(ByteIOContext *s, unsigned int val); | |
101 void put_le16(ByteIOContext *s, unsigned int val); | |
102 void put_be16(ByteIOContext *s, unsigned int val); | |
103 void put_tag(ByteIOContext *s, const char *tag); | |
104 | |
105 void put_be64_double(ByteIOContext *s, double val); | |
106 void put_strz(ByteIOContext *s, const char *buf); | |
107 | |
108 offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence); | |
109 void url_fskip(ByteIOContext *s, offset_t offset); | |
110 offset_t url_ftell(ByteIOContext *s); | |
111 int url_feof(ByteIOContext *s); | |
112 | |
113 #define URL_EOF (-1) | |
114 int url_fgetc(ByteIOContext *s); | |
115 #ifdef __GNUC__ | |
116 int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); | |
117 #else | |
118 int url_fprintf(ByteIOContext *s, const char *fmt, ...); | |
119 #endif | |
120 char *url_fgets(ByteIOContext *s, char *buf, int buf_size); | |
121 | |
122 void put_flush_packet(ByteIOContext *s); | |
123 | |
124 int get_buffer(ByteIOContext *s, unsigned char *buf, int size); | |
125 int get_byte(ByteIOContext *s); | |
126 unsigned int get_le32(ByteIOContext *s); | |
127 uint64_t get_le64(ByteIOContext *s); | |
128 unsigned int get_le16(ByteIOContext *s); | |
129 | |
130 double get_be64_double(ByteIOContext *s); | |
131 char *get_strz(ByteIOContext *s, char *buf, int maxlen); | |
132 unsigned int get_be16(ByteIOContext *s); | |
133 unsigned int get_be32(ByteIOContext *s); | |
134 uint64_t get_be64(ByteIOContext *s); | |
135 | |
136 static inline int url_is_streamed(ByteIOContext *s) | |
137 { | |
138 return s->is_streamed; | |
139 } | |
140 | |
141 int url_vfdopen(ByteIOContext *s, VFSFile *f); | |
142 int url_fdopen(ByteIOContext *s, URLContext *h); | |
143 int url_setbufsize(ByteIOContext *s, int buf_size); | |
144 int url_fopen(ByteIOContext *s, const char *filename, int flags); | |
145 int url_fclose(ByteIOContext *s); | |
146 URLContext *url_fileno(ByteIOContext *s); | |
147 int url_fget_max_packet_size(ByteIOContext *s); | |
148 | |
149 int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags); | |
150 int url_close_buf(ByteIOContext *s); | |
151 | |
152 int url_open_dyn_buf(ByteIOContext *s); | |
153 int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size); | |
154 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer); | |
155 | |
156 /* file.c */ | |
157 extern URLProtocol file_protocol; | |
158 extern URLProtocol pipe_protocol; | |
159 | |
160 /* udp.c */ | |
161 extern URLProtocol udp_protocol; | |
162 int udp_set_remote_url(URLContext *h, const char *uri); | |
163 int udp_get_local_port(URLContext *h); | |
164 int udp_get_file_handle(URLContext *h); | |
165 | |
166 /* tcp.c */ | |
167 extern URLProtocol tcp_protocol; | |
168 | |
169 /* http.c */ | |
170 extern URLProtocol http_protocol; | |
171 | |
172 extern URLProtocol mms_protocol; | |
173 | |
174 #endif | |
175 |