shithub: choc

Download patch

ref: e8e2d602e6b4ff9d41bbb9e43023043bffc64e90
parent: f09202ec5a79a7f8fb9464bcd92833645f23d03e
author: Alex Mayfield <alexmax2742@gmail.com>
date: Mon Mar 13 19:40:21 EDT 2017

Move midipipe messages out of net

Rename them while we're at it.

--- a/midiproc/Makefile.am
+++ b/midiproc/Makefile.am
@@ -6,6 +6,6 @@
 noinst_PROGRAMS = @PROGRAM_PREFIX@midiproc
 
 @PROGRAM_PREFIX@midiproc_LDADD = @SDLMIXER_LIBS@
-@PROGRAM_PREFIX@midiproc_SOURCES = buffer.c buffer.h main.c
+@PROGRAM_PREFIX@midiproc_SOURCES = buffer.c buffer.h main.c proto.h
 
 endif
--- a/midiproc/main.c
+++ b/midiproc/main.c
@@ -28,6 +28,7 @@
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "SDL.h"
@@ -34,10 +35,10 @@
 #include "SDL_mixer.h"
 
 #include "buffer.h"
+#include "proto.h"
 
 #include "config.h"
 #include "doomtype.h"
-#include "net_defs.h"
 
 static HANDLE    midi_process_in;  // Standard In.
 static HANDLE    midi_process_out; // Standard Out.
@@ -158,7 +159,7 @@
 
     // FIXME: We should probably have a function for writing Int16's into
     //        buffers, as opposed to simply winging it.
-    i = NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK;
+    i = MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK;
     buffer[0] = (i >> 8) & 0xff;
     buffer[1] = i & 0xff;
 
@@ -220,15 +221,15 @@
 {
     switch (command)
     {
-    case NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG:
+    case MIDIPIPE_PACKET_TYPE_REGISTER_SONG:
         return MidiPipe_RegisterSong(reader);
-    case NET_MIDIPIPE_PACKET_TYPE_SET_VOLUME:
+    case MIDIPIPE_PACKET_TYPE_SET_VOLUME:
         return MidiPipe_SetVolume(reader);
-    case NET_MIDIPIPE_PACKET_TYPE_PLAY_SONG:
+    case MIDIPIPE_PACKET_TYPE_PLAY_SONG:
         return MidiPipe_PlaySong(reader);
-    case NET_MIDIPIPE_PACKET_TYPE_STOP_SONG:
+    case MIDIPIPE_PACKET_TYPE_STOP_SONG:
         return MidiPipe_StopSong();
-    case NET_MIDIPIPE_PACKET_TYPE_SHUTDOWN:
+    case MIDIPIPE_PACKET_TYPE_SHUTDOWN:
         return MidiPipe_Shutdown();
     default:
         return false;
@@ -400,12 +401,12 @@
     if (strcmp(PACKAGE_STRING, argv[1]) != 0)
     {
         char message[1024];
-        snprintf(message, sizeof(message),
-                 "It appears that the version of %s and %smidiproc are out of "
-                 " sync.  Please reinstall %s.\r\n\r\n"
-                 "Server Version: %s\r\nClient Version: %s",
-                 PACKAGE_NAME, PROGRAM_PREFIX, PACKAGE_NAME,
-                 PACKAGE_STRING, argv[1]);
+        _snprintf(message, sizeof(message),
+                  "It appears that the version of %s and %smidiproc are out "
+                  "of sync.  Please reinstall %s.\r\n\r\n"
+                  "Server Version: %s\r\nClient Version: %s",
+                  PACKAGE_NAME, PROGRAM_PREFIX, PACKAGE_NAME,
+                  PACKAGE_STRING, argv[1]);
         message[sizeof(message) - 1] = '\0';
 
         MessageBox(NULL, TEXT(message),
--- /dev/null
+++ b/midiproc/proto.h
@@ -1,0 +1,31 @@
+//
+// Copyright(C) 2017 Alex Mayfield
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// DESCRIPTION:
+//     Headers for all types of midipipe messages.
+//
+
+#ifndef __PROTO__
+#define __PROTO__
+
+typedef enum {
+    MIDIPIPE_PACKET_TYPE_REGISTER_SONG,
+    MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK,
+    MIDIPIPE_PACKET_TYPE_SET_VOLUME,
+    MIDIPIPE_PACKET_TYPE_PLAY_SONG,
+    MIDIPIPE_PACKET_TYPE_STOP_SONG,
+    MIDIPIPE_PACKET_TYPE_SHUTDOWN
+} net_midipipe_packet_type_t;
+
+#endif
+
--- a/src/i_midipipe.c
+++ b/src/i_midipipe.c
@@ -32,6 +32,8 @@
 #include "m_misc.h"
 #include "net_packet.h"
 
+#include "../midiproc/proto.h"
+
 #if defined(_DEBUG)
 #define DEBUGOUT(s) puts(s)
 #else
@@ -230,7 +232,7 @@
     net_packet_t *packet;
 
     packet = NET_NewPacket(64);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_REGISTER_SONG);
     NET_WriteString(packet, filename);
     ok = WritePipe(packet);
     NET_FreePacket(packet);
@@ -242,7 +244,7 @@
     }
 
     packet = NET_NewPacket(2);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK);
     ok = ExpectPipe(packet);
     NET_FreePacket(packet);
 
@@ -269,7 +271,7 @@
     net_packet_t *packet;
 
     packet = NET_NewPacket(6);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_SET_VOLUME);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_SET_VOLUME);
     NET_WriteInt32(packet, vol);
     ok = WritePipe(packet);
     NET_FreePacket(packet);
@@ -294,7 +296,7 @@
     net_packet_t *packet;
 
     packet = NET_NewPacket(6);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_PLAY_SONG);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_PLAY_SONG);
     NET_WriteInt32(packet, loops);
     ok = WritePipe(packet);
     NET_FreePacket(packet);
@@ -319,7 +321,7 @@
     net_packet_t *packet;
 
     packet = NET_NewPacket(2);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_STOP_SONG);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_STOP_SONG);
     ok = WritePipe(packet);
     NET_FreePacket(packet);
 
@@ -345,7 +347,7 @@
     net_packet_t *packet;
 
     packet = NET_NewPacket(2);
-    NET_WriteInt16(packet, NET_MIDIPIPE_PACKET_TYPE_SHUTDOWN);
+    NET_WriteInt16(packet, MIDIPIPE_PACKET_TYPE_SHUTDOWN);
     ok = WritePipe(packet);
     NET_FreePacket(packet);
 
--- a/src/net_defs.h
+++ b/src/net_defs.h
@@ -142,15 +142,6 @@
     NET_MASTER_PACKET_TYPE_SIGN_END_RESPONSE,
 } net_master_packet_type_t;
 
-typedef enum {
-    NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG,
-    NET_MIDIPIPE_PACKET_TYPE_REGISTER_SONG_ACK,
-    NET_MIDIPIPE_PACKET_TYPE_SET_VOLUME,
-    NET_MIDIPIPE_PACKET_TYPE_PLAY_SONG,
-    NET_MIDIPIPE_PACKET_TYPE_STOP_SONG,
-    NET_MIDIPIPE_PACKET_TYPE_SHUTDOWN
-} net_midipipe_packet_type_t;
-
 // Settings specified when the client connects to the server.
 
 typedef struct