Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

o Ran with Amarok over my files. Looks like it sometimes only 'almost'

  skips to the end of the file (within last 1kB or so). With a bit
  of fudge-factor, this now works with the current skip detection.
o Little HTML tweaks.
  • Loading branch information...
commit bcb77e7f78b39ea7c81f54067c8949f52f1ada42 1 parent 223f392
Henner Zeller authored

Showing 3 changed files with 39 additions and 23 deletions. Show diff stats Hide diff stats

  1. +16 6 convolver.cc
  2. +2 2 fuse-convolve.cc
  3. +21 15 status-server.cc
22 convolver.cc
@@ -127,14 +127,24 @@ class SndFileHandler :
127 127 if (error_) return -1;
128 128 // If this is a skip suspiciously at the very end of the file as
129 129 // reported by stat, we don't do any encoding, just return garbage.
130   - // Programs sometimes do this apparently.
  130 + // Programs sometimes do this apparently. And sometimes not even to the
  131 + // very end but 'almost' at the end. So add some FudeOverhang
  132 + static const int kFudgeOverhang = 512;
131 133 // But of course only if this is really a detected skip.
132 134 if (output_buffer_->FileSize() < offset
133   - && (int) (offset + size) >= file_stat_.st_size) {
134   - const int pretended_available_bytes = file_stat_.st_size - offset;
135   - if (pretended_available_bytes > 0) {
136   - memset(buf, 0x00, pretended_available_bytes);
137   - return pretended_available_bytes;
  135 + && (int) (offset + size + kFudgeOverhang) < file_stat_.st_size) {
  136 + LOGF(stderr,
  137 + "Skip attempt: file=%ld, offset=%ld, size=%ld; file_size=%ld; diff=%ld\n",
  138 + output_buffer_->FileSize(), offset, size, file_stat_.st_size,
  139 + file_stat_.st_size - offset);
  140 + }
  141 + if (output_buffer_->FileSize() < offset
  142 + && (int) (offset + size + kFudgeOverhang) >= file_stat_.st_size) {
  143 + const int pretended_bytes = std::min((off_t)size,
  144 + file_stat_.st_size - offset);
  145 + if (pretended_bytes > 0) {
  146 + memset(buf, 0x00, pretended_bytes);
  147 + return pretended_bytes;
138 148 } else {
139 149 return 0;
140 150 }
4 fuse-convolve.cc
@@ -22,7 +22,7 @@
22 22 // Use latest version.
23 23 #define FUSE_USE_VERSION 26
24 24
25   -#define FUSE_CONVOLVE_VERSION_INFO "v. 0.76 &mdash; 2012-09-14"
  25 +#define FUSE_CONVOLVE_VERSION_INFO "v. 0.77 &mdash; 2012-09-14"
26 26
27 27 #include <fuse.h>
28 28 #include <stdio.h>
@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) {
181 181 argc -=2;
182 182 argv += 2;
183 183 convolver_fs = new ConvolverFilesystem(FUSE_CONVOLVE_VERSION_INFO,
184   - config_dir, 5);
  184 + config_dir, 3);
185 185
186 186 // TODO(hzeller): make this configurable
187 187 StatusServer *statusz = new StatusServer(convolver_fs);
36 status-server.cc
@@ -48,14 +48,15 @@ int StatusServer::HandleHttp(void* user_argument,
48 48 server->CreatePage(&buffer, &size);
49 49 response = MHD_create_response_from_data(size, (void*) buffer,
50 50 MHD_NO, MHD_NO);
51   - MHD_add_response_header(response, "Content-Type", "text/html");
  51 + MHD_add_response_header(response, "Content-Type", "text/html; charset=utf-8");
52 52 ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
53 53 MHD_destroy_response(response);
54 54 return ret;
55 55 }
56 56
57 57 StatusServer::StatusServer(ConvolverFilesystem *fs)
58   - : filesystem_(fs), daemon_(NULL) {
  58 + : total_seconds_filtered_(0), total_seconds_music_seen_(0),
  59 + filesystem_(fs), daemon_(NULL) {
59 60 fs->handler_cache()->SetObserver(this);
60 61 }
61 62
@@ -86,7 +87,8 @@ void StatusServer::RetireHandlerEvent(FileHandler *handler) {
86 87 retired_.pop_back();
87 88 }
88 89
89   -static const char sMessageRowHtml[] = "<td>%s</td><td>%s</td>"
  90 +static const char sMessageRowHtml[] =
  91 + "<td>%s</td><td>%s</td>"
90 92 "<td colspan='3'>-</td>";
91 93
92 94 static const char sProgressRowHtml[] =
@@ -97,13 +99,13 @@ static const char sProgressRowHtml[] =
97 99
98 100 static void AppendFileInfo(std::string *result, const char *progress_style,
99 101 const HandlerStats &stats) {
100   - result->append("<tr>");
  102 + result->append("<tr style='text-wrap:none;white-space:nowrap;'>");
101 103 char row[1024];
102 104 const char *status = "";
103 105 switch (stats.status) {
104 106 case HandlerStats::OPEN: status = "open"; break;
105 107 case HandlerStats::IDLE: status = "idle"; break;
106   - case HandlerStats::RETIRED: status = "----"; break;
  108 + case HandlerStats::RETIRED: status = "&nbsp;----&nbsp;"; break;
107 109 // no default to let the compiler detect new values.
108 110 }
109 111 if (stats.progress <= 0) {
@@ -121,7 +123,8 @@ static void AppendFileInfo(std::string *result, const char *progress_style,
121 123 result->append(row);
122 124 result->append("<td bgcolor='#c0c0c0'>&nbsp;")
123 125 .append(stats.format).append("&nbsp;</td>")
124   - .append("<td style='font-size:small;'>").append(stats.filename)
  126 + .append("<td style='font-size:small;text-wrap:none;white-space:nowrap'>")
  127 + .append(stats.filename)
125 128 .append("</td>");
126 129 result->append("</tr>\n");
127 130 }
@@ -137,7 +140,7 @@ struct CompareStats {
137 140 void StatusServer::CreatePage(const char **buffer, size_t *size) {
138 141 const double start = fuse_convolve::CurrentTime();
139 142 current_page_.clear();
140   - current_page_.append("<body style='font-family:Helvetica;'>");
  143 + current_page_.append("<body style='font-family:Helvetica;'>\n");
141 144 current_page_.append("<center>Welcome to fuse convolve ")
142 145 .append(filesystem_->version()).append("</center>");
143 146
@@ -160,12 +163,14 @@ void StatusServer::CreatePage(const char **buffer, size_t *size) {
160 163 snprintf(total_stats, sizeof(total_stats),
161 164 "Total opening files <b>%d</b> | "
162 165 ".. and re-opened from recency cache <b>%d</b><br/>"
163   - "Total music seen <b>%d:%02d:%02d</b> | "
164   - ".. and convolved <b>%d:%02d:%02d</b><br/>",
  166 + "Total music seen <b>%dd %d:%02d:%02d</b> | "
  167 + ".. and convolved <b>%dd %d:%02d:%02d</b><br/>",
165 168 filesystem_->total_file_openings(),
166 169 filesystem_->total_file_reopen(),
167   - t_seen / 3600, (t_seen % 3600) / 60, t_seen % 60,
168   - t_filtered / 3600, (t_filtered % 3600) / 60, t_filtered % 60);
  170 + t_seen / 86400, (t_seen % 86400) / 3600,
  171 + (t_seen % 3600) / 60, t_seen % 60,
  172 + t_filtered / 86400, (t_filtered % 86400) / 3600,
  173 + (t_filtered % 3600) / 60, t_filtered % 60);
169 174 current_page_.append(total_stats);
170 175
171 176 current_page_.append("<h3>Recent Files</h3>\n");
@@ -177,8 +182,8 @@ void StatusServer::CreatePage(const char **buffer, size_t *size) {
177 182 current_page_.append("<table>\n");
178 183 current_page_.append("<tr><th>Stat</th>"
179 184 "<th width='400px'>Progress</th>"
180   - "<th>Pos</th><td></td><th>Tot</th><th>Format</th>"
181   - "<th>File</th></tr>\n");
  185 + "<th>Pos</th><td></td><th>Len</th><th>Format</th>"
  186 + "<th align='left'>File</th></tr>\n");
182 187 CompareStats comparator;
183 188 std::sort(stat_list.begin(), stat_list.end(), comparator);
184 189 for (size_t i = 0; i < stat_list.size(); ++i) {
@@ -187,8 +192,8 @@ void StatusServer::CreatePage(const char **buffer, size_t *size) {
187 192 current_page_.append("</table><hr/>\n");
188 193
189 194 if (retired_.size() > 0) {
190   - current_page_.append("<table>\n");
191 195 current_page_.append("<h3>Retired</h3>\n");
  196 + current_page_.append("<table>\n");
192 197 for (RetiredList::const_iterator it = retired_.begin();
193 198 it != retired_.end(); ++it) {
194 199 AppendFileInfo(&current_page_, kRetiredProgress, *it);
@@ -200,7 +205,8 @@ void StatusServer::CreatePage(const char **buffer, size_t *size) {
200 205 char time_buffer[128];
201 206 snprintf(time_buffer, sizeof(time_buffer), "page-gen %.2fms",
202 207 duration * 1000.0);
203   - current_page_.append(time_buffer).append("<div align='right'>HZ</div></body>");
  208 + current_page_.append(time_buffer).append("<div align='right'>HZ</div>\n"
  209 + "</body>");
204 210 *buffer = current_page_.data();
205 211 *size = current_page_.size();
206 212 }

0 comments on commit bcb77e7

Please sign in to comment.
Something went wrong with that request. Please try again.