diff --git a/plugins/spu2-x/src/Linux/Alsa.cpp b/plugins/spu2-x/src/Linux/Alsa.cpp index 41b2224a49..298cbdc9a8 100644 --- a/plugins/spu2-x/src/Linux/Alsa.cpp +++ b/plugins/spu2-x/src/Linux/Alsa.cpp @@ -205,7 +205,7 @@ public: return 0; } - int GetEmptySampleCount() const + int GetEmptySampleCount() { if(handle == NULL) return 0; @@ -234,4 +234,4 @@ public: } } static Alsa; -SndOutModule *AlsaOut = &Alsa; +SndOutModule *AlsaOut = &Alsa; diff --git a/plugins/spu2-x/src/Mixer.h b/plugins/spu2-x/src/Mixer.h index 36eb552019..debf00dcb2 100644 --- a/plugins/spu2-x/src/Mixer.h +++ b/plugins/spu2-x/src/Mixer.h @@ -67,6 +67,13 @@ struct StereoOut32 { return StereoOut32( Left / src, Right / src ); } + + void ResampleFrom( const StereoOut32& src ) + { + this->Left = src.Left << 2; + this->Right = src.Right << 2; + } + }; diff --git a/plugins/spu2-x/src/SndOut.cpp b/plugins/spu2-x/src/SndOut.cpp index a3fe48efce..0e89a16b89 100644 --- a/plugins/spu2-x/src/SndOut.cpp +++ b/plugins/spu2-x/src/SndOut.cpp @@ -58,7 +58,7 @@ public: s32 Test() const { return 0; } void Configure(uptr parent) { } bool Is51Out() const { return false; } - int GetEmptySampleCount() const { return 0; } + int GetEmptySampleCount() { return 0; } const wchar_t* GetIdent() const { @@ -88,6 +88,7 @@ SndOutModule* mods[]= DSoundOut, WaveOut, #endif + PortaudioOut, NULL // signals the end of our list }; diff --git a/plugins/spu2-x/src/SndOut.h b/plugins/spu2-x/src/SndOut.h index bf250ed71e..19723b395a 100644 --- a/plugins/spu2-x/src/SndOut.h +++ b/plugins/spu2-x/src/SndOut.h @@ -476,7 +476,7 @@ public: // Returns the number of empty samples in the output buffer. // (which is effectively the amount of data played since the last update) - virtual int GetEmptySampleCount() const=0; + virtual int GetEmptySampleCount() =0; }; @@ -486,6 +486,7 @@ extern SndOutModule* WaveOut; extern SndOutModule* DSoundOut; extern SndOutModule* XAudio2Out; #endif +extern SndOutModule* PortaudioOut; extern SndOutModule* mods[]; diff --git a/plugins/spu2-x/src/SndOut_Portaudio.cpp b/plugins/spu2-x/src/SndOut_Portaudio.cpp new file mode 100644 index 0000000000..43c7fd4b14 --- /dev/null +++ b/plugins/spu2-x/src/SndOut_Portaudio.cpp @@ -0,0 +1,187 @@ +/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2 + * Developed and maintained by the Pcsx2 Development Team. + * + * Original portions from SPU2ghz are (c) 2008 by David Quintana [gigaherz] + * + * SPU2-X is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * SPU2-X 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with SPU2-X. If not, see . + */ + +#include "Global.h" + +#define _WIN32_DCOM +#include "Dialogs.h" + +#include "portaudio/include/portaudio.h" + +class Portaudio : public SndOutModule +{ +private: + static const uint MAX_BUFFER_COUNT = 8; + static const int PacketsPerBuffer = 1; + static const int BufferSize = SndOutPacketSize * PacketsPerBuffer; + + ////////////////////////////////////////////////////////////////////////////////////////// + // Configuration Vars (unused still) + + wstring m_Api; + wstring m_Device; + + bool m_UseHardware; + + ////////////////////////////////////////////////////////////////////////////////////////// + // Instance vars + + int writtenSoFar; + int writtenLastTime; + int availableLastTime; + + bool started; + PaStream* stream; + + static int PaCallback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) + { + return PA.ActualPaCallback(inputBuffer,outputBuffer,framesPerBuffer,timeInfo,statusFlags,userData); + } + + + int ActualPaCallback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) + { + StereoOut32* p1 = (StereoOut32*)outputBuffer; + + int packets = framesPerBuffer / SndOutPacketSize; + + for(int p=0; pGetCurrentPosition( &play, &write ); diff --git a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp index 7f270d0e7b..f5b72b6885 100644 --- a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp @@ -85,7 +85,7 @@ private: CRITICAL_SECTION cs; public: - int GetEmptySampleCount() const + int GetEmptySampleCount() { XAUDIO2_VOICE_STATE state; pSourceVoice->GetState( &state ); @@ -364,7 +364,7 @@ public: return 0; } - int GetEmptySampleCount() const + int GetEmptySampleCount() { if( voiceContext == NULL ) return 0; return voiceContext->GetEmptySampleCount(); diff --git a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp index 96fa2dde5f..905f5a7cad 100644 --- a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp @@ -292,7 +292,7 @@ public: return 0; } - int GetEmptySampleCount() const + int GetEmptySampleCount() { int result = 0; for(int i=0;i + + + +