changeset 218:a6f6309ab0a0 trunk

[svn] - fix for stream save if filename duplicates exist
author yaz
date Sun, 05 Nov 2006 00:34:45 -0800
parents 3f2e3c5c30ed
children 469078516127
files ChangeLog src/mpg123/http.c
diffstat 2 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 04 23:03:45 2006 -0800
+++ b/ChangeLog	Sun Nov 05 00:34:45 2006 -0800
@@ -1,3 +1,11 @@
+2006-11-05 07:03:45 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [434]
+  - make esd plugin assume that write() isn't always successful due to threading contingency. closes #427. patch by <sjleung -at shaw.ca>.
+  
+  trunk/src/esd/audio.c |   17 +++++++++++++----
+  1 file changed, 13 insertions(+), 4 deletions(-)
+
+
 2006-11-04 21:14:27 +0000  Aaron Sheldon <asheldon@uiuc.edu>
   revision [432]
   Works again on x86
--- a/src/mpg123/http.c	Sat Nov 04 23:03:45 2006 -0800
+++ b/src/mpg123/http.c	Sun Nov 05 00:34:45 2006 -0800
@@ -625,26 +625,27 @@
     } while (redirect);
 
     if (mpgdec_cfg.save_http_stream) {
-        gchar *output_name;
+        gchar *output_name_seed, *output_name;
         gint i = 1;
 
         file = mpgdec_http_get_title(url);
-        output_name = file;
-        if (!strncasecmp(output_name, "http://", 7))
-            output_name += 7;
-        temp = strrchr(output_name, '.');
+        output_name_seed = file;
+        if (!strncasecmp(output_name_seed, "http://", 7))
+            output_name_seed += 7;
+        temp = strrchr(output_name_seed, '.');
         if (temp && !strcasecmp(temp, ".mp3"))
             *temp = '\0';
 
-        while ((temp = strchr(output_name, '/')))
+        while ((temp = strchr(output_name_seed, '/')))
             *temp = '_';
+
         output_name = g_strdup_printf("%s/%s.mp3",
-                                      mpgdec_cfg.save_http_path, output_name);
+                                      mpgdec_cfg.save_http_path, output_name_seed);
         while (!access(output_name, F_OK) && i < 100000) {
             g_free(output_name);
             output_name = g_strdup_printf("%s/%s-%d.mp3",
                                           mpgdec_cfg.save_http_path,
-                                          output_name, i++);
+                                          output_name_seed, i++);
         }
 
         g_free(file);