Move midipipe messages out of net
Rename them while we're at it.
This commit is contained in:
parent
f09202ec5a
commit
e8e2d602e6
5 changed files with 54 additions and 29 deletions
|
|
@ -6,6 +6,6 @@ if HAVE_WINDRES
|
|||
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
|
||||
|
|
|
|||
|
|
@ -28,16 +28,17 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#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 @@ static boolean MidiPipe_RegisterSong(buffer_reader_t *reader)
|
|||
|
||||
// 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 @@ boolean ParseCommand(buffer_reader_t *reader, uint16_t command)
|
|||
{
|
||||
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 @@ int main(int argc, char *argv[])
|
|||
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),
|
||||
|
|
|
|||
31
midiproc/proto.h
Executable file
31
midiproc/proto.h
Executable file
|
|
@ -0,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
|
||||
|
||||
|
|
@ -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 @@ boolean I_MidiPipe_RegisterSong(char *filename)
|
|||
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 @@ boolean I_MidiPipe_RegisterSong(char *filename)
|
|||
}
|
||||
|
||||
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 @@ void I_MidiPipe_SetVolume(int vol)
|
|||
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 @@ void I_MidiPipe_PlaySong(int loops)
|
|||
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 @@ void I_MidiPipe_StopSong()
|
|||
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 @@ void I_MidiPipe_ShutdownServer()
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -142,15 +142,6 @@ typedef enum
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue