Debian Codegraph @

modules/lsp-runtime-lib/include/private/mm/MMIOReader.h

raw
1 /*
2 * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2025 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 24 апр. 2020 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef PRIVATE_MM_MMIOREADER_H_
23 #define PRIVATE_MM_MMIOREADER_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26
27 #ifdef PLATFORM_WINDOWS
28
29 #include <lsp-plug.in/common/types.h>
30 #include <lsp-plug.in/common/status.h>
31 #include <lsp-plug.in/runtime/LSPString.h>
32
33 #include <windows.h>
34 #include <mmsystem.h>
35 #include <mmreg.h>
36
37 namespace lsp
38 {
39 namespace mm
40 {
41 /**
42 * Audio file reader using MMIO subsystem
43 */
44 class MMIOReader
45 {
46 private:
47 MMIOReader & operator = (const MMIOReader &);
48
49 protected:
50 HMMIO hMMIO;
51 wsize_t nReadPos;
52 wssize_t nFrames;
53 bool bSeekable;
54 WAVEFORMATEX *pFormat;
55 MMCKINFO ckRiff;
56 MMCKINFO ckData;
57
58 public:
59 explicit MMIOReader();
60 ~MMIOReader();
61
62 public:
63 /**
64 * Check whether reader is seekable
65 * @return true if reader is seekable
66 */
67 inline bool seekable() const { return bSeekable; }
68
69 /**
70 * Get input format descriptor
71 * @return input format descriptor
72 */
73 inline WAVEFORMATEX *format() { return pFormat; }
74
75 /**
76 * Get actual number of frames
77 * @return number of frames or negative value if length is unknown
78 */
79 inline wssize_t frames() const { return nFrames; }
80
81 /**
82 * Open audio file for reading
83 * @param path path to the file
84 * @return status of operation
85 */
86 status_t open(const LSPString *path);
87
88 /**
89 * Seek to the specified location
90 * @param offset offset in bytes from the beginning of data chunk
91 * @return actual offset in bytes from the beginning of data chunk
92 */
93 wssize_t seek(wsize_t offset);
94
95 /**
96 * Read number of bytes into buffer
97 * @param buf pointer to buffer to store data
98 * @param count number of bytes to read
99 * @return actual bytes read or negative error code
100 */
101 ssize_t read(void *buf, size_t count);
102
103 /**
104 * Close the file
105 * @return status of operation
106 */
107 status_t close(status_t code = STATUS_OK);
108 };
109
110 } /* namespace mm */
111 } /* namespace lsp */
112
113 #endif /* PLATFORM_WINDOWS */
114
115 #endif /* PRIVATE_MM_MMIOREADER_H_ */