This is a joined work of XK and me on improving the HLE plugin interface.

It allows run time selection of backends (AOSound, DSound and NullSound).
It replaces the DSP_NULL plugin (works even better!)
It also includes improved thread handling on asound, and using some common functions on both
asound and windows.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2027 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee
2009-01-29 00:57:55 +00:00
parent 121be22532
commit 7219bcd4d5
46 changed files with 705 additions and 4584 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2003-2008 Dolphin Project.
// Copyright (C) 2003-2009 Dolphin Project.
// 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
@ -15,21 +15,90 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __SOUNDSTREAM_H__
#define __SOUNDSTREAM_H__
#ifndef __DSOUNDSTREAM_H__
#define __DSOUNDSTREAM_H__
#include "SoundStream.h"
namespace DSound
#include "Thread.h"
#ifdef _WIN32
#include "stdafx.h"
#include <mmsystem.h>
#include <dsound.h>
#define BUFSIZE 32768
#define MAXWAIT 70 //ms
#endif
class DSound : public SoundStream
{
typedef void (*StreamCallback)(short* buffer, int numSamples, int bits, int rate, int channels);
#ifdef _WIN32
bool DSound_StartSound(HWND window, int sampleRate, StreamCallback _callback);
void DSound_UpdateSound();
void DSound_StopSound();
Common::Thread *thread;
Common::CriticalSection *soundCriticalSection;
Common::Event *soundSyncEvent;
void *hWnd;
float DSound_GetTimer();
int DSound_GetCurSample();
int DSound_GetSampleRate();
}
IDirectSound8* ds;
IDirectSoundBuffer* dsBuffer;
int bufferSize; //i bytes
int totalRenderedBytes;
// playback position
int currentPos;
int lastPos;
short realtimeBuffer[1024 * 1024];
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(int _sampleRate, StreamCallback _callback) :
SoundStream(_sampleRate, _callback) {}
DSound(int _sampleRate, StreamCallback _callback, void *_hWnd) :
SoundStream(_sampleRate, _callback), hWnd(_hWnd) {}
virtual ~DSound() {}
virtual bool Start();
virtual void SoundLoop();
virtual void Stop();
static bool isValid() { return true; }
virtual bool usesMixer() { return true; }
virtual void Update();
#else
public:
DSound(int _sampleRate, StreamCallback _callback, void *hWnd = NULL) :
SoundStream(_sampleRate, _callback) {}
#endif //__SOUNDSTREAM_H__
#endif
};
#endif //__DSOUNDSTREAM_H__