summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2014-08-23 11:18:00 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2014-08-23 11:19:19 -0700
commitaf2405eefdee151e653a326d5f50dc27cb5325cc (patch)
tree4316c6ec7a9716f15a1c0c4efb218a0fec90952d /Source/Core/AudioCommon
parent8bb3fa561b4598e7564300d5d8bf2d38a1fb5362 (diff)
Remove dsound audio backend.
There isn't any reason to use dsound over xaudio.
Diffstat (limited to 'Source/Core/AudioCommon')
-rw-r--r--Source/Core/AudioCommon/AudioCommon.cpp5
-rw-r--r--Source/Core/AudioCommon/AudioCommon.vcxproj2
-rw-r--r--Source/Core/AudioCommon/AudioCommon.vcxproj.filters8
-rw-r--r--Source/Core/AudioCommon/CMakeLists.txt1
-rw-r--r--Source/Core/AudioCommon/DSoundStream.cpp170
-rw-r--r--Source/Core/AudioCommon/DSoundStream.h78
6 files changed, 1 insertions, 263 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp
index 3550b3cb16..270bbec0eb 100644
--- a/Source/Core/AudioCommon/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/AudioCommon.cpp
@@ -7,7 +7,6 @@
#include "AudioCommon/AOSoundStream.h"
#include "AudioCommon/AudioCommon.h"
#include "AudioCommon/CoreAudioSoundStream.h"
-#include "AudioCommon/DSoundStream.h"
#include "AudioCommon/Mixer.h"
#include "AudioCommon/NullSoundStream.h"
#include "AudioCommon/OpenALStream.h"
@@ -37,8 +36,6 @@ namespace AudioCommon
soundStream = new OpenALStream(mixer);
else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
soundStream = new NullSound(mixer);
- else if (backend == BACKEND_DIRECTSOUND && DSound::isValid())
- soundStream = new DSound(mixer, hWnd);
else if (backend == BACKEND_XAUDIO2)
{
if (XAudio2::isValid())
@@ -111,8 +108,6 @@ namespace AudioCommon
if (NullSound::isValid())
backends.push_back(BACKEND_NULLSOUND);
- if (DSound::isValid())
- backends.push_back(BACKEND_DIRECTSOUND);
if (XAudio2_7::isValid() || XAudio2::isValid())
backends.push_back(BACKEND_XAUDIO2);
if (AOSound::isValid())
diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj b/Source/Core/AudioCommon/AudioCommon.vcxproj
index 4bf2996e44..d80bed06d6 100644
--- a/Source/Core/AudioCommon/AudioCommon.vcxproj
+++ b/Source/Core/AudioCommon/AudioCommon.vcxproj
@@ -38,7 +38,6 @@
<ClCompile Include="aldlist.cpp" />
<ClCompile Include="AudioCommon.cpp" />
<ClCompile Include="DPL2Decoder.cpp" />
- <ClCompile Include="DSoundStream.cpp" />
<ClCompile Include="Mixer.cpp" />
<ClCompile Include="NullSoundStream.cpp" />
<ClCompile Include="OpenALStream.cpp" />
@@ -55,7 +54,6 @@
<ClInclude Include="AudioCommon.h" />
<ClInclude Include="CoreAudioSoundStream.h" />
<ClInclude Include="DPL2Decoder.h" />
- <ClInclude Include="DSoundStream.h" />
<ClInclude Include="Mixer.h" />
<ClInclude Include="NullSoundStream.h" />
<ClInclude Include="OpenALStream.h" />
diff --git a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters
index d79b692828..2832422073 100644
--- a/Source/Core/AudioCommon/AudioCommon.vcxproj.filters
+++ b/Source/Core/AudioCommon/AudioCommon.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="SoundStreams">
@@ -11,9 +11,6 @@
<ClCompile Include="DPL2Decoder.cpp" />
<ClCompile Include="Mixer.cpp" />
<ClCompile Include="WaveFile.cpp" />
- <ClCompile Include="DSoundStream.cpp">
- <Filter>SoundStreams</Filter>
- </ClCompile>
<ClCompile Include="NullSoundStream.cpp">
<Filter>SoundStreams</Filter>
</ClCompile>
@@ -37,9 +34,6 @@
<ClInclude Include="AOSoundStream.h">
<Filter>SoundStreams</Filter>
</ClInclude>
- <ClInclude Include="DSoundStream.h">
- <Filter>SoundStreams</Filter>
- </ClInclude>
<ClInclude Include="NullSoundStream.h">
<Filter>SoundStreams</Filter>
</ClInclude>
diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt
index ab4207fa87..8423164226 100644
--- a/Source/Core/AudioCommon/CMakeLists.txt
+++ b/Source/Core/AudioCommon/CMakeLists.txt
@@ -32,7 +32,6 @@ if(PULSEAUDIO_FOUND)
endif(PULSEAUDIO_FOUND)
if(WIN32)
- set(SRCS ${SRCS} DSoundStream.cpp)
set(SRCS ${SRCS} XAudio2Stream.cpp)
endif(WIN32)
diff --git a/Source/Core/AudioCommon/DSoundStream.cpp b/Source/Core/AudioCommon/DSoundStream.cpp
deleted file mode 100644
index dd56754286..0000000000
--- a/Source/Core/AudioCommon/DSoundStream.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2013 Dolphin Emulator Project
-// Licensed under GPLv2
-// Refer to the license.txt file included.
-
-#include <cmath>
-#include <thread>
-#include <Windows.h>
-
-#include "AudioCommon/AudioCommon.h"
-#include "AudioCommon/DSoundStream.h"
-#include "Common/Thread.h"
-
-bool DSound::CreateBuffer()
-{
- PCMWAVEFORMAT pcmwf;
- DSBUFFERDESC dsbdesc;
-
- memset(&pcmwf, 0, sizeof(PCMWAVEFORMAT));
- memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
-
- pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM;
- pcmwf.wf.nChannels = 2;
- pcmwf.wf.nSamplesPerSec = m_mixer->GetSampleRate();
- pcmwf.wf.nBlockAlign = 4;
- pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
- pcmwf.wBitsPerSample = 16;
-
- // Fill out DSound buffer description.
- dsbdesc.dwSize = sizeof(DSBUFFERDESC);
- dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS;
- dsbdesc.dwBufferBytes = bufferSize = BUFSIZE;
- dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&pcmwf;
- dsbdesc.guid3DAlgorithm = DS3DALG_DEFAULT;
-
- HRESULT res = ds->CreateSoundBuffer(&dsbdesc, &dsBuffer, nullptr);
- if (SUCCEEDED(res))
- {
- dsBuffer->SetCurrentPosition(0);
- dsBuffer->SetVolume(m_volume);
- return true;
- }
- else
- {
- // Failed.
- PanicAlertT("Sound buffer creation failed: %08x", res);
- dsBuffer = nullptr;
- return false;
- }
-}
-
-bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write cursor.
- char* soundData, // Start of our data.
- DWORD dwSoundBytes) // Size of block to copy.
-{
- // I want to record the regular audio to, how do I do that?
-
- void *ptr1, *ptr2;
- DWORD numBytes1, numBytes2;
- // Obtain memory address of write block. This will be in two parts if the block wraps around.
- HRESULT hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
-
- // If the buffer was lost, restore and retry lock.
- if (DSERR_BUFFERLOST == hr)
- {
- dsBuffer->Restore();
- hr = dsBuffer->Lock(dwOffset, dwSoundBytes, &ptr1, &numBytes1, &ptr2, &numBytes2, 0);
- }
- if (SUCCEEDED(hr))
- {
- memcpy(ptr1, soundData, numBytes1);
- if (ptr2 != 0)
- memcpy(ptr2, soundData + numBytes1, numBytes2);
-
- // Release the data back to DirectSound.
- dsBuffer->Unlock(ptr1, numBytes1, ptr2, numBytes2);
- return true;
- }
-
- return false;
-}
-
-// The audio thread.
-void DSound::SoundLoop()
-{
- Common::SetCurrentThreadName("Audio thread - dsound");
-
- currentPos = 0;
- lastPos = 0;
- dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
-
- while (!threadData)
- {
- // No blocking inside the csection
- dsBuffer->GetCurrentPosition((DWORD*)&currentPos, 0);
- int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos));
- if (numBytesToRender >= 256)
- {
- if (numBytesToRender > sizeof(realtimeBuffer))
- PanicAlert("soundThread: too big render call");
- m_mixer->Mix(realtimeBuffer, numBytesToRender / 4);
- WriteDataToBuffer(lastPos, (char*)realtimeBuffer, numBytesToRender);
- lastPos = ModBufferSize(lastPos + numBytesToRender);
- }
- soundSyncEvent.Wait();
- }
-}
-
-bool DSound::Start()
-{
- if (FAILED(DirectSoundCreate8(0, &ds, 0)))
- return false;
- if (hWnd)
- {
- HRESULT hr = ds->SetCooperativeLevel((HWND)hWnd, DSSCL_PRIORITY);
- }
- if (!CreateBuffer())
- return false;
-
- DWORD num1;
- short* p1;
- dsBuffer->Lock(0, bufferSize, (void* *)&p1, &num1, 0, 0, DSBLOCK_ENTIREBUFFER);
- memset(p1, 0, num1);
- dsBuffer->Unlock(p1, num1, 0, 0);
- thread = std::thread(&DSound::SoundLoop, this);
- return true;
-}
-
-void DSound::SetVolume(int volume)
-{
- // This is in "dBA attenuation" from 0 to -10000, logarithmic
- m_volume = (int)floor(log10((float)volume) * 5000.0f) - 10000;
-
- if (dsBuffer != nullptr)
- dsBuffer->SetVolume(m_volume);
-}
-
-void DSound::Update()
-{
- soundSyncEvent.Set();
-}
-
-void DSound::Clear(bool mute)
-{
- m_muted = mute;
-
- if (dsBuffer != nullptr)
- {
- if (m_muted)
- {
- dsBuffer->Stop();
- }
- else
- {
- dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
- }
- }
-}
-
-void DSound::Stop()
-{
- threadData = 1;
- // kick the thread if it's waiting
- soundSyncEvent.Set();
-
- thread.join();
- dsBuffer->Stop();
- dsBuffer->Release();
- ds->Release();
-}
-
diff --git a/Source/Core/AudioCommon/DSoundStream.h b/Source/Core/AudioCommon/DSoundStream.h
deleted file mode 100644
index 6ce946c4a2..0000000000
--- a/Source/Core/AudioCommon/DSoundStream.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2013 Dolphin Emulator Project
-// Licensed under GPLv2
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include <thread>
-
-#include "AudioCommon/SoundStream.h"
-#include "Common/Event.h"
-
-#ifdef _WIN32
-#include <Windows.h>
-#include <mmsystem.h>
-#include <dsound.h>
-
-#define BUFSIZE (1024 * 8 * 4)
-#endif
-
-class DSound final : public SoundStream
-{
-#ifdef _WIN32
- std::thread thread;
- Common::Event soundSyncEvent;
- void *hWnd;
-
- IDirectSound8* ds;
- IDirectSoundBuffer* dsBuffer;
-
- int bufferSize; //i bytes
- int m_volume;
-
- // playback position
- int currentPos;
- int lastPos;
- short realtimeBuffer[BUFSIZE / sizeof(short)];
-
- inline int FIX128(int x)
- {
- return x & (~127);
- }
-
- inline int ModBufferSize(int x)
- {
- return (x + bufferSize) % bufferSize;
- }
-
- bool CreateBuffer();
- bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes);
-
-public:
- DSound(CMixer *mixer, void *_hWnd)
- : SoundStream(mixer)
- , bufferSize(0)
- , currentPos(0)
- , lastPos(0)
- , dsBuffer(0)
- , ds(0)
- , hWnd(_hWnd)
- {}
-
- virtual ~DSound() {}
-
- virtual bool Start();
- virtual void SoundLoop();
- virtual void SetVolume(int volume);
- virtual void Stop();
- virtual void Clear(bool mute);
- static bool isValid() { return true; }
- virtual void Update();
-
-#else
-public:
- DSound(CMixer *mixer, void *_hWnd)
- : SoundStream(mixer)
- {}
-#endif
-};