diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-08-04 09:49:56 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2022-10-02 11:57:20 -0400 |
commit | d25d24812e8120c0eb133a412287ac030eb185c9 (patch) | |
tree | d1c336d5d81c39366672c86f30c484f96e24a469 /apps/plugins/mpegplayer/disk_buf.h | |
parent | 9ce5b2a2eda5c7101898476adaa3533e0ba5db82 (diff) | |
download | rockbox-d25d24812e8120c0eb133a412287ac030eb185c9.tar.gz rockbox-d25d24812e8120c0eb133a412287ac030eb185c9.zip |
RFC: Get rid of mpegplayer plugin
It might have made sense once upon a time, but in today's world...
Change-Id: I5d638e6f7a2308c50ab12bd901338f02cf426aae
Diffstat (limited to 'apps/plugins/mpegplayer/disk_buf.h')
-rw-r--r-- | apps/plugins/mpegplayer/disk_buf.h | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/apps/plugins/mpegplayer/disk_buf.h b/apps/plugins/mpegplayer/disk_buf.h deleted file mode 100644 index bc76ab6dc3..0000000000 --- a/apps/plugins/mpegplayer/disk_buf.h +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * AV disk buffer declarations | ||
11 | * | ||
12 | * Copyright (c) 2007 Michael Sevakis | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | #ifndef DISK_BUF_H | ||
24 | #define DISK_BUF_H | ||
25 | |||
26 | #ifndef OFF_T_MAX | ||
27 | #define OFF_T_MAX (~((off_t)1 << (sizeof (off_t)*8 - 1))) | ||
28 | #endif | ||
29 | |||
30 | #ifndef OFF_T_MIN | ||
31 | #define OFF_T_MIN ((off_t)1 << (sizeof (off_t)*8 - 1)) | ||
32 | #endif | ||
33 | |||
34 | #define DISK_BUF_PAGE_SHIFT 15 /* 32KB cache lines */ | ||
35 | #define DISK_BUF_PAGE_SIZE (1 << DISK_BUF_PAGE_SHIFT) | ||
36 | #define DISK_BUF_PAGE_MASK (DISK_BUF_PAGE_SIZE-1) | ||
37 | |||
38 | enum | ||
39 | { | ||
40 | DISK_BUF_NOTIFY_ERROR = -1, | ||
41 | DISK_BUF_NOTIFY_NULL = 0, | ||
42 | DISK_BUF_NOTIFY_OK, | ||
43 | DISK_BUF_NOTIFY_TIMEDOUT, | ||
44 | DISK_BUF_NOTIFY_PROCESS_EVENT, | ||
45 | DISK_BUF_NOTIFY_REGISTERED, | ||
46 | }; | ||
47 | |||
48 | /** Macros to map file offsets to cached data **/ | ||
49 | |||
50 | /* Returns a cache tag given a file offset */ | ||
51 | #define MAP_OFFSET_TO_TAG(o) \ | ||
52 | ((o) >> DISK_BUF_PAGE_SHIFT) | ||
53 | |||
54 | /* Returns the cache page number given a file offset */ | ||
55 | #define MAP_OFFSET_TO_PAGE(o) \ | ||
56 | (MAP_OFFSET_TO_TAG(o) % disk_buf.pgcount) | ||
57 | |||
58 | /* Returns the buffer offset given a file offset */ | ||
59 | #define MAP_OFFSET_TO_BUFFER(o) \ | ||
60 | (MAP_OFFSET_TO_PAGE(o) * DISK_BUF_PAGE_SIZE) | ||
61 | |||
62 | struct dbuf_range | ||
63 | { | ||
64 | uint32_t tag_start; | ||
65 | uint32_t tag_end; | ||
66 | int pg_start; | ||
67 | }; | ||
68 | |||
69 | #define DISK_BUF_L2_CACHE_SHIFT 6 | ||
70 | #define DISK_BUF_L2_CACHE_SIZE (1 << DISK_BUF_L2_CACHE_SHIFT) | ||
71 | #define DISK_BUF_L2_CACHE_MASK (DISK_BUF_L2_CACHE_SIZE-1) | ||
72 | |||
73 | struct dbuf_l2_cache | ||
74 | { | ||
75 | off_t addr; /* L2 file offset */ | ||
76 | size_t size; /* Real size */ | ||
77 | uint8_t data[DISK_BUF_L2_CACHE_SIZE*2]; /* Local data and guard */ | ||
78 | }; | ||
79 | |||
80 | void dbuf_l2_init(struct dbuf_l2_cache *l2_p); | ||
81 | |||
82 | /* This object is an extension of the stream manager and handles some | ||
83 | * playback events as well as buffering */ | ||
84 | struct disk_buf | ||
85 | { | ||
86 | unsigned int thread; | ||
87 | struct event_queue *q; | ||
88 | uint8_t *start; /* Start pointer */ | ||
89 | uint8_t *end; /* End of buffer pointer less MPEG_GUARDBUF_SIZE. The | ||
90 | guard space is used to wrap data at the buffer start to | ||
91 | pass continuous data packets */ | ||
92 | uint8_t *tail; /* Location of last data + 1 filled into the buffer */ | ||
93 | ssize_t size; /* The buffer length _not_ including the guard space (end-start) */ | ||
94 | int pgcount; /* Total number of available cached pages */ | ||
95 | uint32_t *cache; /* Pointer to cache structure - allocated on buffer */ | ||
96 | int in_file; /* File being read */ | ||
97 | ssize_t filesize; /* Size of file in_file in bytes */ | ||
98 | int file_pages; /* Number of pages in file (rounded up) */ | ||
99 | off_t offset; /* Current position (random access) */ | ||
100 | off_t win_left; /* Left edge of buffer window (streaming) */ | ||
101 | off_t win_right; /* Right edge of buffer window (streaming) */ | ||
102 | uint32_t time_last; /* Last time watermark was checked */ | ||
103 | off_t pos_last; /* Last position at watermark check time */ | ||
104 | ssize_t low_wm; /* The low watermark for automatic rebuffering */ | ||
105 | int status; /* Status as stream */ | ||
106 | int state; /* Current thread state */ | ||
107 | bool need_seek; /* Need to seek because a read was not contiguous */ | ||
108 | }; | ||
109 | |||
110 | extern struct disk_buf disk_buf SHAREDBSS_ATTR; | ||
111 | |||
112 | struct stream_hdr; | ||
113 | bool disk_buf_is_data_ready(struct stream_hdr *sh, ssize_t margin); | ||
114 | |||
115 | bool disk_buf_init(void); | ||
116 | void disk_buf_exit(void); | ||
117 | |||
118 | static inline int disk_buf_status(void) | ||
119 | { return disk_buf.status; } | ||
120 | |||
121 | int disk_buf_open(const char *filename); | ||
122 | void disk_buf_close(void); | ||
123 | ssize_t _disk_buf_getbuffer(size_t size, void **pp, void **pwrap, | ||
124 | size_t *sizewrap); | ||
125 | #define disk_buf_getbuffer(size, pp, pwrap, sizewrap) \ | ||
126 | _disk_buf_getbuffer((size), PUN_PTR(void **, (pp)), \ | ||
127 | PUN_PTR(void **, (pwrap)), (sizewrap)) | ||
128 | |||
129 | ssize_t _disk_buf_getbuffer_l2(struct dbuf_l2_cache *l2, | ||
130 | size_t size, void **pp); | ||
131 | #define disk_buf_getbuffer_l2(l2, size, pp) \ | ||
132 | _disk_buf_getbuffer_l2((l2), (size), PUN_PTR(void **, (pp))) | ||
133 | |||
134 | ssize_t disk_buf_read(void *buffer, size_t size); | ||
135 | ssize_t disk_buf_lseek(off_t offset, int whence); | ||
136 | |||
137 | static inline off_t disk_buf_ftell(void) | ||
138 | { return disk_buf.offset; } | ||
139 | |||
140 | static inline ssize_t disk_buf_filesize(void) | ||
141 | { return disk_buf.filesize; } | ||
142 | |||
143 | ssize_t disk_buf_prepare_streaming(off_t pos, size_t len); | ||
144 | ssize_t disk_buf_set_streaming_window(off_t left, off_t right); | ||
145 | void * disk_buf_offset2ptr(off_t offset); | ||
146 | int disk_buf_check_streaming_window(off_t left, off_t right); | ||
147 | |||
148 | intptr_t disk_buf_send_msg(long id, intptr_t data); | ||
149 | void disk_buf_post_msg(long id, intptr_t data); | ||
150 | void disk_buf_reply_msg(intptr_t retval); | ||
151 | |||
152 | #endif /* DISK_BUF_H */ | ||