diff --git a/src/openal/sound.c b/src/openal/sound.c
index f4f07b9b6e91112d15b1b154dad7e8b4bcfa4df3..c1411f0f1d47f64b50ea71358a59d838fff866f3 100644 (file)
--- a/src/openal/sound.c
+++ b/src/openal/sound.c
+/* Copyright (C) 2020 SovietPony
+ *
+ * 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, version 3 of the License ONLY.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "sound.h"
#include "music.h"
#include "files.h" // F_findres F_getreslen
#include "memory.h" // M_lock M_unlock
-#include "misc.h" // int2host
#include "error.h" // logo
+#include "common/endianness.h"
+
#ifdef __APPLE__
# include <OpenAL/al.h>
# include <OpenAL/alc.h>
#pragma pack(1)
typedef struct dmi {
- dword len;
- dword rate;
- dword lstart;
- dword llen;
+ word len;
+ word rate;
+ word lstart;
+ word llen;
byte data[];
} dmi;
#pragma pack()
/* Sound */
-static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
enum { VOLUME, __NUM__ };
static const simple_menu_t sm = {
@@ -115,7 +131,7 @@ static int sound_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int
}
const menu_t *S_menu (void) {
- static const menu_t m = { sound_menu_handler };
+ static const menu_t m = { &sound_menu_handler };
return &m;
}
handle = M_lock(id);
if (handle != NULL) {
void *data = handle;
- dword len = F_getreslen(id);
- dword rate = 11025;
- dword lstart = 0;
- dword llen = 0;
+ word len = F_getreslen(id);
+ word rate = 11025;
+ word lstart = 0;
+ word llen = 0;
int sign = 0;
- if (len > 16) {
+ if (len > 8) {
dmi *hdr = handle;
- dword hdr_len = int2host(hdr->len);
- dword hdr_rate = int2host(hdr->rate);
- dword hdr_lstart = int2host(hdr->lstart);
- dword hdr_llen = int2host(hdr->llen);
- if (hdr_len <= len - 8 && hdr_lstart + hdr_llen <= len - 16) {
+ word hdr_len = short2host(hdr->len);
+ word hdr_rate = short2host(hdr->rate);
+ word hdr_lstart = short2host(hdr->lstart);
+ word hdr_llen = short2host(hdr->llen);
+ if (hdr_len <= len - 4 && hdr_lstart + hdr_llen <= len - 8) {
data = hdr->data;
len = hdr_len;
rate = hdr_rate;