Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 109 lines (86 sloc) 3.899 kb
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
1 // -*- c++ -*-
4d4d90b @hzeller o More legalese
authored
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
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
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
21
22 #include <unistd.h>
23
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
24 #include <string>
25 #include <vector>
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
26 #include <set>
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
27
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
28 #include "file-handler-cache.h"
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
29 #include "file-handler.h"
7472d51 @hzeller o initial implementation of processor pool. Not wired up yet.
authored
30 #include "processor-pool.h"
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
31
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
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
36 class FolveFilesystem {
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
37 public:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
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
46 // Config directories contain the filter configurations.
df18f63 @hzeller o Make path-names to filters and base-directory absolute
authored
47 void add_config_dir(const std::string &config_dir) {
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
48 config_dirs_.push_back(config_dir);
49 }
50 const std::vector<std::string> &config_dirs() const { return config_dirs_; }
51
52 // Switch the current config to i. Values out of range are not accepted.
53 void SwitchCurrentConfigIndex(int i);
54 int current_cfg_index() const { return current_cfg_index_; }
55
56 // Check if properly initialized. Return 'false' if not and print a message
57 // to stderr.
58 bool CheckInitialized();
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
59
0aee3bb @hzeller o Show base dir that is mounted.
authored
60 // Create a new filter given the filesystem path and the underlying
61 // path.
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
62 // Returns NULL, if it cannot be created.
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
63 FileHandler *GetOrCreateHandler(const char *fs_path);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
64
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
65 // Inform filesystem that this file handler is not needed anymore
66 // (FS still might consider keeping it around for a while).
67 void Close(const char *fs_path, const FileHandler *handler);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
68
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
69 // Return dynamic size of file.
70 int StatByFilename(const char *fs_path, struct stat *st);
71
ac40d85 @hzeller o Make sure we match the alphabetically next file with
authored
72 // List files in given filesystem directory that match the suffix.
73 // Returns a set of filesystem paths of existing files.
74 // (We don't want globbing as filenames might contain weird characters).
75 bool ListDirectory(const std::string &fs_dir, const std::string &suffix,
76 std::set<std::string> *files);
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
77
b5c1e96 @hzeller o more useful output on status server.
authored
78 FileHandlerCache *handler_cache() { return &open_file_cache_; }
0aee3bb @hzeller o Show base dir that is mounted.
authored
79
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
80 void set_debug_ui_enabled(bool b) { debug_ui_enabled_ = b; }
81 bool is_debug_ui_enabled() const { return debug_ui_enabled_; }
82
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
83 void set_gapless_processing(bool b) { gapless_processing_ = b; }
84 bool gapless_processing() const { return gapless_processing_; }
85
0aee3bb @hzeller o Show base dir that is mounted.
authored
86 // Some stats.
b5c1e96 @hzeller o more useful output on status server.
authored
87 int total_file_openings() { return total_file_openings_; }
88 int total_file_reopen() { return total_file_reopen_; }
89
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
90 private:
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
91 // Get cache key, depending on the given configuration.
92 std::string CacheKey(int config_idx, const char *fs_path);
8268c37 @hzeller o Bubble up error messages in status server.
authored
93
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
94 FileHandler *CreateFromDescriptor(int filedes, int cfg_idx,
95 const char *fs_path,
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
96 const std::string &underlying_file);
8268c37 @hzeller o Bubble up error messages in status server.
authored
97
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
98 std::string underlying_dir_;
99 std::vector<std::string> config_dirs_;
100 int current_cfg_index_;
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
101 bool debug_ui_enabled_;
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
102 bool gapless_processing_;
b5c1e96 @hzeller o more useful output on status server.
authored
103 FileHandlerCache open_file_cache_;
104 int total_file_openings_;
105 int total_file_reopen_;
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
106 };
107
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
108 #endif // FOLVE_FILESYSTEM_H
Something went wrong with that request. Please try again.