Browse Source

Rename dsound and it nolonger reflects DirectSound

pull/567/head
Anders Jenbo 6 years ago
parent
commit
6e9987cc93
  1. 2
      CMakeLists.txt
  2. 6
      Source/sound.h
  3. 1
      SourceS/miniwin.h
  4. 17
      SourceS/miniwin/com.h
  5. 1
      SourceS/miniwin/misc_macro.h
  6. 18
      SourceS/ssound.h
  7. 21
      SourceX/miniwin/dsound.h
  8. 7
      SourceX/sound.cpp
  9. 13
      SourceX/ssound.cpp
  10. 2
      structs.h
  11. 1
      types.h

2
CMakeLists.txt

@ -255,8 +255,8 @@ set(devilutionx_SRCS
SourceX/miniwin/misc_msg.cpp
SourceX/miniwin/rand.cpp
SourceX/miniwin/thread.cpp
SourceX/miniwin/dsound.cpp
SourceX/sound.cpp
SourceX/ssound.cpp
SourceX/storm/storm.cpp
SourceX/storm/storm_net.cpp
SourceX/storm/storm_dx.cpp

6
Source/sound.h

@ -2,7 +2,7 @@
#ifndef __SOUND_H__
#define __SOUND_H__
extern IDirectSoundBuffer *DSBs[8];
extern SoundSample *DSBs[8];
extern BOOLEAN gbSndInited;
extern HMODULE hDsound_dll;
@ -10,8 +10,8 @@ void snd_update(BOOL bStopAll);
void snd_stop_snd(TSnd *pSnd);
BOOL snd_playing(TSnd *pSnd);
void snd_play_snd(TSnd *pSnd, int lVolume, int lPan);
IDirectSoundBuffer *sound_dup_channel(IDirectSoundBuffer *DSB);
BOOL sound_file_reload(TSnd *sound_file, IDirectSoundBuffer *DSB);
SoundSample *sound_dup_channel(SoundSample *DSB);
BOOL sound_file_reload(TSnd *sound_file, SoundSample *DSB);
TSnd *sound_file_load(char *path);
void sound_CreateSoundBuffer(TSnd *sound_file);
void sound_file_cleanup(TSnd *sound_file);

1
SourceS/miniwin.h

@ -22,7 +22,6 @@
#endif
#include "miniwin/misc.h"
#include "miniwin/com.h"
#include "miniwin/ui.h"
#include "miniwin/thread.h"
#include "miniwin/rand.h"

17
SourceS/miniwin/com.h

@ -1,17 +0,0 @@
#pragma once
namespace dvl {
struct IDirectSoundBuffer {
virtual void Release() = 0;
virtual bool IsPlaying() = 0;
virtual void Play(int lVolume, int lPan) = 0;
virtual void Stop() = 0;
virtual int SetChunk(BYTE *fileData, DWORD dwBytes) = 0;
};
typedef IDirectSoundBuffer *LPDIRECTSOUNDBUFFER;
const auto DVL_ERROR_SUCCESS = 0L;
} // namespace dvl

1
SourceS/miniwin/misc_macro.h

@ -49,7 +49,6 @@
#define GENERIC_WRITE DVL_GENERIC_WRITE
#define OPEN_EXISTING DVL_OPEN_EXISTING
#define OPEN_ALWAYS 4
#define ERROR_SUCCESS DVL_ERROR_SUCCESS
#define FILE_ATTRIBUTE_NORMAL 128
#define OFS_MAXPATHNAME DVL_OFS_MAXPATHNAME

18
SourceS/ssound.h

@ -0,0 +1,18 @@
#pragma once
#include <SDL_mixer.h>
namespace dvl {
typedef struct SoundSample final {
public:
void Release() ;
bool IsPlaying() ;
void Play(int lVolume, int lPan) ;
void Stop() ;
int SetChunk(BYTE *fileData, DWORD dwBytes) ;
private:
Mix_Chunk *chunk;
} SoundSample;
} // namespace dvl

21
SourceX/miniwin/dsound.h

@ -1,21 +0,0 @@
#pragma once
#include "devilution.h"
#include <SDL_mixer.h>
namespace dvl {
struct DirectSoundBuffer final : public IDirectSoundBuffer {
public:
void Release() override;
bool IsPlaying() override;
void Play(int lVolume, int lPan) override;
void Stop() override;
int SetChunk(BYTE *fileData, DWORD dwBytes) override;
private:
Mix_Chunk *chunk;
};
} // namespace dvl

7
SourceX/sound.cpp

@ -1,5 +1,4 @@
#include "devilution.h"
#include "miniwin/dsound.h"
#include "stubs.h"
#include <SDL.h>
#include <SDL_mixer.h>
@ -46,7 +45,7 @@ BOOL snd_playing(TSnd *pSnd)
void snd_play_snd(TSnd *pSnd, int lVolume, int lPan)
{
LPDIRECTSOUNDBUFFER DSB;
SoundSample *DSB;
DWORD tc;
if (!pSnd || !gbSoundOn) {
@ -91,7 +90,7 @@ TSnd *sound_file_load(char *path)
wave_file = DiabloAllocPtr(dwBytes);
SFileReadFile(file, wave_file, dwBytes, NULL, NULL);
pSnd->DSB = new DirectSoundBuffer();
pSnd->DSB = new SoundSample();
error = pSnd->DSB->SetChunk(wave_file, dwBytes);
WCloseFile(file);
mem_free_dbg(wave_file);
@ -108,7 +107,7 @@ void sound_file_cleanup(TSnd *sound_file)
if (sound_file->DSB) {
sound_file->DSB->Stop();
sound_file->DSB->Release();
delete static_cast<DirectSoundBuffer *>(sound_file->DSB);
delete sound_file->DSB;
sound_file->DSB = NULL;
}

13
SourceX/miniwin/dsound.cpp → SourceX/ssound.cpp

@ -1,18 +1,17 @@
#include "devilution.h"
#include "miniwin/dsound.h"
#include "stubs.h"
#include <SDL.h>
namespace dvl {
///// DirectSoundBuffer /////
///// SoundSample /////
void DirectSoundBuffer::Release()
void SoundSample::Release()
{
Mix_FreeChunk(chunk);
};
bool DirectSoundBuffer::IsPlaying()
bool SoundSample::IsPlaying()
{
for (int i = 1; i < Mix_AllocateChannels(-1); i++) {
if (Mix_GetChunk(i) == chunk && Mix_Playing(i)) {
@ -23,7 +22,7 @@ bool DirectSoundBuffer::IsPlaying()
return false;
};
void DirectSoundBuffer::Play(int lVolume, int lPan)
void SoundSample::Play(int lVolume, int lPan)
{
int channel = Mix_PlayChannel(-1, chunk, 0);
if (channel == -1) {
@ -36,7 +35,7 @@ void DirectSoundBuffer::Play(int lVolume, int lPan)
Mix_SetPanning(channel, pan > 0 ? pan : 255, pan < 0 ? abs(pan) : 255);
};
void DirectSoundBuffer::Stop()
void SoundSample::Stop()
{
for (int i = 1; i < Mix_AllocateChannels(-1); i++) {
if (Mix_GetChunk(i) != chunk) {
@ -47,7 +46,7 @@ void DirectSoundBuffer::Stop()
}
};
int DirectSoundBuffer::SetChunk(BYTE *fileData, DWORD dwBytes)
int SoundSample::SetChunk(BYTE *fileData, DWORD dwBytes)
{
SDL_RWops *buf1 = SDL_RWFromConstMem(fileData, dwBytes);
if (buf1 == NULL) {

2
structs.h

@ -451,7 +451,7 @@ typedef struct MissileStruct {
typedef struct TSnd {
char *sound_path;
LPDIRECTSOUNDBUFFER DSB;
SoundSample *DSB;
int start_tc;
} TSnd;

1
types.h

@ -9,6 +9,7 @@
#define DEVILUTION_END_NAMESPACE }
#include "miniwin.h"
#include "ssound.h"
DEVILUTION_BEGIN_NAMESPACE

Loading…
Cancel
Save