Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'Rockbox:master' into master

authored by

Tsiry Sandratraina and committed by
GitHub
57f0267f 5d436c00

+121 -52
+14
apps/lang/chinese-simp.lang
··· 16459 16459 *: "禁用主菜单滚动" 16460 16460 </voice> 16461 16461 </phrase> 16462 + <phrase> 16463 + id: LANG_RANDOM_SHUFFLE_RANDOM_SELECTIVE_SONGS_SUMMARY 16464 + desc: a summary splash screen that appear on the database browser when you try to create a playlist from the database browser that exceeds your system limit 16465 + user: core 16466 + <source> 16467 + *: "Selection too big, %d random tracks will be picked from it" 16468 + </source> 16469 + <dest> 16470 + *: "选择了太多,将从中随机选取%d首" 16471 + </dest> 16472 + <voice> 16473 + *: "选择了太多,将从中选择更少曲目" 16474 + </voice> 16475 + </phrase>
+3 -3
apps/lang/english.lang
··· 2058 2058 desc: a summary splash screen that appear on the database browser when you try to create a playlist from the database browser that exceeds your system limit 2059 2059 user: core 2060 2060 <source> 2061 - *: "Selection too big, %d random tracks will be picked from it" 2061 + *: "Selection too big, %d random tracks will be selected" 2062 2062 </source> 2063 2063 <dest> 2064 - *: "Selection too big, %d random tracks will be picked from it" 2064 + *: "Selection too big, %d random tracks will be selected" 2065 2065 </dest> 2066 2066 <voice> 2067 - *: "Selection too big, fewer random tracks will be picked from it" 2067 + *: "Selection too big, fewer random tracks will be selected" 2068 2068 </voice> 2069 2069 </phrase> 2070 2070 <phrase>
+2 -1
apps/onplay.c
··· 1294 1294 #else 1295 1295 (void)hotkey; 1296 1296 #endif 1297 - if (customaction == ONPLAY_CUSTOMACTION_SHUFFLE_SONGS) { 1297 + if (customaction == ONPLAY_CUSTOMACTION_SHUFFLE_SONGS) 1298 + { 1298 1299 int returnCode = add_to_playlist(&addtopl_replace_shuffled); 1299 1300 if (returnCode == 1) 1300 1301 // User did not want to erase his current playlist, so let's show again the database main menu
+96 -45
apps/tagtree.c
··· 2131 2131 return tagtree_get_entry(c, c->selected_item)->customaction; 2132 2132 } 2133 2133 2134 - static void swap_array_bool(bool *a, bool *b) { 2134 + static void swap_array_bool(bool *a, bool *b) 2135 + { 2135 2136 bool temp = *a; 2136 2137 *a = *b; 2137 2138 *b = temp; 2138 2139 } 2139 - 2140 + 2140 2141 /** 2141 - * Randomly shuffle an array using the Fisher-Yates algorithm : https://en.wikipedia.org/wiki/Random_permutation 2142 - * This algorithm has a linear complexity. Don't forget to srand before call to use it with a relevant seed. 2142 + * Randomly shuffle an array using the Fisher-Yates algorithm : 2143 + * https://en.wikipedia.org/wiki/Random_permutation 2144 + * This algorithm has a linear complexity. Don't forget to srand 2145 + * before call to use it with a relevant seed. 2143 2146 */ 2144 - static void shuffle_bool_array(bool array[], int size) { 2145 - for (int i = size - 1; i > 0; i--) { 2147 + static void shuffle_bool_array(bool array[], int size) 2148 + { 2149 + for (int i = size - 1; i > 0; i--) 2150 + { 2146 2151 int j = rand() % (i + 1); 2147 2152 swap_array_bool(&array[i], &array[j]); 2148 2153 } 2149 2154 } 2150 2155 2151 - static bool fill_selective_random_playlist_indexes(int current_segment_n, int current_segment_max_available_space) { 2152 - if (current_segment_n == 0 || current_segment_max_available_space == 0) 2156 + static bool fill_random_playlist_indexes(int current_segment_n, 2157 + int current_segment_max_space) 2158 + { 2159 + if (current_segment_n == 0 || current_segment_max_space == 0) 2153 2160 return false; 2154 - if (current_segment_max_available_space > current_segment_n) 2155 - current_segment_max_available_space = current_segment_n; 2161 + if (current_segment_max_space > current_segment_n) 2162 + current_segment_max_space = current_segment_n; 2156 2163 for (int i = 0; i < current_segment_n; i++) 2157 - selective_random_playlist_indexes[i] = i < current_segment_max_available_space; 2164 + selective_random_playlist_indexes[i] = i < current_segment_max_space; 2158 2165 srand(current_tick); 2159 2166 shuffle_bool_array(selective_random_playlist_indexes, current_segment_n); 2160 2167 return true; ··· 2201 2208 return false; 2202 2209 } 2203 2210 } 2211 + 2204 2212 last_tick = current_tick + HZ/2; /* Show splash after 0.5 seconds have passed */ 2205 2213 splash_progress_set_delay(HZ / 2); /* wait 1/2 sec before progress */ 2206 2214 n = c->filesindir; 2215 + 2216 + int max_playlist_size = playlist_get_current()->max_playlist_size; 2217 + int playlist_amount = playlist_get_current()->amount; 2207 2218 int segment_size = INSERT_ALL_PLAYLIST_MAX_SEGMENT_SIZE; 2208 2219 int segments_count = n / segment_size; 2209 - int leftovers_segment_size = n % segment_size; 2220 + int leftovers_segment_size = n - (segments_count * segment_size); 2210 2221 bool fill_randomly = false; 2211 - if (playlist == NULL) { 2212 - bool will_exceed = n > playlist_get_current()->max_playlist_size; 2222 + 2223 + if (playlist == NULL) 2224 + { 2225 + bool will_exceed = n > max_playlist_size; 2213 2226 fill_randomly = will_exceed; 2214 2227 } 2215 - if (leftovers_segment_size > 0 && fill_randomly) { 2216 - // We need to re-balance the segments so the randomness will be coherent and balanced the same through all segments 2217 - while (leftovers_segment_size + segments_count < segment_size) { 2228 + if (leftovers_segment_size > 0 && fill_randomly) 2229 + { 2230 + /* We need to re-balance the segments so the randomness will be 2231 + * coherent and balanced the same through all segments */ 2232 + while (leftovers_segment_size + segments_count < segment_size) 2233 + { 2218 2234 segment_size--; // -1 to all other segments 2219 2235 leftovers_segment_size += segments_count; 2220 2236 } 2221 2237 } 2222 2238 if (leftovers_segment_size > 0) 2223 2239 segments_count += 1; 2224 - int max_available_space = playlist_get_current()->max_playlist_size - playlist_get_current()->amount; 2225 - int max_available_space_per_segment = max_available_space / segments_count; 2226 - if (fill_randomly) { 2240 + 2241 + int max_available_space = max_playlist_size - playlist_amount; 2242 + int max_space_per_segment = max_available_space / segments_count; 2243 + 2244 + int remaining_space = 2245 + max_available_space - (max_space_per_segment * segments_count); 2246 + 2247 + if (fill_randomly) 2248 + { 2227 2249 talk_id(LANG_RANDOM_SHUFFLE_RANDOM_SELECTIVE_SONGS_SUMMARY, true); 2228 - splashf(HZ * 3, str(LANG_RANDOM_SHUFFLE_RANDOM_SELECTIVE_SONGS_SUMMARY), max_available_space_per_segment * segments_count); 2229 - //splashf(HZ * 5, "sz=%d lsz=%d sc=%d rcps=%d", segment_size, leftovers_segment_size, segments_count, max_available_space_per_segment); 2250 + splashf(HZ * 3, str(LANG_RANDOM_SHUFFLE_RANDOM_SELECTIVE_SONGS_SUMMARY), 2251 + max_space_per_segment * segments_count + remaining_space); 2252 + /* logf("sz=%d lsz=%d sc=%d rcps=%d", segment_size, leftovers_segment_size, 2253 + segments_count, max_available_space_per_segment); */ 2230 2254 } 2231 - for (int i = 0; i < segments_count; i++) { 2232 - bool is_leftovers_segment = leftovers_segment_size > 0 && i + 1 >= segments_count; 2233 - if (fill_randomly) { 2234 - if (is_leftovers_segment) 2235 - fill_randomly = fill_selective_random_playlist_indexes(leftovers_segment_size, max_available_space_per_segment); 2236 - else 2237 - fill_randomly = fill_selective_random_playlist_indexes(segment_size, max_available_space_per_segment); 2238 - } 2239 - bool exit_loop_now = false; 2255 + 2256 + bool exit_loop_now = false; 2257 + for (int i = 0; i < segments_count; i++) 2258 + { 2259 + int cur_segment_size = segment_size; 2240 2260 int cur_segment_start = i * segment_size; 2241 2261 int cur_segment_end; 2242 - if (is_leftovers_segment) 2243 - cur_segment_end = cur_segment_start + leftovers_segment_size; 2244 - else 2245 - cur_segment_end = cur_segment_start + segment_size; 2246 - for (int j = cur_segment_start; j < cur_segment_end && !exit_loop_now; j++) { 2247 - if (fill_randomly && !selective_random_playlist_indexes[j % segment_size]) 2248 - continue; 2249 - splash_progress(j, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); 2250 - if (TIME_AFTER(current_tick, last_tick + HZ/4)) { 2251 - if (action_userabort(TIMEOUT_NOBLOCK)) { 2262 + int space_per_segment = max_space_per_segment; 2263 + 2264 + if (i + 1 >= segments_count && leftovers_segment_size > 0) 2265 + { 2266 + /* add any remaining tracks to the last segment */ 2267 + space_per_segment += remaining_space; 2268 + cur_segment_size = leftovers_segment_size; 2269 + } 2270 + else if (fill_randomly) 2271 + { 2272 + /* add an extra track to some of the segments */ 2273 + if (remaining_space > 0 && (i & 7) != 7) 2274 + { 2275 + space_per_segment++; 2276 + remaining_space--; 2277 + } 2278 + } 2279 + if (fill_randomly) 2280 + { 2281 + fill_randomly = fill_random_playlist_indexes(cur_segment_size, 2282 + space_per_segment); 2283 + } 2284 + 2285 + cur_segment_end = cur_segment_start + cur_segment_size; 2286 + 2287 + for (int j = cur_segment_start; j < cur_segment_end && !exit_loop_now; j++) 2288 + { 2289 + if (TIME_AFTER(current_tick, last_tick + HZ/4)) 2290 + { 2291 + splash_progress(j, n, "%s (%s)", str(LANG_WAIT), str(LANG_OFF_ABORT)); 2292 + if (action_userabort(TIMEOUT_NOBLOCK)) 2293 + { 2252 2294 exit_loop_now = true; 2253 2295 break; 2254 2296 } 2255 2297 last_tick = current_tick; 2256 2298 } 2299 + 2300 + if (fill_randomly && !selective_random_playlist_indexes[j % segment_size]) 2301 + continue; 2302 + 2257 2303 if (!tagcache_retrieve(&tcs, tagtree_get_entry(c, j)->extraseek, tcs.type, buf, sizeof buf)) 2258 2304 continue; 2259 - if (playlist == NULL) { 2305 + 2306 + if (playlist == NULL) 2307 + { 2260 2308 if (playlist_insert_track(NULL, buf, position, queue, false) < 0) { 2261 2309 logf("playlist_insert_track failed"); 2262 2310 exit_loop_now = true; 2263 2311 break; 2264 2312 } 2265 - } else if (fdprintf(fd, "%s\n", buf) <= 0) { 2313 + } 2314 + else if (fdprintf(fd, "%s\n", buf) <= 0) 2315 + { 2266 2316 exit_loop_now = true; 2267 2317 break; 2268 2318 } ··· 2445 2495 2446 2496 int n = c->filesindir; 2447 2497 bool has_playlist_been_randomized = n > playlist_get_current()->max_playlist_size; 2448 - if (has_playlist_been_randomized) { 2498 + if (has_playlist_been_randomized) 2499 + { 2449 2500 /* We need to recalculate the start index based on a percentage to put the user 2450 2501 around its desired start position and avoid out of bounds */ 2451 - 2502 + 2452 2503 int percentage_start_index = 100 * start_index / n; 2453 2504 start_index = percentage_start_index * playlist_get_current()->amount / 100; 2454 2505 }
+6 -3
apps/tree.c
··· 738 738 int customaction = ONPLAY_NO_CUSTOMACTION; 739 739 bool do_restore_display = true; 740 740 #ifdef HAVE_TAGCACHE 741 - if (id3db && (button == ACTION_STD_OK || button == ACTION_STD_CONTEXT)) { 741 + if (id3db && (button == ACTION_STD_OK || button == ACTION_STD_CONTEXT)) 742 + { 742 743 customaction = tagtree_get_custom_action(&tc); 743 - if (customaction == ONPLAY_CUSTOMACTION_SHUFFLE_SONGS) { 744 - button = ACTION_STD_CONTEXT; /** The code to insert shuffled is on the context branch of the switch so we always go here */ 744 + if (customaction == ONPLAY_CUSTOMACTION_SHUFFLE_SONGS) 745 + { 746 + /* The code to insert shuffled is on the context branch of the switch so we always go here */ 747 + button = ACTION_STD_CONTEXT; 745 748 do_restore_display = false; 746 749 } 747 750 }