ref: 8f1bc269f071e2e5eb607ecb26133656fc850527
parent: 09b188ac29717b8445df22ee3ee352db12c3c79d
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Sep 2 20:34:47 EDT 2019
I might have found out why Sound.cpp uses DSBUFFERDESC1
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -177,9 +177,9 @@
else
data_size = wave_size;
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
+ ZeroMemory(&dsbd, sizeof(dsbd));
- dsbd.dwSize = sizeof(DSBUFFERDESC);
+ dsbd.dwSize = sizeof(dsbd);
dsbd.dwBufferBytes = data_size;
dsbd.lpwfxFormat = &format_tbl2;
dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
+#define DIRECTSOUND_VERSION 0x500
#include <dsound.h>
#include "WindowsWrapper.h"
@@ -35,7 +36,7 @@
BOOL InitDirectSound(HWND hwnd)
{
int i;
- DSBUFFERDESC1 dsbd;
+ DSBUFFERDESC dsbd;
// DirectDrawの初期化 (DirectDraw initialization)
if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK)
@@ -51,10 +52,10 @@
lpDS->SetCooperativeLevel(hwnd, DSSCL_EXCLUSIVE);
// 一次バッファの初期化 (Initializing the primary buffer)
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC1));
- dsbd.dwSize = sizeof(DSBUFFERDESC1);
+ ZeroMemory(&dsbd, sizeof(dsbd));
+ dsbd.dwSize = sizeof(dsbd);
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
- lpDS->CreateSoundBuffer((DSBUFFERDESC*)&dsbd, &lpPRIMARYBUFFER, NULL);
+ lpDS->CreateSoundBuffer(&dsbd, &lpPRIMARYBUFFER, NULL);
for (i = 0; i < SE_MAX; i++)
lpSECONDARYBUFFER[i] = NULL;
@@ -91,7 +92,7 @@
BOOL InitSoundObject(LPCSTR resname, int no)
{
HRSRC hrscr;
- DSBUFFERDESC1 dsbd;
+ DSBUFFERDESC dsbd;
DWORD *lpdword; // リソースのアドレス (Resource address)
if (lpDS == NULL)
@@ -105,13 +106,13 @@
lpdword = (DWORD*)LockResource(LoadResource(NULL, hrscr));
// 二次バッファの生成 (Create secondary buffer)
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC1));
- dsbd.dwSize = sizeof(DSBUFFERDESC1);
+ ZeroMemory(&dsbd, sizeof(dsbd));
+ dsbd.dwSize = sizeof(dsbd);
dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
dsbd.dwBufferBytes = *(DWORD*)((BYTE*)lpdword+0x36); // WAVEデータのサイズ (WAVE data size)
dsbd.lpwfxFormat = (LPWAVEFORMATEX)(lpdword+5);
- if (lpDS->CreateSoundBuffer((DSBUFFERDESC*)&dsbd, &lpSECONDARYBUFFER[no], NULL) != DS_OK)
+ if (lpDS->CreateSoundBuffer(&dsbd, &lpSECONDARYBUFFER[no], NULL) != DS_OK)
return FALSE;
LPVOID lpbuf1, lpbuf2;
@@ -178,14 +179,14 @@
fclose(fp);
// セカンダリバッファの生成 (Create secondary buffer)
- DSBUFFERDESC1 dsbd;
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC1));
- dsbd.dwSize = sizeof(DSBUFFERDESC1);
+ DSBUFFERDESC dsbd;
+ ZeroMemory(&dsbd, sizeof(dsbd));
+ dsbd.dwSize = sizeof(dsbd);
dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
dsbd.dwBufferBytes = *(DWORD*)((BYTE*)wp+0x36); // WAVEデータのサイズ (WAVE data size)
dsbd.lpwfxFormat = (LPWAVEFORMATEX)(wp+5);
- if (lpDS->CreateSoundBuffer((DSBUFFERDESC*)&dsbd, &lpSECONDARYBUFFER[no], NULL) != DS_OK)
+ if (lpDS->CreateSoundBuffer(&dsbd, &lpSECONDARYBUFFER[no], NULL) != DS_OK)
{
#ifdef FIX_BUGS
free(wp); // The updated Organya source code includes this fix
@@ -293,7 +294,7 @@
int i;
int j;
- DSBUFFERDESC1 dsbd;
+ DSBUFFERDESC dsbd;
WavHeader wav_header;
const PIXTONEPARAMETER *ptp_pointer;
int sample_count;
@@ -333,13 +334,13 @@
++ptp_pointer;
}
- ZeroMemory(&dsbd, sizeof(DSBUFFERDESC1));
- dsbd.dwSize = sizeof(DSBUFFERDESC1);
+ ZeroMemory(&dsbd, sizeof(dsbd));
+ dsbd.dwSize = sizeof(dsbd);
dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
dsbd.dwBufferBytes = sample_count;
dsbd.lpwfxFormat = (WAVEFORMATEX*)&wav_header.audio_format;
- if (lpDS->CreateSoundBuffer((DSBUFFERDESC*)&dsbd, &lpSECONDARYBUFFER[no], 0) != DS_OK)
+ if (lpDS->CreateSoundBuffer(&dsbd, &lpSECONDARYBUFFER[no], 0) != DS_OK)
return -1;
pcm_buffer = mixed_pcm_buffer = NULL;
--- a/src/Sound.h
+++ b/src/Sound.h
@@ -2,6 +2,9 @@
#include <stddef.h>
+#ifndef DIRECTSOUND_VERSION
+#define DIRECTSOUND_VERSION 0x500
+#endif
#include <dsound.h>
#include "WindowsWrapper.h"