shithub: choc

Download patch

ref: ba9a4fc5e2ac4cbdf8b5b7917bf61753fe2a25c2
parent: 4abf58cf86c28893a3ba30fae38a7825267aa061
parent: 73a90031dbfe5f71bad0f5bb6c4dbc2214437e69
author: Alex Mayfield <alexmax2742@gmail.com>
date: Wed Mar 8 17:51:15 EST 2017

Merge remote-tracking branch 'me/chocolate-midivolume' into chocolate-midivolume

# Conflicts:
#	src/i_midipipe.c

--- a/src/i_midipipe.c
+++ b/src/i_midipipe.c
@@ -147,6 +147,7 @@
 //
 static boolean ExpectPipe(net_packet_t *packet)
 {
+    int start;
     BOOL ok;
     CHAR pipe_buffer[8192];
     DWORD pipe_buffer_read = 0;
@@ -158,7 +159,7 @@
         return false;
     }
 
-    int start = I_GetTimeMS();
+    start = I_GetTimeMS();
 
     do
     {
@@ -210,7 +211,7 @@
 // Tells the MIDI subprocess to load a specific filename for playing.  This
 // function blocks until there is an acknowledgement from the server.
 //
-boolean I_MidiPipe_RegisterSong(const char *filename)
+boolean I_MidiPipe_RegisterSong(char *filename)
 {
     boolean ok;
     net_packet_t *packet;
@@ -360,10 +361,16 @@
 //
 boolean I_MidiPipe_InitServer()
 {
+    size_t filename_len;
     struct stat sbuf;
     char filename[MAX_PATH + 1];
+    char *fp = NULL;
     char *module = NULL;
     char *cmdline = NULL;
+    SECURITY_ATTRIBUTES sec_attrs;
+    PROCESS_INFORMATION proc_info;
+    STARTUPINFO startup_info;
+    BOOL ok;
 
     if (!UsingNativeMidi() || strlen(snd_musiccmd) > 0)
     {
@@ -373,11 +380,11 @@
     }
 
     memset(filename, 0, sizeof(filename));
-    size_t filename_len = GetModuleFileName(NULL, filename, MAX_PATH);
+    filename_len = GetModuleFileName(NULL, filename, MAX_PATH);
 
     // Remove filespec
     // TODO: Move this to m_misc?
-    char *fp = &filename[filename_len];
+    fp = &filename[filename_len];
     while (filename <= fp && *fp != DIR_SEPARATOR)
     {
         fp--;
@@ -394,7 +401,6 @@
     }
 
     // Set up pipes
-    SECURITY_ATTRIBUTES sec_attrs;
     memset(&sec_attrs, 0, sizeof(SECURITY_ATTRIBUTES));
     sec_attrs.nLength = sizeof(SECURITY_ATTRIBUTES);
     sec_attrs.bInheritHandle = TRUE;
@@ -425,10 +431,7 @@
     }
 
     // Launch the subprocess
-    PROCESS_INFORMATION proc_info;
     memset(&proc_info, 0, sizeof(proc_info));
-
-    STARTUPINFO startup_info;
     memset(&startup_info, 0, sizeof(startup_info));
     startup_info.cb = sizeof(startup_info);
     startup_info.hStdInput = midi_process_in_reader;
@@ -435,7 +438,7 @@
     startup_info.hStdOutput = midi_process_out_writer;
     startup_info.dwFlags = STARTF_USESTDHANDLES;
 
-    BOOL ok = CreateProcess(TEXT(module), TEXT(cmdline), NULL, NULL, TRUE,
+    ok = CreateProcess(TEXT(module), TEXT(cmdline), NULL, NULL, TRUE,
         0, NULL, NULL, &startup_info, &proc_info);
 
     if (!ok)
--- a/src/i_midipipe.h
+++ b/src/i_midipipe.h
@@ -28,7 +28,7 @@
 extern boolean midi_server_initialized;
 extern boolean midi_server_registered;
 
-boolean I_MidiPipe_RegisterSong(const char *filename);
+boolean I_MidiPipe_RegisterSong(char *filename);
 void I_MidiPipe_SetVolume(int vol);
 void I_MidiPipe_PlaySong(int loops);
 void I_MidiPipe_StopSong();