diff options
Diffstat (limited to 'apps/buffering.c')
-rw-r--r-- | apps/buffering.c | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 811c1e5d65..651ec4c2ff 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -133,8 +133,6 @@ static volatile size_t buf_ridx; /* current reading position */ | |||
133 | 133 | ||
134 | /* Configuration */ | 134 | /* Configuration */ |
135 | static size_t conf_watermark = 0; /* Level to trigger filebuf fill */ | 135 | static size_t conf_watermark = 0; /* Level to trigger filebuf fill */ |
136 | static size_t conf_filechunk = 0; /* Bytes-per-read for buffering (impacts | ||
137 | responsiveness of buffering thread) */ | ||
138 | #if MEM > 8 | 136 | #if MEM > 8 |
139 | static size_t high_watermark = 0; /* High watermark for rebuffer */ | 137 | static size_t high_watermark = 0; /* High watermark for rebuffer */ |
140 | #endif | 138 | #endif |
@@ -167,7 +165,8 @@ static struct { | |||
167 | 165 | ||
168 | /* Messages available to communicate with the buffering thread */ | 166 | /* Messages available to communicate with the buffering thread */ |
169 | enum { | 167 | enum { |
170 | Q_BUFFER_HANDLE = 1, /* Request buffering of a handle */ | 168 | Q_BUFFER_HANDLE = 1, /* Request buffering of a handle, this should not be |
169 | used in a low buffer situation. */ | ||
171 | Q_RESET_HANDLE, /* (internal) Request resetting of a handle to its | 170 | Q_RESET_HANDLE, /* (internal) Request resetting of a handle to its |
172 | offset (the offset has to be set beforehand) */ | 171 | offset (the offset has to be set beforehand) */ |
173 | Q_CLOSE_HANDLE, /* Request closing a handle */ | 172 | Q_CLOSE_HANDLE, /* Request closing a handle */ |
@@ -552,7 +551,7 @@ static bool buffer_handle(int handle_id) | |||
552 | while (h->filerem > 0) | 551 | while (h->filerem > 0) |
553 | { | 552 | { |
554 | /* max amount to copy */ | 553 | /* max amount to copy */ |
555 | size_t copy_n = MIN( MIN(h->filerem, conf_filechunk), | 554 | size_t copy_n = MIN( MIN(h->filerem, BUFFERING_DEFAULT_FILECHUNK), |
556 | buffer_len - h->widx); | 555 | buffer_len - h->widx); |
557 | 556 | ||
558 | /* stop copying if it would overwrite the reading position */ | 557 | /* stop copying if it would overwrite the reading position */ |
@@ -1101,23 +1100,10 @@ size_t buf_used(void) | |||
1101 | return BUF_USED; | 1100 | return BUF_USED; |
1102 | } | 1101 | } |
1103 | 1102 | ||
1104 | void buf_set_conf(int setting, size_t value) | 1103 | void buf_set_watermark(size_t bytes) |
1105 | { | 1104 | { |
1106 | int msg; | 1105 | LOGFQUEUE("buffering > Q_SET_WATERMARK %ld", bytes); |
1107 | switch (setting) | 1106 | queue_post(&buffering_queue, Q_SET_WATERMARK, bytes); |
1108 | { | ||
1109 | case BUFFERING_SET_WATERMARK: | ||
1110 | msg = Q_SET_WATERMARK; | ||
1111 | break; | ||
1112 | |||
1113 | case BUFFERING_SET_CHUNKSIZE: | ||
1114 | msg = Q_SET_CHUNKSIZE; | ||
1115 | break; | ||
1116 | |||
1117 | default: | ||
1118 | return; | ||
1119 | } | ||
1120 | queue_post(&buffering_queue, msg, value); | ||
1121 | } | 1107 | } |
1122 | 1108 | ||
1123 | bool register_buffer_low_callback(buffer_low_callback func) | 1109 | bool register_buffer_low_callback(buffer_low_callback func) |
@@ -1228,22 +1214,11 @@ void buffering_thread(void) | |||
1228 | case Q_SET_WATERMARK: | 1214 | case Q_SET_WATERMARK: |
1229 | LOGFQUEUE("buffering < Q_SET_WATERMARK"); | 1215 | LOGFQUEUE("buffering < Q_SET_WATERMARK"); |
1230 | conf_watermark = (size_t)ev.data; | 1216 | conf_watermark = (size_t)ev.data; |
1231 | if (conf_watermark < conf_filechunk) | 1217 | if (conf_watermark < BUFFERING_DEFAULT_FILECHUNK) |
1232 | { | ||
1233 | logf("wmark<chunk %ld<%ld", conf_watermark, conf_filechunk); | ||
1234 | conf_watermark = conf_filechunk; | ||
1235 | } | ||
1236 | break; | ||
1237 | |||
1238 | case Q_SET_CHUNKSIZE: | ||
1239 | LOGFQUEUE("buffering < Q_SET_CHUNKSIZE"); | ||
1240 | conf_filechunk = (size_t)ev.data; | ||
1241 | if (conf_filechunk == 0) | ||
1242 | conf_filechunk = BUFFERING_DEFAULT_FILECHUNK; | ||
1243 | if (conf_filechunk > conf_watermark) | ||
1244 | { | 1218 | { |
1245 | logf("chunk>wmark %ld>%ld", conf_filechunk, conf_watermark); | 1219 | logf("wmark<chunk %ld<%d", |
1246 | conf_watermark = conf_filechunk; | 1220 | conf_watermark, BUFFERING_DEFAULT_FILECHUNK); |
1221 | conf_watermark = BUFFERING_DEFAULT_FILECHUNK; | ||
1247 | } | 1222 | } |
1248 | break; | 1223 | break; |
1249 | 1224 | ||
@@ -1308,7 +1283,6 @@ void buffering_thread(void) | |||
1308 | void buffering_init(void) { | 1283 | void buffering_init(void) { |
1309 | mutex_init(&llist_mutex); | 1284 | mutex_init(&llist_mutex); |
1310 | 1285 | ||
1311 | conf_filechunk = BUFFERING_DEFAULT_FILECHUNK; | ||
1312 | conf_watermark = BUFFERING_DEFAULT_WATERMARK; | 1286 | conf_watermark = BUFFERING_DEFAULT_WATERMARK; |
1313 | 1287 | ||
1314 | queue_init(&buffering_queue, true); | 1288 | queue_init(&buffering_queue, true); |