summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-03-07 22:11:04 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2022-03-11 09:40:31 -0500
commit355553baf4c45f5c57655ba3c49e3809d9fc1906 (patch)
tree322e2acf3ee1970f76dc42a00e3fed386a4074e7
parentf6a2bf28e1c000ce4ca7eb45677e6d5a218f7dfb (diff)
downloadrockbox-355553baf4c45f5c57655ba3c49e3809d9fc1906.tar.gz
rockbox-355553baf4c45f5c57655ba3c49e3809d9fc1906.zip
playlist_resume, fix control fd, add some error info
I ocassionally see Playlist Invalid messages but which part is failing? eventually it works so its probably a race Change-Id: Ib2b09ab13ce09a55130430a2e94bc0498443b6ec
-rw-r--r--apps/playlist.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index a7b16d8b1b..83d7013c82 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -428,7 +428,7 @@ static int recreate_control(struct playlist_info* playlist)
428 char c = playlist->filename[playlist->dirlen-1]; 428 char c = playlist->filename[playlist->dirlen-1];
429 429
430 close(playlist->control_fd); 430 close(playlist->control_fd);
431 playlist->control_fd = 0; 431 playlist->control_fd = -1;
432 432
433 snprintf(temp_file, sizeof(temp_file), "%s%s", 433 snprintf(temp_file, sizeof(temp_file), "%s%s",
434 playlist->control_filename, file_suffix); 434 playlist->control_filename, file_suffix);
@@ -2205,7 +2205,7 @@ int playlist_resume(void)
2205 2205
2206 if (!str1) 2206 if (!str1)
2207 { 2207 {
2208 result = -1; 2208 result = -2;
2209 exit_loop = true; 2209 exit_loop = true;
2210 break; 2210 break;
2211 } 2211 }
@@ -2220,7 +2220,7 @@ int playlist_resume(void)
2220 2220
2221 if (version != PLAYLIST_CONTROL_FILE_VERSION) 2221 if (version != PLAYLIST_CONTROL_FILE_VERSION)
2222 { 2222 {
2223 result = -1; 2223 result = -3;
2224 goto out; 2224 goto out;
2225 } 2225 }
2226 2226
@@ -2254,7 +2254,7 @@ int playlist_resume(void)
2254 2254
2255 if (!str1 || !str2 || !str3) 2255 if (!str1 || !str2 || !str3)
2256 { 2256 {
2257 result = -1; 2257 result = -4;
2258 exit_loop = true; 2258 exit_loop = true;
2259 break; 2259 break;
2260 } 2260 }
@@ -2270,7 +2270,7 @@ int playlist_resume(void)
2270 if (add_track_to_playlist(playlist, str3, position, 2270 if (add_track_to_playlist(playlist, str3, position,
2271 queue, total_read+(str3-buffer)) < 0) 2271 queue, total_read+(str3-buffer)) < 0)
2272 { 2272 {
2273 result = -1; 2273 result = -5;
2274 goto out; 2274 goto out;
2275 } 2275 }
2276 2276
@@ -2285,7 +2285,7 @@ int playlist_resume(void)
2285 2285
2286 if (!str1) 2286 if (!str1)
2287 { 2287 {
2288 result = -1; 2288 result = -6;
2289 exit_loop = true; 2289 exit_loop = true;
2290 break; 2290 break;
2291 } 2291 }
@@ -2295,7 +2295,7 @@ int playlist_resume(void)
2295 if (remove_track_from_playlist(playlist, position, 2295 if (remove_track_from_playlist(playlist, position,
2296 false) < 0) 2296 false) < 0)
2297 { 2297 {
2298 result = -1; 2298 result = -7;
2299 goto out; 2299 goto out;
2300 } 2300 }
2301 2301
@@ -2308,7 +2308,7 @@ int playlist_resume(void)
2308 2308
2309 if (!str1 || !str2) 2309 if (!str1 || !str2)
2310 { 2310 {
2311 result = -1; 2311 result = -8;
2312 exit_loop = true; 2312 exit_loop = true;
2313 break; 2313 break;
2314 } 2314 }
@@ -2325,7 +2325,7 @@ int playlist_resume(void)
2325 if (randomise_playlist(playlist, seed, false, 2325 if (randomise_playlist(playlist, seed, false,
2326 false) < 0) 2326 false) < 0)
2327 { 2327 {
2328 result = -1; 2328 result = -9;
2329 goto out; 2329 goto out;
2330 } 2330 }
2331 sorted = false; 2331 sorted = false;
@@ -2336,7 +2336,7 @@ int playlist_resume(void)
2336 /* str1=first_index */ 2336 /* str1=first_index */
2337 if (!str1) 2337 if (!str1)
2338 { 2338 {
2339 result = -1; 2339 result = -10;
2340 exit_loop = true; 2340 exit_loop = true;
2341 break; 2341 break;
2342 } 2342 }
@@ -2345,7 +2345,7 @@ int playlist_resume(void)
2345 2345
2346 if (sort_playlist(playlist, false, false) < 0) 2346 if (sort_playlist(playlist, false, false) < 0)
2347 { 2347 {
2348 result = -1; 2348 result = -11;
2349 goto out; 2349 goto out;
2350 } 2350 }
2351 2351
@@ -2374,7 +2374,7 @@ int playlist_resume(void)
2374 /* first non-comment line must always specify playlist */ 2374 /* first non-comment line must always specify playlist */
2375 if (first && *p != 'P' && *p != '#') 2375 if (first && *p != 'P' && *p != '#')
2376 { 2376 {
2377 result = -1; 2377 result = -12;
2378 exit_loop = true; 2378 exit_loop = true;
2379 break; 2379 break;
2380 } 2380 }
@@ -2385,7 +2385,7 @@ int playlist_resume(void)
2385 /* playlist can only be specified once */ 2385 /* playlist can only be specified once */
2386 if (!first) 2386 if (!first)
2387 { 2387 {
2388 result = -1; 2388 result = -13;
2389 exit_loop = true; 2389 exit_loop = true;
2390 break; 2390 break;
2391 } 2391 }
@@ -2414,7 +2414,7 @@ int playlist_resume(void)
2414 current_command = PLAYLIST_COMMAND_COMMENT; 2414 current_command = PLAYLIST_COMMAND_COMMENT;
2415 break; 2415 break;
2416 default: 2416 default:
2417 result = -1; 2417 result = -14;
2418 exit_loop = true; 2418 exit_loop = true;
2419 break; 2419 break;
2420 } 2420 }
@@ -2459,7 +2459,7 @@ int playlist_resume(void)
2459 2459
2460 if (result < 0) 2460 if (result < 0)
2461 { 2461 {
2462 splash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_INVALID)); 2462 splashf(HZ*2, "Err: %d, %s", result, str(LANG_PLAYLIST_CONTROL_INVALID));
2463 goto out; 2463 goto out;
2464 } 2464 }
2465 2465
@@ -2474,8 +2474,8 @@ int playlist_resume(void)
2474 if ((total_read + count) >= control_file_size) 2474 if ((total_read + count) >= control_file_size)
2475 { 2475 {
2476 /* no newline at end of control file */ 2476 /* no newline at end of control file */
2477 splash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_INVALID)); 2477 splashf(HZ*2, "Err: EOF, %s", str(LANG_PLAYLIST_CONTROL_INVALID));
2478 result = -1; 2478 result = -15;
2479 goto out; 2479 goto out;
2480 } 2480 }
2481 2481