Skip to content
Newer
Older
100644 134 lines (106 sloc) 4.81 KB
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 13, 2012
1 // -*- c++ -*-
4d4d90b @hzeller o More legalese
authored Sep 23, 2012
2 // Folve - A fuse filesystem that convolves audio files on-the-fly.
3 //
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
4 // Copyright (C) 2012 Henner Zeller <h.zeller@acm.org>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored Sep 15, 2012
19 #ifndef FOLVE_FILESYSTEM_H
20 #define FOLVE_FILESYSTEM_H
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
21
22 #include <unistd.h>
23
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 17, 2012
24 #include <string>
25 #include <vector>
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
26 #include <set>
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
27
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
28 #include "file-handler-cache.h"
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored Sep 16, 2012
29 #include "file-handler.h"
7472d51 @hzeller o initial implementation of processor pool. Not wired up yet.
authored Oct 5, 2012
30 #include "processor-pool.h"
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
31
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
32 #ifndef FOLVE_VERSION
33 #define FOLVE_VERSION "[unknown version - compile from git]"
34 #endif
35
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored Sep 16, 2012
36 class FolveFilesystem {
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
37 public:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
38 // Create a new filesystem. At least SetBasedir() needs to be called
39 // for this to be properly initialized.
40 FolveFilesystem();
41
42 // Underlying directory - the directory we read files from.
43 void set_underlying_dir(const std::string &dir) { underlying_dir_ = dir; }
44 const std::string &underlying_dir() const { return underlying_dir_; }
45
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
46 // Set the base configuration directory.
47 void SetBaseConfigDir(const std::string &config_dir) {
48 base_config_dir_ = config_dir;
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
49 }
e296ede @hzeller o Errmsg: print short name of filter.
authored Oct 6, 2012
50 const std::string &base_config_dir() const { return base_config_dir_; }
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
51
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
52 // Return a set of available named configurations. Essentially the names
53 // of subdirectories in the configuration dir.
54 const std::set<std::string> GetAvailableConfigDirs() const;
55
56 // Switch the current config to subdir. Returns 'true', if this was a valid
57 // choice and we actually did a switch to a new directory.
58 bool SwitchCurrentConfigDir(const std::string &subdir);
59 const std::string &current_config_subdir() const {
60 return current_config_subdir_;
61 }
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
62
63 // Check if properly initialized. Return 'false' if not and print a message
64 // to stderr.
65 bool CheckInitialized();
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
66
a90d922 @hzeller o Separate sanitizing of config subdirectories.
authored Oct 4, 2012
67 // After startup: choose the initial configuation.
68 void SetupInitialConfig();
69
0aee3bb @hzeller o Show base dir that is mounted.
authored Sep 15, 2012
70 // Create a new filter given the filesystem path and the underlying
71 // path.
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
72 // Returns NULL, if it cannot be created.
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
73 FileHandler *GetOrCreateHandler(const char *fs_path);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
74
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
75 // Inform filesystem that this file handler is not needed anymore
76 // (FS still might consider keeping it around for a while).
77 void Close(const char *fs_path, const FileHandler *handler);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
78
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
79 // Return dynamic size of file.
80 int StatByFilename(const char *fs_path, struct stat *st);
81
ac40d85 @hzeller o Make sure we match the alphabetically next file with
authored Sep 21, 2012
82 // List files in given filesystem directory that match the suffix.
83 // Returns a set of filesystem paths of existing files.
84 // (We don't want globbing as filenames might contain weird characters).
85 bool ListDirectory(const std::string &fs_dir, const std::string &suffix,
86 std::set<std::string> *files);
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
87
b5c1e96 @hzeller o more useful output on status server.
authored Sep 14, 2012
88 FileHandlerCache *handler_cache() { return &open_file_cache_; }
950f192 @hzeller o Wire up processor-pool to folve-filesystem.
authored Oct 5, 2012
89 ProcessorPool *processor_pool() { return &processor_pool_; }
0aee3bb @hzeller o Show base dir that is mounted.
authored Sep 15, 2012
90
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
91 void set_gapless_processing(bool b) { gapless_processing_ = b; }
92 bool gapless_processing() const { return gapless_processing_; }
93
fea3d55 @hzeller o Initial implementation of pre-buffering thread.
authored Oct 6, 2012
94 // Should we attempt to pre-buffer files ?
95 void set_pre_buffer_size(int b) { pre_buffer_size_ = b; }
96 int pre_buffer_size() const { return pre_buffer_size_; }
97
0aee3bb @hzeller o Show base dir that is mounted.
authored Sep 15, 2012
98 // Some stats.
b5c1e96 @hzeller o more useful output on status server.
authored Sep 14, 2012
99 int total_file_openings() { return total_file_openings_; }
100 int total_file_reopen() { return total_file_reopen_; }
101
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
102 private:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
103 // Get cache key, depending on the given configuration.
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
104 std::string CacheKey(const std::string &config_path, const char *fs_path);
8268c37 @hzeller o Bubble up error messages in status server.
authored Sep 15, 2012
105
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
106 FileHandler *CreateFromDescriptor(int filedes, const std::string &cfg_dir,
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
107 const char *fs_path,
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
108 const std::string &underlying_file);
8268c37 @hzeller o Bubble up error messages in status server.
authored Sep 16, 2012
109
a90d922 @hzeller o Separate sanitizing of config subdirectories.
authored Oct 4, 2012
110 // Sanitize path to configuration subdirectory. Checks if someone tries
111 // to break out of the given base directory.
112 // Return if this is a sane directory.
113 // Passes the sanitized directory in the parameter.
114 bool SanitizeConfigSubdir(std::string *subdir_path) const;
115
116 // List available config directories; if "warn_invalid" is true,
117 // non-directories or symbolic links breaking out of the directory are
118 // reported.
119 const std::set<std::string> ListConfigDirs(bool warn_invalid) const;
120
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored Sep 18, 2012
121 std::string underlying_dir_;
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
122 std::string base_config_dir_;
950f192 @hzeller o Wire up processor-pool to folve-filesystem.
authored Oct 6, 2012
123
31096bb @hzeller o remove option -c and add -C: give a base directory for all filters.
authored Oct 4, 2012
124 std::string current_config_subdir_;
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored Sep 21, 2012
125 bool gapless_processing_;
fea3d55 @hzeller o Initial implementation of pre-buffering thread.
authored Oct 7, 2012
126 int pre_buffer_size_;
b5c1e96 @hzeller o more useful output on status server.
authored Sep 14, 2012
127 FileHandlerCache open_file_cache_;
950f192 @hzeller o Wire up processor-pool to folve-filesystem.
authored Oct 6, 2012
128 ProcessorPool processor_pool_;
b5c1e96 @hzeller o more useful output on status server.
authored Sep 14, 2012
129 int total_file_openings_;
130 int total_file_reopen_;
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored Sep 14, 2012
131 };
132
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored Sep 16, 2012
133 #endif // FOLVE_FILESYSTEM_H
Something went wrong with that request. Please try again.