Cocoa OpenEmu Plug-in:
- Integrate OpenEmu's audio system with the OpenEmu Plug-in. (Special thanks to jweinberg, clobber, and Psy from the OpenEmu team!) - Make input handling asynchronous through the Distributed Object system. - Rename OpenEmuSoundInterface.mm/.h to OESoundInterface.mm/.h. - Some minor cleanup to global defines.
This commit is contained in:
parent
18a5907a1e
commit
5b11947f77
|
@ -104,6 +104,7 @@
|
|||
AB0F29C914BE7213009ABC6F /* Icon_Speaker_420x420.png in Resources */ = {isa = PBXBuildFile; fileRef = AB0F29A514BE7213009ABC6F /* Icon_Speaker_420x420.png */; };
|
||||
AB15CA7214A29EE500B8A6A4 /* cpu_detect_x86_gcc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABAD3E6613AF1D6D00502E1E /* cpu_detect_x86_gcc.cpp */; };
|
||||
AB181D0013B66889006CA82D /* datetime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD1FF1F1345ACBF00AF11D1 /* datetime.cpp */; };
|
||||
AB1949DB15034F900098793E /* OESoundInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABB3C6401501BB8300E0C22E /* OESoundInterface.mm */; };
|
||||
AB1B9E631501A78000464647 /* coreaudiosound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */; };
|
||||
AB1B9E641501A78000464647 /* coreaudiosound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */; };
|
||||
AB1B9E651501A78000464647 /* coreaudiosound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */; };
|
||||
|
@ -291,9 +292,6 @@
|
|||
ABB3C6691501BF8A00E0C22E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABC570D4134431DA00E7B0B1 /* OpenGL.framework */; };
|
||||
ABB3C66A1501BF8A00E0C22E /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AB0A0D1914AACA9600E83E91 /* libz.dylib */; };
|
||||
ABB3C66C1501C04F00E0C22E /* NDSGameCore.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABB3C63E1501BB8300E0C22E /* NDSGameCore.mm */; };
|
||||
ABB3C66D1501C04F00E0C22E /* coreaudiosound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E5F1501A78000464647 /* coreaudiosound.cpp */; };
|
||||
ABB3C66E1501C04F00E0C22E /* ringbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB1B9E601501A78000464647 /* ringbuffer.cpp */; };
|
||||
ABB3C66F1501C04F00E0C22E /* sndOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABD104141346652500AF11D1 /* sndOSX.cpp */; };
|
||||
ABB3C6701501C04F00E0C22E /* videofilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB817A35143EE2DB00A7DFE9 /* videofilter.cpp */; };
|
||||
ABB3C6711501C04F00E0C22E /* cocoa_core.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABD104121346652500AF11D1 /* cocoa_core.mm */; };
|
||||
ABB3C6721501C04F00E0C22E /* cocoa_file.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB58F32C1364F44B0074C376 /* cocoa_file.mm */; };
|
||||
|
@ -844,8 +842,8 @@
|
|||
ABB3C63D1501BB8300E0C22E /* NDSGameCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NDSGameCore.h; sourceTree = "<group>"; };
|
||||
ABB3C63E1501BB8300E0C22E /* NDSGameCore.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NDSGameCore.mm; sourceTree = "<group>"; };
|
||||
ABB3C63F1501BB8300E0C22E /* OENDSSystemResponderClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OENDSSystemResponderClient.h; sourceTree = "<group>"; };
|
||||
ABB3C6401501BB8300E0C22E /* OpenEmuSoundInterface.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OpenEmuSoundInterface.cpp; sourceTree = "<group>"; };
|
||||
ABB3C6411501BB8300E0C22E /* OpenEmuSoundInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenEmuSoundInterface.h; sourceTree = "<group>"; };
|
||||
ABB3C6401501BB8300E0C22E /* OESoundInterface.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OESoundInterface.mm; sourceTree = "<group>"; };
|
||||
ABB3C6411501BB8300E0C22E /* OESoundInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OESoundInterface.h; sourceTree = "<group>"; };
|
||||
ABB3C6471501BC6D00E0C22E /* DeSmuME.oecoreplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DeSmuME.oecoreplugin; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
ABB7160914E386740027FE88 /* DeSmuME (Debug).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DeSmuME (Debug).app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
ABB97873144E89CC00793FA3 /* Icon_ActionReplay_32x32.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon_ActionReplay_32x32.png; path = Images/Icon_ActionReplay_32x32.png; sourceTree = "<group>"; };
|
||||
|
@ -1294,10 +1292,10 @@
|
|||
ABB3C63A1501BB8300E0C22E /* openemu */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ABB3C6401501BB8300E0C22E /* OpenEmuSoundInterface.cpp */,
|
||||
ABB3C6401501BB8300E0C22E /* OESoundInterface.mm */,
|
||||
ABB3C63D1501BB8300E0C22E /* NDSGameCore.h */,
|
||||
ABB3C63F1501BB8300E0C22E /* OENDSSystemResponderClient.h */,
|
||||
ABB3C6411501BB8300E0C22E /* OpenEmuSoundInterface.h */,
|
||||
ABB3C6411501BB8300E0C22E /* OESoundInterface.h */,
|
||||
ABB3C63E1501BB8300E0C22E /* NDSGameCore.mm */,
|
||||
ABB3C63B1501BB8300E0C22E /* DeSmuME_Prefix_OpenEmu.pch */,
|
||||
ABB3C63C1501BB8300E0C22E /* Info (OpenEmu Plug-in).plist */,
|
||||
|
@ -2324,9 +2322,6 @@
|
|||
files = (
|
||||
ABE9EEEB1501C78700D3FB19 /* fs-linux.cpp in Sources */,
|
||||
ABB3C66C1501C04F00E0C22E /* NDSGameCore.mm in Sources */,
|
||||
ABB3C66D1501C04F00E0C22E /* coreaudiosound.cpp in Sources */,
|
||||
ABB3C66E1501C04F00E0C22E /* ringbuffer.cpp in Sources */,
|
||||
ABB3C66F1501C04F00E0C22E /* sndOSX.cpp in Sources */,
|
||||
ABB3C6701501C04F00E0C22E /* videofilter.cpp in Sources */,
|
||||
ABB3C6711501C04F00E0C22E /* cocoa_core.mm in Sources */,
|
||||
ABB3C6721501C04F00E0C22E /* cocoa_file.mm in Sources */,
|
||||
|
@ -2430,6 +2425,7 @@
|
|||
ABB3C6D61501C04F00E0C22E /* version.cpp in Sources */,
|
||||
ABB3C6D71501C04F00E0C22E /* wifi.cpp in Sources */,
|
||||
ABE9EEEA1501C6EB00D3FB19 /* cocoa_firmware.mm in Sources */,
|
||||
AB1949DB15034F900098793E /* OESoundInterface.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -161,11 +161,11 @@
|
|||
#define FRAME_SKIP_BIAS 0.5 // May be any real number. This value acts as a vector addition to the frame skip.
|
||||
#define MAX_FRAME_SKIP (DS_FRAMES_PER_SECOND / 3.0)
|
||||
|
||||
#define SPU_SAMPLE_RATE 44100 // Samples per second
|
||||
#define SPU_SAMPLE_RATE 44100.0 // Samples per second
|
||||
#define SPU_SAMPLE_RESOLUTION 16 // Bits per sample; must be a multiple of 8
|
||||
#define SPU_NUMBER_CHANNELS 2 // Number of channels
|
||||
#define SPU_SAMPLE_SIZE ((SPU_SAMPLE_RESOLUTION / 8) * SPU_NUMBER_CHANNELS) // Bytes per sample, multiplied by the number of channels
|
||||
#define SPU_BUFFER_BYTES ((SPU_SAMPLE_RATE / DS_FRAMES_PER_SECOND) * SPU_SAMPLE_SIZE)
|
||||
#define SPU_BUFFER_BYTES ((SPU_SAMPLE_RATE / DS_FRAMES_PER_SECOND) * SPU_SAMPLE_SIZE) // Note that this value may be returned as floating point
|
||||
|
||||
#define CLOCKWISE_DEGREES(x) (360.0 - x) // Converts an angle in degrees from normal-direction to clockwise-direction.
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
#import "cocoa_core.h"
|
||||
#import "cocoa_mic.h"
|
||||
#import "cocoa_output.h"
|
||||
#include "../sndOSX.h"
|
||||
//#include "OpenEmuSoundInterface.h"
|
||||
#import "OESoundInterface.h"
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
#include "../../path.h"
|
||||
|
@ -76,8 +75,9 @@
|
|||
CommonSettings.spuInterpolationMode = SPUInterpolation_Cosine;
|
||||
|
||||
// Set up the sound core
|
||||
NSInteger result = SPU_ChangeSoundCore(SNDCORE_OSX, (int)SPU_BUFFER_BYTES);
|
||||
//NSInteger result = SPU_ChangeSoundCore(SNDCORE_OPENEMU, (int)SPU_BUFFER_BYTES);
|
||||
openEmuSoundInterfaceBuffer = [self ringBufferAtIndex:0];
|
||||
|
||||
NSInteger result = SPU_ChangeSoundCore(SNDCORE_OPENEMU, (int)SPU_BUFFER_BYTES);
|
||||
if(result == -1)
|
||||
{
|
||||
SPU_ChangeSoundCore(SNDCORE_DUMMY, 0);
|
||||
|
@ -187,40 +187,24 @@
|
|||
|
||||
- (NSTimeInterval)frameInterval
|
||||
{
|
||||
return DS_FRAMES_PER_SECOND;
|
||||
return DS_FRAMES_PER_SECOND;
|
||||
}
|
||||
|
||||
#pragma mark Audio
|
||||
|
||||
- (NSUInteger)audioBufferCount
|
||||
{
|
||||
//return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void)getAudioBuffer:(void *)buffer frameCount:(NSUInteger)frameCount bufferIndex:(NSUInteger)index
|
||||
{
|
||||
// TODO: Better integrate the emulator audio with OpenEmu's audio system.
|
||||
//
|
||||
// Right now, we're using the Cocoa port's audio handling code, which works great.
|
||||
// But it's a good idea to not use it for the purposes of proving good code modularity.
|
||||
|
||||
//if (openEmuSoundInterfaceBuffer != NULL)
|
||||
//{
|
||||
// openEmuSoundInterfaceBuffer->read(buffer, frameCount * SPU_SAMPLE_SIZE);
|
||||
//}
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSUInteger)channelCount
|
||||
{
|
||||
//return SPU_NUMBER_CHANNELS;
|
||||
return 0;
|
||||
return SPU_NUMBER_CHANNELS;
|
||||
}
|
||||
|
||||
- (double)audioSampleRate
|
||||
{
|
||||
//return SPU_SAMPLE_RATE;
|
||||
return 0.0;
|
||||
return SPU_SAMPLE_RATE;
|
||||
}
|
||||
|
||||
- (NSUInteger)channelCountForBuffer:(NSUInteger)buffer
|
||||
|
@ -230,8 +214,7 @@
|
|||
|
||||
- (NSUInteger)audioBufferSizeForBuffer:(NSUInteger)buffer
|
||||
{
|
||||
//return (SPU_BUFFER_BYTES * 2);
|
||||
return 0;
|
||||
return (NSUInteger)SPU_BUFFER_BYTES;
|
||||
}
|
||||
|
||||
- (double)audioSampleRateForBuffer:(NSUInteger)buffer
|
||||
|
@ -242,12 +225,12 @@
|
|||
|
||||
#pragma mark Input
|
||||
|
||||
- (void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player
|
||||
- (oneway void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player
|
||||
{
|
||||
input[button] = true;
|
||||
}
|
||||
|
||||
- (void)didReleaseNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player
|
||||
- (oneway void)didReleaseNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player
|
||||
{
|
||||
input[button] = false;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef enum _OENDSButton
|
|||
|
||||
@protocol OENDSSystemResponderClient <OESystemResponderClient, NSObject>
|
||||
|
||||
- (void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
|
||||
- (void)didReleaseNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
|
||||
- (oneway void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
|
||||
- (oneway void)didReleaseNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,10 +15,7 @@
|
|||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _OPENEMUSOUNDINTERFACE_
|
||||
#define _OPENEMUSOUNDINTERFACE_
|
||||
|
||||
#include "../ringbuffer.h"
|
||||
#import <OpenEmuBase/OERingBuffer.h>
|
||||
#include "../../SPU.h"
|
||||
|
||||
#define SNDCORE_OPENEMU 58326
|
||||
|
@ -27,7 +24,12 @@
|
|||
extern SoundInterface_struct SNDOpenEmu;
|
||||
|
||||
// Ring buffer
|
||||
extern RingBuffer *openEmuSoundInterfaceBuffer;
|
||||
extern OERingBuffer *openEmuSoundInterfaceBuffer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// OpenEmu functions for the sound interface
|
||||
int SNDOpenEmuInit(int buffer_size);
|
||||
|
@ -40,4 +42,6 @@ void SNDOpenEmuUnMuteAudio();
|
|||
void SNDOpenEmuSetVolume(int volume);
|
||||
void SNDOpenEmuClearBuffer();
|
||||
|
||||
#endif // _OPENEMUSOUNDINTERFACE_
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -15,11 +15,11 @@
|
|||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "OpenEmuSoundInterface.h"
|
||||
#include "OESoundInterface.h"
|
||||
|
||||
#include "cocoa_globals.h"
|
||||
|
||||
RingBuffer *openEmuSoundInterfaceBuffer = NULL;
|
||||
OERingBuffer *openEmuSoundInterfaceBuffer = nil;
|
||||
|
||||
// Sound interface to the SPU
|
||||
SoundInterface_struct SNDOpenEmu = {
|
||||
|
@ -43,72 +43,49 @@ SoundInterface_struct *SNDCoreList[] = {
|
|||
|
||||
int SNDOpenEmuInit(int buffer_size)
|
||||
{
|
||||
if (openEmuSoundInterfaceBuffer != NULL)
|
||||
{
|
||||
RingBuffer *oldBuffer = openEmuSoundInterfaceBuffer;
|
||||
openEmuSoundInterfaceBuffer = new RingBuffer(buffer_size / SPU_SAMPLE_SIZE, SPU_SAMPLE_SIZE);
|
||||
delete oldBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
openEmuSoundInterfaceBuffer = new RingBuffer(buffer_size / SPU_SAMPLE_SIZE, SPU_SAMPLE_SIZE);
|
||||
}
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
[openEmuSoundInterfaceBuffer setLength:buffer_size];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SNDOpenEmuDeInit()
|
||||
{
|
||||
delete openEmuSoundInterfaceBuffer;
|
||||
openEmuSoundInterfaceBuffer = NULL;
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
}
|
||||
|
||||
int SNDOpenEmuReset()
|
||||
{
|
||||
SNDOpenEmuClearBuffer();
|
||||
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SNDOpenEmuUpdateAudio(s16 *buffer, u32 num_samples)
|
||||
{
|
||||
if (openEmuSoundInterfaceBuffer != NULL)
|
||||
{
|
||||
openEmuSoundInterfaceBuffer->write(buffer, openEmuSoundInterfaceBuffer->getElementSize() * (size_t)num_samples);
|
||||
}
|
||||
[openEmuSoundInterfaceBuffer write:buffer maxLength:num_samples * SPU_SAMPLE_SIZE];
|
||||
}
|
||||
|
||||
u32 SNDOpenEmuGetAudioSpace()
|
||||
{
|
||||
u32 availableSamples = 0;
|
||||
|
||||
if (openEmuSoundInterfaceBuffer != NULL)
|
||||
{
|
||||
availableSamples = (u32)openEmuSoundInterfaceBuffer->getAvailableElements();
|
||||
}
|
||||
|
||||
return availableSamples;
|
||||
{
|
||||
return (u32)[openEmuSoundInterfaceBuffer usedBytes] / SPU_SAMPLE_SIZE;
|
||||
}
|
||||
|
||||
void SNDOpenEmuMuteAudio()
|
||||
{
|
||||
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
}
|
||||
|
||||
void SNDOpenEmuUnMuteAudio()
|
||||
{
|
||||
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
}
|
||||
|
||||
void SNDOpenEmuSetVolume(int volume)
|
||||
{
|
||||
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
}
|
||||
|
||||
void SNDOpenEmuClearBuffer()
|
||||
{
|
||||
if (openEmuSoundInterfaceBuffer != NULL)
|
||||
{
|
||||
openEmuSoundInterfaceBuffer->clear();
|
||||
}
|
||||
// Do nothing. The OpenEmu frontend will take care of this.
|
||||
}
|
Loading…
Reference in New Issue