OSDN Git Service

Fix loop embedding
authorStarg <starg@users.osdn.me>
Sat, 15 Feb 2020 17:37:10 +0000 (02:37 +0900)
committerStarg <starg@users.osdn.me>
Sat, 15 Feb 2020 17:37:10 +0000 (02:37 +0900)
timidity/output.h
timidity/vorbis_a.c

index 0e2947e..2aa54a3 100644 (file)
@@ -237,6 +237,14 @@ extern char *create_auto_output_name(const char *input_filename, const char *ext
 #define FILE_OUTPUT_MODE       O_WRONLY|O_CREAT|O_TRUNC, 0644
 #endif
 
+#if defined(__W32__)
+#define FILE_UPDATE_MODE       O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0644
+#elif defined(__MACOS__)
+#define FILE_UPDATE_MODE       O_RDWR|O_CREAT|O_TRUNC
+#else /* UNIX */
+#define FILE_UPDATE_MODE       O_RDWR|O_CREAT|O_TRUNC, 0644
+#endif
+
 extern void set_temporary_encoding(uint32 enc); // called open_output()
 extern void reset_temporary_encoding(void); // called close_output()
 
index ad1a69a..8a40800 100644 (file)
@@ -217,7 +217,7 @@ static int ogg_output_open(const char *fname, const char *comment)
       comment = "(stdout)";
   } else {
     /* Open the audio file */
-    fd = open(fname, FILE_OUTPUT_MODE);
+    fd = open(fname, FILE_UPDATE_MODE);
     if(fd < 0) {
       ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s",
                fname, strerror(errno));
@@ -554,7 +554,7 @@ static int insert_loop_tags(void)
 
        vcedit_state *state = vcedit_new_state();
        FILE *ftemp = tmpfile();
-       FILE *fin = fdopen(dup(dpm.fd), "wb");
+       FILE *fin = fdopen(dup(dpm.fd), "w+b");
 
        if (!ftemp) {
                ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "failed to insert loop info; tmpfile() failed");