Decouple <cstdint>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef ARCH_HOOKS_H
|
||||
#define ARCH_HOOKS_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
struct lua_State;
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
* underlying timers may be 32-bit, but implementations should try to avoid
|
||||
* wrapping if possible.
|
||||
*/
|
||||
static int64_t GetMicrosecondsSinceStart( bool bAccurate );
|
||||
static std::int64_t GetMicrosecondsSinceStart( bool bAccurate );
|
||||
|
||||
/*
|
||||
* Add file search paths, higher priority first.
|
||||
@@ -130,8 +131,8 @@ public:
|
||||
private:
|
||||
/* This are helpers for GetMicrosecondsSinceStart on systems with a timer
|
||||
* that may loop or move backwards. */
|
||||
static int64_t FixupTimeIfLooped( int64_t usecs );
|
||||
static int64_t FixupTimeIfBackwards( int64_t usecs );
|
||||
static std::int64_t FixupTimeIfLooped( std::int64_t usecs );
|
||||
static std::int64_t FixupTimeIfBackwards( std::int64_t usecs );
|
||||
|
||||
static bool g_bQuitting;
|
||||
static bool g_bToggleWindowed;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ArchHooks.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
* This is a helper for GetMicrosecondsSinceStart on systems with a system
|
||||
* timer that may loop or move backwards.
|
||||
@@ -25,15 +27,15 @@
|
||||
* bAccurate == false.
|
||||
*/
|
||||
|
||||
int64_t ArchHooks::FixupTimeIfLooped( int64_t usecs )
|
||||
std::int64_t ArchHooks::FixupTimeIfLooped( std::int64_t usecs )
|
||||
{
|
||||
static int64_t last = 0;
|
||||
static int64_t offset_us = 0;
|
||||
static std::int64_t last = 0;
|
||||
static std::int64_t offset_us = 0;
|
||||
|
||||
/* The time has wrapped if the last time was very high and the current time is very low. */
|
||||
const int64_t i32BitMaxMs = uint64_t(1) << 32;
|
||||
const int64_t i32BitMaxUs = i32BitMaxMs*1000;
|
||||
const int64_t one_day = uint64_t(24*60*60)*1000000;
|
||||
const std::int64_t i32BitMaxMs = std::uint64_t(1) << 32;
|
||||
const std::int64_t i32BitMaxUs = i32BitMaxMs*1000;
|
||||
const std::int64_t one_day = std::uint64_t(24*60*60)*1000000;
|
||||
if( last > (i32BitMaxUs-one_day) && usecs < one_day )
|
||||
offset_us += i32BitMaxUs;
|
||||
|
||||
@@ -42,10 +44,10 @@ int64_t ArchHooks::FixupTimeIfLooped( int64_t usecs )
|
||||
return usecs + offset_us;
|
||||
}
|
||||
|
||||
int64_t ArchHooks::FixupTimeIfBackwards( int64_t usecs )
|
||||
std::int64_t ArchHooks::FixupTimeIfBackwards( std::int64_t usecs )
|
||||
{
|
||||
static int64_t last = 0;
|
||||
static int64_t offset_us = 0;
|
||||
static std::int64_t last = 0;
|
||||
static std::int64_t offset_us = 0;
|
||||
|
||||
if( usecs < last )
|
||||
{
|
||||
@@ -61,7 +63,7 @@ int64_t ArchHooks::FixupTimeIfBackwards( int64_t usecs )
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -71,7 +73,7 @@ int64_t ArchHooks::FixupTimeIfBackwards( int64_t usecs )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "ProductInfo.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
@@ -160,7 +161,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
float fRam;
|
||||
char ramPower;
|
||||
{
|
||||
uint64_t iRam = 0;
|
||||
std::uint64_t iRam = 0;
|
||||
GET_PARAM( "hw.memsize", iRam );
|
||||
|
||||
fRam = float( double(iRam) / 1073741824.0 );
|
||||
@@ -175,7 +176,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
RString sModel("Unknown");
|
||||
do {
|
||||
char szModel[128];
|
||||
uint64_t iFreq;
|
||||
std::uint64_t iFreq;
|
||||
|
||||
GET_PARAM( "hw.logicalcpu_max", iMaxCPUs );
|
||||
GET_PARAM( "hw.logicalcpu", iCPUs );
|
||||
@@ -257,7 +258,7 @@ bool ArchHooks_MacOSX::GoToURL( RString sUrl )
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
// http://developer.apple.com/qa/qa2004/qa1398.html
|
||||
static double factor = 0.0;
|
||||
@@ -269,7 +270,7 @@ int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
mach_timebase_info( &timeBase );
|
||||
factor = timeBase.numer / ( 1000.0 * timeBase.denom );
|
||||
}
|
||||
return int64_t( mach_absolute_time() * factor );
|
||||
return std::int64_t( mach_absolute_time() * factor );
|
||||
}
|
||||
|
||||
#include "RageFileManager.h"
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "archutils/Common/PthreadHelpers.h"
|
||||
#include "archutils/Unix/EmergencyShutdown.h"
|
||||
#include "archutils/Unix/AssertionHandler.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -86,7 +89,7 @@ static bool EmergencyShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
/* We didn't run the crash handler. Run the default handler, so we can dump core. */
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_TLS)
|
||||
static thread_local int g_iTestTLS = 0;
|
||||
|
||||
@@ -122,14 +125,14 @@ static void TestTLS()
|
||||
namespace
|
||||
{
|
||||
clockid_t g_Clock = CLOCK_REALTIME;
|
||||
|
||||
|
||||
void OpenGetTime()
|
||||
{
|
||||
static bool bInitialized = false;
|
||||
if( bInitialized )
|
||||
return;
|
||||
bInitialized = true;
|
||||
|
||||
|
||||
/* Check whether the clock is actually supported. */
|
||||
timespec ts;
|
||||
if( clock_getres(CLOCK_MONOTONIC, &ts) == -1 )
|
||||
@@ -138,7 +141,7 @@ namespace
|
||||
/* If the resolution is worse than a millisecond, fall back on CLOCK_REALTIME. */
|
||||
if( ts.tv_sec > 0 || ts.tv_nsec > 1000000 )
|
||||
return;
|
||||
|
||||
|
||||
g_Clock = CLOCK_MONOTONIC;
|
||||
}
|
||||
};
|
||||
@@ -149,25 +152,25 @@ clockid_t ArchHooks_Unix::GetClock()
|
||||
return g_Clock;
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
OpenGetTime();
|
||||
|
||||
timespec ts;
|
||||
clock_gettime( g_Clock, &ts );
|
||||
|
||||
int64_t iRet = int64_t(ts.tv_sec) * 1000000 + int64_t(ts.tv_nsec)/1000;
|
||||
std::int64_t iRet = std::int64_t(ts.tv_sec) * 1000000 + std::int64_t(ts.tv_nsec)/1000;
|
||||
if( g_Clock != CLOCK_MONOTONIC )
|
||||
iRet = ArchHooks::FixupTimeIfBackwards( iRet );
|
||||
return iRet;
|
||||
}
|
||||
#else
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
int64_t iRet = int64_t(tv.tv_sec) * 1000000 + int64_t(tv.tv_usec);
|
||||
std::int64_t iRet = std::int64_t(tv.tv_sec) * 1000000 + std::int64_t(tv.tv_usec);
|
||||
ret = FixupTimeIfBackwards( ret );
|
||||
return iRet;
|
||||
}
|
||||
@@ -220,7 +223,7 @@ void ArchHooks_Unix::Init()
|
||||
SignalHandler::OnClose( EmergencyShutdown );
|
||||
|
||||
InstallExceptionHandler();
|
||||
|
||||
|
||||
#if defined(HAVE_TLS) && !defined(BSD)
|
||||
TestTLS();
|
||||
#endif
|
||||
@@ -256,7 +259,7 @@ bool ArchHooks_Unix::GoToURL( RString sUrl )
|
||||
#endif
|
||||
|
||||
static RString LibcVersion()
|
||||
{
|
||||
{
|
||||
char buf[1024] = "(error)";
|
||||
int ret = confstr( _CS_GNU_LIBC_VERSION, buf, sizeof(buf) );
|
||||
if( ret == -1 )
|
||||
@@ -295,7 +298,7 @@ void ArchHooks_Unix::SetTime( tm newtime )
|
||||
newtime.tm_year+1900,
|
||||
newtime.tm_sec );
|
||||
|
||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
||||
int ret = system( sCommand );
|
||||
if( ret == -1 || ret == 127 || !WIFEXITED(ret) || WEXITSTATUS(ret) )
|
||||
LOG->Trace( "'%s' failed", sCommand.c_str() );
|
||||
@@ -341,7 +344,7 @@ RString ArchHooks_Unix::GetClipboard()
|
||||
// property on YOUR window.
|
||||
XConvertSelection( Dpy, XA_CLIPBOARD, XA_STRING, XA_PRIMARY, Win, CurrentTime );
|
||||
// XXX: This seems to always return 1 even when it works. (Success == 0)
|
||||
|
||||
|
||||
// Now we must wait for the clipboard owner to cough it up.
|
||||
// HACK: What we SHOULD do is XSelectInput() for SelectionNotify before
|
||||
// calling XConvertSelection and then block on XWindowEvent(), but that
|
||||
@@ -432,7 +435,7 @@ void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -442,7 +445,7 @@ void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define ARCH_HOOKS_UNIX_H
|
||||
|
||||
#include "ArchHooks.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class ArchHooks_Unix: public ArchHooks
|
||||
{
|
||||
public:
|
||||
@@ -10,7 +13,7 @@ public:
|
||||
void DumpDebugInfo();
|
||||
|
||||
void SetTime( tm newtime );
|
||||
int64_t GetMicrosecondsSinceStart();
|
||||
std::int64_t GetMicrosecondsSinceStart();
|
||||
|
||||
void MountInitialFilesystems( const RString &sDirOfExecutable );
|
||||
float GetDisplayAspectRatio() { return 4.0f/3; }
|
||||
@@ -31,7 +34,7 @@ public:
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -41,7 +44,7 @@ public:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
|
||||
#include "VersionHelpers.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
static HANDLE g_hInstanceMutex;
|
||||
static bool g_bIsMultipleInstance = false;
|
||||
|
||||
void InvalidParameterHandler( const wchar_t *szExpression, const wchar_t *szFunction, const wchar_t *szFile,
|
||||
unsigned int iLine, uintptr_t pReserved )
|
||||
unsigned int iLine, std::uintptr_t pReserved )
|
||||
{
|
||||
FAIL_M( "Invalid parameter" ); //TODO: Make this more informative
|
||||
}
|
||||
@@ -115,7 +117,7 @@ bool ArchHooks_Win32::CheckForMultipleInstances(int argc, char* argv[])
|
||||
cds.dwData = 0;
|
||||
cds.cbData = sAllArgs.size();
|
||||
cds.lpData = (void*)sAllArgs.data();
|
||||
SendMessage(
|
||||
SendMessage(
|
||||
(HWND)hWnd, // HWND hWnd = handle of destination window
|
||||
WM_COPYDATA,
|
||||
(WPARAM)nullptr, // HANDLE OF SENDING WINDOW
|
||||
@@ -141,7 +143,7 @@ void ArchHooks_Win32::SetTime( tm newtime )
|
||||
st.wMinute = (WORD)newtime.tm_min;
|
||||
st.wSecond = (WORD)newtime.tm_sec;
|
||||
st.wMilliseconds = 0;
|
||||
SetLocalTime( &st );
|
||||
SetLocalTime( &st );
|
||||
}
|
||||
|
||||
void ArchHooks_Win32::BoostPriority()
|
||||
@@ -197,12 +199,12 @@ RString ArchHooks_Win32::GetClipboard()
|
||||
// First make sure that the clipboard actually contains a string
|
||||
// (or something stringifiable)
|
||||
if(unlikely( !IsClipboardFormatAvailable( CF_TEXT ) )) return "";
|
||||
|
||||
|
||||
// Yes. All this mess just to gain access to the string stored by the clipboard.
|
||||
// I'm having flashbacks to Berkeley sockets.
|
||||
if(unlikely( !OpenClipboard( nullptr ) ))
|
||||
{ LOG->Warn(werr_ssprintf( GetLastError(), "InputHandler_DirectInput: OpenClipboard() failed" )); return ""; }
|
||||
|
||||
|
||||
hgl = GetClipboardData( CF_TEXT );
|
||||
if(unlikely( hgl == nullptr ))
|
||||
{ LOG->Warn(werr_ssprintf( GetLastError(), "InputHandler_DirectInput: GetClipboardData() failed" )); CloseClipboard(); return ""; }
|
||||
@@ -220,18 +222,18 @@ RString ArchHooks_Win32::GetClipboard()
|
||||
#else
|
||||
ret = RString( lpstr );
|
||||
#endif
|
||||
|
||||
|
||||
// And now we clean up.
|
||||
GlobalUnlock( hgl );
|
||||
CloseClipboard();
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -241,7 +243,7 @@ RString ArchHooks_Win32::GetClipboard()
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "ProductInfo.h"
|
||||
#include "RageFileManager.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// for timeGetTime
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
@@ -25,18 +27,18 @@ static void InitTimer()
|
||||
timeBeginPeriod( 1 );
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
if( !g_bTimerInitialized )
|
||||
InitTimer();
|
||||
|
||||
int64_t ret = timeGetTime() * int64_t(1000);
|
||||
std::int64_t ret = timeGetTime() * std::int64_t(1000);
|
||||
if( bAccurate )
|
||||
{
|
||||
ret = FixupTimeIfLooped( ret );
|
||||
ret = FixupTimeIfBackwards( ret );
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -221,7 +223,7 @@ RString ArchHooks::GetPreferredLanguage()
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -231,7 +233,7 @@ RString ArchHooks::GetPreferredLanguage()
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/input.h>
|
||||
@@ -69,7 +70,7 @@ struct EventDevice
|
||||
|
||||
static std::vector<EventDevice *> g_apEventDevices;
|
||||
|
||||
static bool BitIsSet( const uint8_t *pArray, uint32_t iBit )
|
||||
static bool BitIsSet( const std::uint8_t *pArray, std::uint32_t iBit )
|
||||
{
|
||||
return !!(pArray[iBit/8] & (1<<(iBit%8)));
|
||||
}
|
||||
@@ -98,14 +99,14 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
||||
if( ioctl(m_iFD, EVIOCGVERSION, &iVersion) == -1 )
|
||||
LOG->Warn( "ioctl(EVIOCGVERSION): %s", strerror(errno) );
|
||||
else
|
||||
LOG->Info( "Event driver: v%i.%i.%i", (iVersion >> 16) & 0xFF, (iVersion >> 8) & 0xFF, iVersion & 0xFF );
|
||||
LOG->Info( "Event driver: v%i.%i.%i", (iVersion >> 16) & 0xFF, (iVersion >> 8) & 0xFF, iVersion & 0xFF );
|
||||
}
|
||||
|
||||
char szName[1024];
|
||||
if( ioctl(m_iFD, EVIOCGNAME(sizeof(szName)), szName) == -1 )
|
||||
{
|
||||
LOG->Warn( "ioctl(EVIOCGNAME): %s", strerror(errno) );
|
||||
|
||||
|
||||
m_sName = "(unknown)";
|
||||
}
|
||||
else
|
||||
@@ -125,7 +126,7 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
||||
DevInfo.version, m_sName.c_str() );
|
||||
}
|
||||
|
||||
uint8_t iABSMask[ABS_MAX/8 + 1];
|
||||
std::uint8_t iABSMask[ABS_MAX/8 + 1];
|
||||
memset( iABSMask, 0, sizeof(iABSMask) );
|
||||
if( ioctl(m_iFD, EVIOCGBIT(EV_ABS, sizeof(iABSMask)), iABSMask) < 0 )
|
||||
LOG->Warn( "ioctl(EVIOCGBIT(EV_ABS)): %s", strerror(errno) );
|
||||
@@ -142,12 +143,12 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t iKeyMask[KEY_MAX/8 + 1];
|
||||
std::uint8_t iKeyMask[KEY_MAX/8 + 1];
|
||||
memset( iKeyMask, 0, sizeof(iKeyMask) );
|
||||
if( ioctl(m_iFD, EVIOCGBIT(EV_KEY, sizeof(iKeyMask)), iKeyMask) < 0 )
|
||||
LOG->Warn( "ioctl(EVIOCGBIT(EV_KEY)): %s", strerror(errno) );
|
||||
|
||||
uint8_t iEventTypes[EV_MAX/8];
|
||||
std::uint8_t iEventTypes[EV_MAX/8];
|
||||
memset( iEventTypes, 0, sizeof(iEventTypes) );
|
||||
if( ioctl(m_iFD, EVIOCGBIT(0, EV_MAX), iEventTypes) == -1 )
|
||||
LOG->Warn( "ioctl(EV_MAX): %s", strerror(errno) );
|
||||
@@ -170,7 +171,7 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
||||
|
||||
LOG->Info( " Event types: %s", join(", ", setEventTypes).c_str() );
|
||||
}
|
||||
|
||||
|
||||
int iTotalKeys = 0;
|
||||
for( int i = 0; i < KEY_MAX; ++i )
|
||||
{
|
||||
@@ -273,7 +274,7 @@ InputHandler_Linux_Event::InputHandler_Linux_Event()
|
||||
if( ! g_apEventDevices.empty() ) // LinuxInputManager found at least one valid device for us
|
||||
StartThread();
|
||||
}
|
||||
|
||||
|
||||
InputHandler_Linux_Event::~InputHandler_Linux_Event()
|
||||
{
|
||||
if( m_InputThread.IsCreated() ) StopThread();
|
||||
@@ -310,7 +311,7 @@ bool InputHandler_Linux_Event::TryDevice(RString devfile)
|
||||
g_apEventDevices.push_back( pDev );
|
||||
}
|
||||
if( hotplug ) StartThread();
|
||||
|
||||
|
||||
m_NextDevice = enum_add2(m_NextDevice, 1);
|
||||
m_bDevicesChanged = true;
|
||||
return true;
|
||||
@@ -339,7 +340,7 @@ void InputHandler_Linux_Event::InputThread()
|
||||
fd_set fdset;
|
||||
FD_ZERO( &fdset );
|
||||
int iMaxFD = -1;
|
||||
|
||||
|
||||
for( int i = 0; i < (int) g_apEventDevices.size(); ++i )
|
||||
{
|
||||
int iFD = g_apEventDevices[i]->m_iFD;
|
||||
@@ -400,7 +401,7 @@ void InputHandler_Linux_Event::InputThread()
|
||||
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, enum_add2(JOY_BUTTON_1, iNum), event.value != 0, now) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case EV_ABS: {
|
||||
ASSERT_M( event.code < ABS_MAX, ssprintf("%i", event.code) );
|
||||
DeviceButton neg = g_apEventDevices[i]->aiAbsMappingLow[event.code];
|
||||
@@ -435,7 +436,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
|
||||
EventDevice *pDev = g_apEventDevices[i];
|
||||
vDevicesOut.push_back( InputDeviceInfo(pDev->m_Dev, pDev->m_sName) );
|
||||
}
|
||||
|
||||
|
||||
m_bDevicesChanged = false;
|
||||
}
|
||||
|
||||
@@ -443,7 +444,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
|
||||
* (c) 2003-2008 Glenn Maynard
|
||||
* (c) 2013 Ben "root" Anderson
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -453,7 +454,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
@@ -130,7 +131,7 @@ class InputHandler_SextetStream::Impl
|
||||
handler->ButtonPressed(di);
|
||||
}
|
||||
|
||||
uint8_t stateBuffer[STATE_BUFFER_SIZE];
|
||||
std::uint8_t stateBuffer[STATE_BUFFER_SIZE];
|
||||
std::size_t timeout_ms;
|
||||
RageThread inputThread;
|
||||
bool continueInputThread;
|
||||
@@ -190,7 +191,7 @@ class InputHandler_SextetStream::Impl
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void GetNewState(uint8_t * buffer, RString& line)
|
||||
inline void GetNewState(std::uint8_t * buffer, RString& line)
|
||||
{
|
||||
std::size_t lineLen = line.length();
|
||||
std::size_t i, cursor;
|
||||
@@ -226,10 +227,10 @@ class InputHandler_SextetStream::Impl
|
||||
}
|
||||
}
|
||||
|
||||
inline void ReactToChanges(const uint8_t * newStateBuffer)
|
||||
inline void ReactToChanges(const std::uint8_t * newStateBuffer)
|
||||
{
|
||||
InputDevice id = InputDevice(FIRST_DEVICE);
|
||||
uint8_t changes[STATE_BUFFER_SIZE];
|
||||
std::uint8_t changes[STATE_BUFFER_SIZE];
|
||||
RageTimer now;
|
||||
|
||||
// XOR to find differences
|
||||
@@ -274,7 +275,7 @@ class InputHandler_SextetStream::Impl
|
||||
if(linereader->ReadLine(line)) {
|
||||
LOG->Trace("Got line: '%s'", line.c_str());
|
||||
if(line.length() > 0) {
|
||||
uint8_t newStateBuffer[STATE_BUFFER_SIZE];
|
||||
std::uint8_t newStateBuffer[STATE_BUFFER_SIZE];
|
||||
GetNewState(newStateBuffer, line);
|
||||
ReactToChanges(newStateBuffer);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageInputDevice.h"
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include "PrefsManager.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
typedef int (*thread_create_t)(
|
||||
int (*proc)(void*), void* ctx, uint32_t stack_sz, unsigned int priority);
|
||||
int (*proc)(void*), void* ctx, std::uint32_t stack_sz, unsigned int priority);
|
||||
typedef void (*thread_join_t)(int thread_id, int* result);
|
||||
typedef void (*thread_destroy_t)(int thread_id);
|
||||
|
||||
@@ -24,13 +26,13 @@ static DDRIO_IO_INIT ddrio_io_init;
|
||||
typedef int (*DDRIO_READ_PAD)();
|
||||
static DDRIO_READ_PAD ddrio_io_read_pad;
|
||||
|
||||
typedef int (*DDRIO_SETLIGHTS_P3IO)(uint32_t lights);
|
||||
typedef int (*DDRIO_SETLIGHTS_P3IO)(std::uint32_t lights);
|
||||
static DDRIO_SETLIGHTS_P3IO ddrio_set_lights_p3io;
|
||||
|
||||
typedef int (*DDRIO_SETLIGHTS_EXTIO)(uint32_t lights);
|
||||
typedef int (*DDRIO_SETLIGHTS_EXTIO)(std::uint32_t lights);
|
||||
static DDRIO_SETLIGHTS_EXTIO ddrio_set_lights_extio;
|
||||
|
||||
typedef int (*DDRIO_SETLIGHTS_HDXSPANEL)(uint32_t lights);
|
||||
typedef int (*DDRIO_SETLIGHTS_HDXSPANEL)(std::uint32_t lights);
|
||||
static DDRIO_SETLIGHTS_HDXSPANEL ddrio_set_lights_hdxs_panel;
|
||||
|
||||
typedef int (*DDRIO_FINI)();
|
||||
@@ -65,13 +67,13 @@ static unsigned int crt_thread_shim(void* outer_ctx)
|
||||
|
||||
|
||||
int crt_thread_create(
|
||||
int (*proc)(void*), void* ctx, uint32_t stack_sz, unsigned int priority)
|
||||
int (*proc)(void*), void* ctx, std::uint32_t stack_sz, unsigned int priority)
|
||||
{
|
||||
|
||||
LOG->Trace("crt_thread_create");
|
||||
|
||||
struct shim_ctx sctx;
|
||||
uintptr_t thread_id;
|
||||
std::uintptr_t thread_id;
|
||||
|
||||
sctx.barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
sctx.proc = proc;
|
||||
@@ -92,7 +94,7 @@ void crt_thread_destroy(int thread_id)
|
||||
{
|
||||
LOG->Trace("crt_thread_destroy %d", thread_id);
|
||||
|
||||
CloseHandle((HANDLE)(uintptr_t)thread_id);
|
||||
CloseHandle((HANDLE)(std::uintptr_t)thread_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,11 +102,11 @@ void crt_thread_join(int thread_id, int* result)
|
||||
{
|
||||
LOG->Trace("crt_thread_join %d", thread_id);
|
||||
|
||||
WaitForSingleObject((HANDLE)(uintptr_t)thread_id, INFINITE);
|
||||
WaitForSingleObject((HANDLE)(std::uintptr_t)thread_id, INFINITE);
|
||||
|
||||
if (result)
|
||||
{
|
||||
GetExitCodeThread((HANDLE)(uintptr_t)thread_id, (DWORD*)result);
|
||||
GetExitCodeThread((HANDLE)(std::uintptr_t)thread_id, (DWORD*)result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,14 +197,14 @@ InputHandler_Win32_ddrio::~InputHandler_Win32_ddrio()
|
||||
InputThread.Wait();
|
||||
LOG->Trace( "ddrio thread shut down." );
|
||||
|
||||
|
||||
|
||||
if (ddrio_fini != nullptr)
|
||||
{
|
||||
LOG->Trace("calling ddrio dll fini");
|
||||
ddrio_fini();
|
||||
LOG->Trace("ddrio dll complete");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ int InputHandler_Win32_ddrio::InputThread_Start( void *p )
|
||||
|
||||
void InputHandler_Win32_ddrio::InputThreadMain()
|
||||
{
|
||||
uint32_t prevInput = 0, newInput = 0;
|
||||
std::uint32_t prevInput = 0, newInput = 0;
|
||||
LightsState prevLS = { 0 };
|
||||
LightsState newLS = { 0 };
|
||||
|
||||
@@ -290,7 +292,7 @@ void InputHandler_Win32_ddrio::InputThreadMain()
|
||||
}
|
||||
}
|
||||
|
||||
void InputHandler_Win32_ddrio::PushInputState(uint32_t newInput)
|
||||
void InputHandler_Win32_ddrio::PushInputState(std::uint32_t newInput)
|
||||
{
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
@@ -327,15 +329,15 @@ bool InputHandler_Win32_ddrio::IsLightChange(LightsState prevLS, LightsState new
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_ddrio::PushLightState(LightsState newLS)
|
||||
{
|
||||
uint32_t p3io = 0;
|
||||
uint32_t hdxs = 0;
|
||||
uint32_t extio = 0;
|
||||
std::uint32_t p3io = 0;
|
||||
std::uint32_t hdxs = 0;
|
||||
std::uint32_t extio = 0;
|
||||
|
||||
//lighting state has already been verified to have changed in this method, so create the new one from scratch.
|
||||
|
||||
@@ -383,7 +385,7 @@ void InputHandler_Win32_ddrio::PushLightState(LightsState newLS)
|
||||
/*
|
||||
* (c) 2022 din
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -393,7 +395,7 @@ void InputHandler_Win32_ddrio::PushLightState(LightsState newLS)
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
#include "RageThreads.h"
|
||||
#include "arch/Lights/LightsDriver_Export.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
static bool _ddriodll_loaded = false;
|
||||
|
||||
//we want to use a
|
||||
//we want to use a
|
||||
#define DDRIO_DEVICEID DEVICE_JOY1
|
||||
|
||||
enum p3io_light_bit {
|
||||
@@ -77,7 +79,7 @@ private:
|
||||
static int InputThread_Start( void *p );
|
||||
void InputThreadMain();
|
||||
|
||||
void PushInputState(uint32_t newInput);
|
||||
void PushInputState(std::uint32_t newInput);
|
||||
|
||||
bool IsLightChange(LightsState prevLS, LightsState newLS);
|
||||
void PushLightState(LightsState newLS);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "RageLog.h"
|
||||
#include "LightsDriver_LinuxPacDrive.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" {
|
||||
#include <usb.h>
|
||||
}
|
||||
@@ -77,7 +79,7 @@ void LightsDriver_LinuxPacDrive::Set( const LightsState *ls )
|
||||
{
|
||||
if ( !DeviceHandle ) return;
|
||||
|
||||
uint16_t outb = 0;
|
||||
std::uint16_t outb = 0;
|
||||
|
||||
switch (iLightingOrder) {
|
||||
case 1:
|
||||
@@ -243,13 +245,13 @@ void LightsDriver_LinuxPacDrive::OpenDevice()
|
||||
}
|
||||
}
|
||||
|
||||
void LightsDriver_LinuxPacDrive::WriteDevice(uint16_t out)
|
||||
void LightsDriver_LinuxPacDrive::WriteDevice(std::uint16_t out)
|
||||
{
|
||||
if ( !DeviceHandle ) return;
|
||||
|
||||
// output is within the first 16 bits - accept a
|
||||
// 16-bit arg and cast it, for simplicity's sake.
|
||||
uint32_t data = (out << 16);
|
||||
std::uint32_t data = (out << 16);
|
||||
int expected = sizeof(data);
|
||||
|
||||
int result = usb_control_msg( DeviceHandle, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "LightsDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" {
|
||||
#include <usb.h>
|
||||
}
|
||||
@@ -20,7 +22,7 @@ private:
|
||||
|
||||
void FindDevice();
|
||||
void OpenDevice();
|
||||
void WriteDevice(uint16_t out);
|
||||
void WriteDevice(std::uint16_t out);
|
||||
void CloseDevice();
|
||||
|
||||
struct usb_device *Device;
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
|
||||
#include "arch/Lights/LightsDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class LightsDriver_Linux_Leds : public LightsDriver
|
||||
{
|
||||
private:
|
||||
static const uint8_t LINUX_LED_STATE_ON = 255;
|
||||
static const uint8_t LINUX_LED_STATE_OFF = 0;
|
||||
static const std::uint8_t LINUX_LED_STATE_ON = 255;
|
||||
static const std::uint8_t LINUX_LED_STATE_OFF = 0;
|
||||
static const int LINUX_LED_MAX_DIRECTORY_LENGTH = PATH_MAX;
|
||||
|
||||
const InputScheme *pInput;
|
||||
@@ -61,6 +63,6 @@ public:
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*
|
||||
* i love lamp
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#include "global.h"
|
||||
#include <stdio.h>
|
||||
#include "LightsDriver_Linux_stac.h"
|
||||
#include "GameState.h"
|
||||
#include "Game.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -10,12 +18,6 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include "LightsDriver_Linux_stac.h"
|
||||
#include "GameState.h"
|
||||
#include "Game.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#include <libudev.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/hidraw.h>
|
||||
@@ -23,7 +25,7 @@
|
||||
|
||||
REGISTER_LIGHTS_DRIVER_CLASS2(stac, Linux_stac);
|
||||
|
||||
StacDevice::StacDevice(uint8_t pn)
|
||||
StacDevice::StacDevice(std::uint8_t pn)
|
||||
{
|
||||
memset(outputBuffer, 0x00, sizeof(outputBuffer));
|
||||
|
||||
@@ -175,11 +177,11 @@ void StacDevice::Close()
|
||||
void StacDevice::SetInBuffer(int index, bool lightState)
|
||||
{
|
||||
//the first byte is the report ID, so we offset it here to adjust.
|
||||
uint8_t index_offset = index + 1;
|
||||
std::uint8_t index_offset = index + 1;
|
||||
|
||||
//each index in the array represents a single light,
|
||||
//the light will turn on for any value that isn't 0x00
|
||||
uint8_t val = lightState ? 0xFF : 0x00;
|
||||
std::uint8_t val = lightState ? 0xFF : 0x00;
|
||||
|
||||
//ensure the index is valid and the light value has changed.
|
||||
if (index_offset < STAC_HIDREPORT_SIZE && outputBuffer[index_offset] != val)
|
||||
|
||||
@@ -4,22 +4,24 @@
|
||||
#define LightsDriver_Linux_stac_H
|
||||
|
||||
/*
|
||||
* -------------------------- NOTE --------------------------
|
||||
*
|
||||
* -------------------------- NOTE --------------------------
|
||||
*
|
||||
* This driver needs user read/write access to the icedragon.io stac.
|
||||
* This can be achieved by using a udev rule like this:
|
||||
*
|
||||
*
|
||||
* (player 1 then player 2)
|
||||
* SUBSYSTEMS=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="eb5b", OWNER="dance", GROUP="dance", MODE="0660"
|
||||
* SUBSYSTEMS=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="eb5a", OWNER="dance", GROUP="dance", MODE="0660"
|
||||
*
|
||||
*
|
||||
* Refer to your distrobution's documentation on how to properly apply a udev rule.
|
||||
*
|
||||
* -------------------------- NOTE --------------------------
|
||||
*
|
||||
* -------------------------- NOTE --------------------------
|
||||
*/
|
||||
|
||||
#include "arch/Lights/LightsDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
//static information about the device(s) in question.
|
||||
#define STAC_VID "04d8"
|
||||
#define STAC_PID_P1 "ea4b"
|
||||
@@ -50,12 +52,12 @@ public:
|
||||
const char *devicePath;
|
||||
int fd = -1;
|
||||
|
||||
uint8_t playerNumber = 0;
|
||||
std::uint8_t playerNumber = 0;
|
||||
bool newState = false;
|
||||
|
||||
uint8_t outputBuffer[STAC_HIDREPORT_SIZE];
|
||||
std::uint8_t outputBuffer[STAC_HIDREPORT_SIZE];
|
||||
|
||||
StacDevice(uint8_t pn);
|
||||
StacDevice(std::uint8_t pn);
|
||||
|
||||
void FindDevice();
|
||||
void Connect();
|
||||
@@ -117,4 +119,4 @@ public:
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ class LightsDriver_PacDrive : public LightsDriver
|
||||
public:
|
||||
LightsDriver_PacDrive();
|
||||
virtual ~LightsDriver_PacDrive();
|
||||
|
||||
|
||||
virtual void Set( const LightsState *ls );
|
||||
};
|
||||
|
||||
@@ -25,4 +25,4 @@ class LightsDriver_PacDrive : public LightsDriver
|
||||
* 2014 - twistedsymphony
|
||||
* Created for use with Beware's StepMania 3.9 DDR Extreme Simulation
|
||||
* feel free to reuse and distribute this code
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "SextetUtils.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
// Private members/methods are kept out of the header using an opaque pointer `_impl`.
|
||||
@@ -18,7 +19,7 @@ namespace
|
||||
class Impl
|
||||
{
|
||||
protected:
|
||||
uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||
std::uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||
RageFile * out;
|
||||
|
||||
public:
|
||||
@@ -40,7 +41,7 @@ namespace
|
||||
|
||||
void Set(const LightsState * ls)
|
||||
{
|
||||
uint8_t buffer[FULL_SEXTET_COUNT];
|
||||
std::uint8_t buffer[FULL_SEXTET_COUNT];
|
||||
|
||||
packLine(buffer, ls);
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "windows.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
REGISTER_LIGHTS_DRIVER_CLASS(Win32Serial);
|
||||
|
||||
static Preference<RString> g_sLightsComPort("LightsComPort", "COM54");
|
||||
@@ -68,7 +70,7 @@ LightsDriver_Win32Serial::~LightsDriver_Win32Serial()
|
||||
void LightsDriver_Win32Serial::Set(const LightsState* ls)
|
||||
{
|
||||
if (serialPort != INVALID_HANDLE_VALUE) {
|
||||
uint8_t buffer[FULL_SEXTET_COUNT];
|
||||
std::uint8_t buffer[FULL_SEXTET_COUNT];
|
||||
|
||||
packLine(buffer, ls);
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
#include "LightsDriver.h"
|
||||
#include "SextetUtils.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class LightsDriver_Win32Serial : public LightsDriver
|
||||
{
|
||||
protected:
|
||||
uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||
std::uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||
public:
|
||||
LightsDriver_Win32Serial();
|
||||
virtual ~LightsDriver_Win32Serial();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "LightsDriver.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
* Utility functions that both `LightsDriver_Win32Serial` and `LightsDriver_SextetStream`
|
||||
@@ -22,7 +23,7 @@ static const std::size_t FULL_SEXTET_COUNT = CABINET_SEXTET_COUNT + (NUM_GameCon
|
||||
// Encodes the low 6 bits of a byte as a printable, non-space ASCII
|
||||
// character (i.e., within the range 0x21-0x7E) such that the low 6 bits of
|
||||
// the character are the same as the input.
|
||||
inline uint8_t printableSextet(uint8_t data)
|
||||
inline std::uint8_t printableSextet(std::uint8_t data)
|
||||
{
|
||||
// Maps the 6-bit value into the range 0x30-0x6F, wrapped in such a way
|
||||
// that the low 6 bits of the result are the same as the data (so
|
||||
@@ -37,13 +38,13 @@ inline uint8_t printableSextet(uint8_t data)
|
||||
// the top two bits T of the input like so:
|
||||
// H = ((T + 1) mod 4) + 3
|
||||
|
||||
return ((data + (uint8_t)0x10) & (uint8_t)0x3F) + (uint8_t)0x30;
|
||||
return ((data + (std::uint8_t)0x10) & (std::uint8_t)0x3F) + (std::uint8_t)0x30;
|
||||
}
|
||||
|
||||
// Packs 6 booleans into a 6-bit value
|
||||
inline uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||
inline std::uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||
{
|
||||
return (uint8_t)(
|
||||
return (std::uint8_t)(
|
||||
(b0 ? 0x01 : 0) |
|
||||
(b1 ? 0x02 : 0) |
|
||||
(b2 ? 0x04 : 0) |
|
||||
@@ -53,13 +54,13 @@ inline uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool
|
||||
}
|
||||
|
||||
// Packs 6 booleans into a printable sextet
|
||||
inline uint8_t packPrintableSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||
inline std::uint8_t packPrintableSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||
{
|
||||
return printableSextet(packPlainSextet(b0, b1, b2, b3, b4, b5));
|
||||
}
|
||||
|
||||
// Packs the cabinet lights into a printable sextet and adds it to a buffer
|
||||
inline std::size_t packCabinetLights(const LightsState* ls, uint8_t* buffer)
|
||||
inline std::size_t packCabinetLights(const LightsState* ls, std::uint8_t* buffer)
|
||||
{
|
||||
buffer[0] = packPrintableSextet(
|
||||
ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT],
|
||||
@@ -73,7 +74,7 @@ inline std::size_t packCabinetLights(const LightsState* ls, uint8_t* buffer)
|
||||
|
||||
// Packs the button lights for a controller into 6 printable sextets and
|
||||
// adds them to a buffer
|
||||
inline std::size_t packControllerLights(const LightsState* ls, GameController gc, uint8_t* buffer)
|
||||
inline std::size_t packControllerLights(const LightsState* ls, GameController gc, std::uint8_t* buffer)
|
||||
{
|
||||
// Menu buttons
|
||||
buffer[0] = packPrintableSextet(
|
||||
@@ -126,7 +127,7 @@ inline std::size_t packControllerLights(const LightsState* ls, GameController gc
|
||||
return CONTROLLER_SEXTET_COUNT;
|
||||
}
|
||||
|
||||
inline std::size_t packLine(uint8_t* buffer, const LightsState* ls)
|
||||
inline std::size_t packLine(std::uint8_t* buffer, const LightsState* ls)
|
||||
{
|
||||
std::size_t index = 0;
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "RageSurface_Load.h"
|
||||
#include "LoadingWindow_Gtk.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GtkWidget *label;
|
||||
@@ -75,7 +77,7 @@ void LoadingWindow_Gtk::SetText( RString s )
|
||||
|
||||
static void DeletePixels( guchar *pixels, gpointer data )
|
||||
{
|
||||
delete[] (uint8_t *)pixels;
|
||||
delete[] (std::uint8_t *)pixels;
|
||||
}
|
||||
|
||||
static GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
|
||||
@@ -149,7 +151,7 @@ void LoadingWindow_Gtk::SetIndeterminate( bool indeterminate )
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard, Sean Burke
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -159,7 +161,7 @@ void LoadingWindow_Gtk::SetIndeterminate( bool indeterminate )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
|
||||
#include "LowLevelWindow.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <objc/objc.h>
|
||||
|
||||
typedef const struct __CFDictionary *CFDictionaryRef;
|
||||
typedef uint32_t CGDirectDisplayID;
|
||||
typedef std::uint32_t CGDirectDisplayID;
|
||||
|
||||
class LowLevelWindow_MacOSX : public LowLevelWindow
|
||||
{
|
||||
@@ -21,7 +24,7 @@ public:
|
||||
LowLevelWindow_MacOSX();
|
||||
~LowLevelWindow_MacOSX();
|
||||
void *GetProcAddress( RString s );
|
||||
RString TryVideoMode( const VideoModeParams& p, bool& newDeviceOut );
|
||||
RString TryVideoMode( const VideoModeParams& p, bool& newDeviceOut );
|
||||
void GetDisplaySpecs( DisplaySpecs &specs ) const;
|
||||
|
||||
void SwapBuffers();
|
||||
@@ -51,7 +54,7 @@ private:
|
||||
/*
|
||||
* (c) 2005-2006, 2008 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -61,7 +64,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#import "arch/ArchHooks/ArchHooks.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <OpenGL/OpenGL.h>
|
||||
@@ -189,7 +190,7 @@ public:
|
||||
RenderTarget_MacOSX( id shareContext );
|
||||
~RenderTarget_MacOSX();
|
||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_iTexHandle); }
|
||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_iTexHandle); }
|
||||
void StartRenderingTo();
|
||||
void FinishRenderingTo();
|
||||
|
||||
@@ -325,11 +326,11 @@ void *LowLevelWindow_MacOSX::GetProcAddress( RString s )
|
||||
// http://developer.apple.com/qa/qa2001/qa1188.html
|
||||
// Both functions mentioned in there are deprecated in 10.4.
|
||||
const RString& symbolName( '_' + s );
|
||||
const uint32_t count = _dyld_image_count();
|
||||
const std::uint32_t count = _dyld_image_count();
|
||||
NSSymbol symbol = nil;
|
||||
const uint32_t options = NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
|
||||
const std::uint32_t options = NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
|
||||
|
||||
for( uint32_t i = 0; i < count && !symbol; ++i )
|
||||
for( std::uint32_t i = 0; i < count && !symbol; ++i )
|
||||
symbol = NSLookupSymbolInImage( _dyld_get_image_header(i), symbolName, options );
|
||||
return symbol ? NSAddressOfSymbol( symbol ) : nil;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "RageDisplay_OGL_Helpers.h"
|
||||
#include "RageDisplay_OGL.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
static PIXELFORMATDESCRIPTOR g_CurrentPixelFormat;
|
||||
@@ -129,7 +131,7 @@ void DumpPixelFormat( const PIXELFORMATDESCRIPTOR &pfd )
|
||||
RString LowLevelWindow_Win32::TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut )
|
||||
{
|
||||
//LOG->Warn( "LowLevelWindow_Win32::TryVideoMode" );
|
||||
|
||||
|
||||
ASSERT_M( p.bpp == 16 || p.bpp == 32, ssprintf("%i", p.bpp) );
|
||||
|
||||
bNewDeviceOut = false;
|
||||
@@ -323,10 +325,10 @@ public:
|
||||
virtual ~RenderTarget_Win32();
|
||||
|
||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_texHandle); }
|
||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_texHandle); }
|
||||
void StartRenderingTo();
|
||||
void FinishRenderingTo();
|
||||
|
||||
|
||||
virtual bool InvertY() const { return true; }
|
||||
|
||||
private:
|
||||
@@ -415,7 +417,7 @@ void RenderTarget_Win32::FinishRenderingTo()
|
||||
|
||||
BOOL successful = wglMakeCurrent(m_hOldDeviceContext, m_hOldRenderContext);
|
||||
ASSERT_M( successful == TRUE, "wglMakeCurrent failed in RenderTarget_Win32::FinishRenderingTo()" );
|
||||
|
||||
|
||||
m_hOldDeviceContext = 0;
|
||||
m_hOldRenderContext = 0;
|
||||
}
|
||||
@@ -428,7 +430,7 @@ RenderTarget* LowLevelWindow_Win32::CreateRenderTarget()
|
||||
/*
|
||||
* (c) 2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -438,7 +440,7 @@ RenderTarget* LowLevelWindow_Win32::CreateRenderTarget()
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -13,7 +13,9 @@ using namespace RageDisplay_Legacy_Helpers;
|
||||
using namespace X11Helper;
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
#include <GL/glxew.h>
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include <GL/glx.h> // All sorts of stuff...
|
||||
@@ -315,7 +317,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
||||
// If an output name has been specified, search for it
|
||||
RROutput targetOut = None;
|
||||
if (p.sDisplayId.length() > 0) {
|
||||
for (unsigned int i = 0; i < static_cast<uint32_t>(scrRes->noutput) && targetOut == None; ++i) {
|
||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(scrRes->noutput) && targetOut == None; ++i) {
|
||||
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
||||
std::string outName = std::string(outInfo->name, static_cast<unsigned int> (outInfo->nameLen));
|
||||
if (p.sDisplayId == outName) {
|
||||
@@ -335,7 +337,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
||||
// (it is possible the connection state could be unknown), we'll at least
|
||||
// look for an output with a CRTC driving it
|
||||
RROutput connected = None, hasCrtc = None;
|
||||
for (unsigned int i = 0; i < static_cast<uint32_t>(scrRes->noutput); ++i) {
|
||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(scrRes->noutput); ++i) {
|
||||
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
||||
if (outInfo->connection == RR_Connected) { // Check for CONNECTED state: Connected == 0
|
||||
connected = scrRes->outputs[i];
|
||||
@@ -362,7 +364,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
||||
RRCrtc tgtOutCrtc = tgtOutInfo->crtc;
|
||||
if (tgtOutCrtc == None)
|
||||
{
|
||||
for (unsigned int i = 0; i < static_cast<uint32_t>(tgtOutInfo->ncrtc); ++i)
|
||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(tgtOutInfo->ncrtc); ++i)
|
||||
{
|
||||
XRRCrtcInfo *crtcInfo = XRRGetCrtcInfo( Dpy, scrRes, tgtOutInfo->crtcs[i] );
|
||||
if (crtcInfo->mode == None)
|
||||
@@ -390,7 +392,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
||||
const XRRModeInfo &thisMI = scrRes->modes[i];
|
||||
const unsigned int modeWidth = bPortrait ? thisMI.height : thisMI.width;
|
||||
const unsigned int modeHeight = bPortrait ? thisMI.width : thisMI.height;
|
||||
if (p.width >= 0 && p.height >= 0 && modeWidth == static_cast<uint32_t>(p.width) && modeHeight == static_cast<uint32_t>(p.height)) {
|
||||
if (p.width >= 0 && p.height >= 0 && modeWidth == static_cast<std::uint32_t>(p.width) && modeHeight == static_cast<std::uint32_t>(p.height)) {
|
||||
float fTempRefresh = calcRandRRefresh(thisMI.dotClock, thisMI.hTotal, thisMI.vTotal);
|
||||
float fTempDiff = std::abs(p.rate - fTempRefresh);
|
||||
if ((p.rate != REFRESH_DEFAULT && fTempDiff < fRefreshDiff) ||
|
||||
@@ -660,11 +662,11 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
||||
int nsizes = 0;
|
||||
XRRScreenSize *screenSizes = XRRSizes( Dpy, screenNum, &nsizes);
|
||||
DisplayMode screenCurMode{};
|
||||
for (unsigned int szIdx = 0, mode_idx = 0; nsizes >= 0 && szIdx < static_cast<uint32_t>(nsizes); ++szIdx) {
|
||||
for (unsigned int szIdx = 0, mode_idx = 0; nsizes >= 0 && szIdx < static_cast<std::uint32_t>(nsizes); ++szIdx) {
|
||||
XRRScreenSize &size = screenSizes[szIdx];
|
||||
int nrates = 0;
|
||||
short *rates = XRRRates(Dpy, screenNum, szIdx, &nrates);
|
||||
for (unsigned int rIdx = 0; nrates >=0 && rIdx < static_cast<uint32_t>(nrates); ++rIdx, ++mode_idx) {
|
||||
for (unsigned int rIdx = 0; nrates >=0 && rIdx < static_cast<std::uint32_t>(nrates); ++rIdx, ++mode_idx) {
|
||||
DisplayMode m = {static_cast<unsigned int> (size.width), static_cast<unsigned int> (size.height), static_cast<double> (rates[rIdx])};
|
||||
screenModes.insert(m);
|
||||
if (rates[rIdx] == curRate && szIdx == curSizeId) {
|
||||
@@ -694,7 +696,7 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
||||
}
|
||||
|
||||
// Now, for each output, build a corresponding DisplaySpec
|
||||
for (unsigned int outIdx = 0; outIdx < static_cast<uint32_t>(scrRes->noutput); ++outIdx)
|
||||
for (unsigned int outIdx = 0; outIdx < static_cast<std::uint32_t>(scrRes->noutput); ++outIdx)
|
||||
{
|
||||
XRROutputInfo *outInfo = XRRGetOutputInfo( Dpy, scrRes, scrRes->outputs[outIdx] );
|
||||
if (outInfo->nmode > 0)
|
||||
@@ -717,7 +719,7 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
||||
std::set<DisplayMode> outputSupported;
|
||||
DisplayMode outputCurMode{};
|
||||
RectI outBounds;
|
||||
for (unsigned int modeIdx = 0; modeIdx < static_cast<uint32_t>(outInfo->nmode); ++modeIdx)
|
||||
for (unsigned int modeIdx = 0; modeIdx < static_cast<std::uint32_t>(outInfo->nmode); ++modeIdx)
|
||||
{
|
||||
DisplayMode mode = outputModes[outInfo->modes[modeIdx]];
|
||||
unsigned int modeWidth = bPortrait ? mode.height : mode.width;
|
||||
@@ -758,7 +760,7 @@ public:
|
||||
~RenderTarget_X11();
|
||||
|
||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_iTexHandle); }
|
||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_iTexHandle); }
|
||||
void StartRenderingTo();
|
||||
void FinishRenderingTo();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageLog.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -204,7 +205,7 @@ void MemoryCardDriverThreaded_MacOSX::GetUSBStorageDevices( std::vector<UsbStora
|
||||
|
||||
LOG->Trace( "Found memory card at path: %s.", fs[i].f_mntonname );
|
||||
usbd.SetOsMountDir( fs[i].f_mntonname );
|
||||
usbd.iVolumeSizeMB = int( (uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 );
|
||||
usbd.iVolumeSizeMB = int( (std::uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 );
|
||||
|
||||
// Now we can get some more information from the registry tree.
|
||||
usbd.iBus = GetIntProperty( device, CFSTR("USB Address") );
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* XXX register thread */
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
// Link with the DirectShow base class libraries
|
||||
#if defined(DEBUG)
|
||||
#pragma comment(lib, "baseclasses/debug/strmbasd.lib")
|
||||
#pragma comment(lib, "baseclasses/debug/strmbasd.lib")
|
||||
#else
|
||||
#pragma comment(lib, "baseclasses/release/strmbase.lib")
|
||||
#pragma comment(lib, "baseclasses/release/strmbase.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
#include "archutils/Win32/DirectXHelpers.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <vfw.h> /* for GetVideoCodecDebugInfo */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment(lib, "vfw32.lib")
|
||||
@@ -230,12 +232,12 @@ void MovieTexture_DShow::CheckFrame()
|
||||
// DirectShow feeds us in BGR8
|
||||
RageSurface *pFromDShow = CreateSurfaceFrom(
|
||||
m_iSourceWidth, m_iSourceHeight,
|
||||
24,
|
||||
24,
|
||||
0xFF0000,
|
||||
0x00FF00,
|
||||
0x0000FF,
|
||||
0x000000,
|
||||
(uint8_t *) buffer, m_iSourceWidth*3 );
|
||||
(std::uint8_t *) buffer, m_iSourceWidth*3 );
|
||||
|
||||
/*
|
||||
* Optimization notes:
|
||||
@@ -250,7 +252,7 @@ void MovieTexture_DShow::CheckFrame()
|
||||
*/
|
||||
CHECKPOINT;
|
||||
DISPLAY->UpdateTexture(
|
||||
m_uTexHandle,
|
||||
m_uTexHandle,
|
||||
pFromDShow,
|
||||
0, 0,
|
||||
m_iImageWidth, m_iImageHeight );
|
||||
@@ -296,7 +298,7 @@ RString PrintCodecError( HRESULT hr, RString s )
|
||||
* at the file and try to figure out if it's something
|
||||
* common: DIV3, DIV4, DIV5, XVID, or maybe even MPEG2. */
|
||||
RString err = hr_ssprintf(hr, "%s", s.c_str());
|
||||
return
|
||||
return
|
||||
ssprintf(
|
||||
"There was an error initializing a movie: %s.\n"
|
||||
"Could not locate the DivX video codec.\n"
|
||||
@@ -309,7 +311,7 @@ RString PrintCodecError( HRESULT hr, RString s )
|
||||
RString MovieTexture_DShow::GetActiveFilterList()
|
||||
{
|
||||
RString ret;
|
||||
|
||||
|
||||
IEnumFilters *pEnum = nullptr;
|
||||
HRESULT hr = m_pGB->EnumFilters(&pEnum);
|
||||
if (FAILED(hr))
|
||||
@@ -373,7 +375,7 @@ RString MovieTexture_DShow::Create()
|
||||
if( FAILED( hr = pFTR->FindPin( L"In", &pFTRPinIn ) ) )
|
||||
return hr_ssprintf(hr, "Could not find input pin" );
|
||||
|
||||
CComPtr<IPin> pFSrcPinOut; // Source Filter Output Pin
|
||||
CComPtr<IPin> pFSrcPinOut; // Source Filter Output Pin
|
||||
if( FAILED( hr = pFSrc->FindPin( L"Output", &pFSrcPinOut ) ) )
|
||||
return hr_ssprintf( hr, "Could not find output pin" );
|
||||
|
||||
@@ -427,7 +429,7 @@ RString MovieTexture_DShow::Create()
|
||||
void MovieTexture_DShow::NewData(const char *data)
|
||||
{
|
||||
ASSERT(data);
|
||||
|
||||
|
||||
/* Try to lock. */
|
||||
if( buffer_lock.TryWait() )
|
||||
{
|
||||
@@ -557,7 +559,7 @@ void MovieTexture_DShow::SetPlaybackRate( float fRate )
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -567,7 +569,7 @@ void MovieTexture_DShow::SetPlaybackRate( float fRate )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
static void FixLilEndian()
|
||||
{
|
||||
@@ -384,7 +385,7 @@ static RString averr_ssprintf( int err, const char *fmt, ... )
|
||||
return s + " (" + Error + ")";
|
||||
}
|
||||
|
||||
static int AVIORageFile_ReadPacket( void *opaque, uint8_t *buf, int buf_size )
|
||||
static int AVIORageFile_ReadPacket( void *opaque, std::uint8_t *buf, int buf_size )
|
||||
{
|
||||
RageFile *f = (RageFile *)opaque;
|
||||
int n = f->Read( buf, buf_size );
|
||||
@@ -393,7 +394,7 @@ static int AVIORageFile_ReadPacket( void *opaque, uint8_t *buf, int buf_size )
|
||||
return n;
|
||||
}
|
||||
|
||||
static int64_t AVIORageFile_Seek( void *opaque, int64_t offset, int whence )
|
||||
static std::int64_t AVIORageFile_Seek( void *opaque, std::int64_t offset, int whence )
|
||||
{
|
||||
RageFile *f = (RageFile *)opaque;
|
||||
if( whence == AVSEEK_SIZE )
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#define RAGE_MOVIE_TEXTURE_FFMPEG_H
|
||||
|
||||
#include "MovieTexture_Generic.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct RageSurface;
|
||||
|
||||
namespace avcodec
|
||||
@@ -90,7 +93,7 @@ private:
|
||||
static struct AVPixelFormat_t
|
||||
{
|
||||
int bpp;
|
||||
uint32_t masks[4];
|
||||
std::uint32_t masks[4];
|
||||
avcodec::AVPixelFormat pf;
|
||||
bool bHighColor;
|
||||
bool bByteSwapOnLittleEndian;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Sprite.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
@@ -147,7 +148,7 @@ public:
|
||||
|
||||
virtual void Invalidate() { m_uTexHandle = 0; }
|
||||
virtual void Reload() { }
|
||||
virtual uintptr_t GetTexHandle() const
|
||||
virtual std::uintptr_t GetTexHandle() const
|
||||
{
|
||||
return m_uTexHandle;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ private:
|
||||
delete pSurface;
|
||||
}
|
||||
|
||||
uintptr_t m_uTexHandle;
|
||||
std::uintptr_t m_uTexHandle;
|
||||
RageSurfaceFormat m_SurfaceFormat;
|
||||
RagePixelFormat m_PixFmt;
|
||||
};
|
||||
@@ -451,7 +452,7 @@ void MovieTexture_Generic::UpdateFrame()
|
||||
|
||||
if( m_pTextureLock != nullptr )
|
||||
{
|
||||
uintptr_t iHandle = m_pTextureIntermediate != nullptr? m_pTextureIntermediate->GetTexHandle(): this->GetTexHandle();
|
||||
std::uintptr_t iHandle = m_pTextureIntermediate != nullptr? m_pTextureIntermediate->GetTexHandle(): this->GetTexHandle();
|
||||
m_pTextureLock->Lock( iHandle, m_pSurface );
|
||||
}
|
||||
|
||||
@@ -520,7 +521,7 @@ void MovieTexture_Generic::SetPosition( float fSeconds )
|
||||
m_bWantRewind = true;
|
||||
}
|
||||
|
||||
uintptr_t MovieTexture_Generic::GetTexHandle() const
|
||||
std::uintptr_t MovieTexture_Generic::GetTexHandle() const
|
||||
{
|
||||
if( m_pRenderTarget != nullptr )
|
||||
return m_pRenderTarget->GetTexHandle();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "MovieTexture.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class FFMpeg_Helper;
|
||||
struct RageSurface;
|
||||
struct RageTextureLock;
|
||||
@@ -93,7 +95,7 @@ public:
|
||||
virtual void DecodeSeconds( float fSeconds );
|
||||
virtual void SetPlaybackRate( float fRate ) { m_fRate = fRate; }
|
||||
void SetLooping( bool bLooping=true ) { m_bLoop = bLooping; }
|
||||
uintptr_t GetTexHandle() const;
|
||||
std::uintptr_t GetTexHandle() const;
|
||||
|
||||
static EffectMode GetEffectMode( MovieDecoderPixelFormatYCbCr fmt );
|
||||
|
||||
@@ -110,7 +112,7 @@ private:
|
||||
|
||||
enum State { DECODER_QUIT, DECODER_RUNNING } m_State;
|
||||
|
||||
uintptr_t m_uTexHandle;
|
||||
std::uintptr_t m_uTexHandle;
|
||||
RageTextureRenderTarget *m_pRenderTarget;
|
||||
RageTexture *m_pTextureIntermediate;
|
||||
Sprite *m_pSprite;
|
||||
@@ -137,7 +139,7 @@ private:
|
||||
/*
|
||||
* (c) 2003-2005 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -147,7 +149,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
#include "MovieTexture_Null.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class MovieTexture_Null : public RageMovieTexture {
|
||||
public:
|
||||
MovieTexture_Null(RageTextureID ID);
|
||||
virtual ~MovieTexture_Null();
|
||||
void Invalidate() { texHandle = 0; }
|
||||
uintptr_t GetTexHandle() const { return texHandle; }
|
||||
std::uintptr_t GetTexHandle() const { return texHandle; }
|
||||
void Update(float /* delta */) { }
|
||||
void Reload() { }
|
||||
void SetPosition(float /* seconds */) { }
|
||||
@@ -21,7 +23,7 @@ public:
|
||||
private:
|
||||
bool playing;
|
||||
bool loop;
|
||||
uintptr_t texHandle;
|
||||
std::uintptr_t texHandle;
|
||||
};
|
||||
|
||||
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
||||
@@ -74,7 +76,7 @@ RageMovieTexture *RageMovieTextureDriver_Null::Create( RageTextureID ID, RString
|
||||
/*
|
||||
* (c) 2003 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -84,7 +86,7 @@ RageMovieTexture *RageMovieTextureDriver_Null::Create( RageTextureID ID, RString
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "ALSA9Dynamic.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
@@ -90,7 +91,7 @@ bool Alsa9Buf::SetSWParams()
|
||||
/* If this fails, we might have bound dsnd_pcm_sw_params_set_avail_min to
|
||||
* the old SW API. */
|
||||
// ASSERT( err <= 0 );
|
||||
|
||||
|
||||
/* Disable SND_PCM_STATE_XRUN. */
|
||||
snd_pcm_uframes_t boundary = 0;
|
||||
err = dsnd_pcm_sw_params_get_boundary( swparams, &boundary );
|
||||
@@ -138,7 +139,7 @@ static RString DeviceName()
|
||||
|
||||
void Alsa9Buf::GetSoundCardDebugInfo()
|
||||
{
|
||||
static bool done = false;
|
||||
static bool done = false;
|
||||
if( done )
|
||||
return;
|
||||
done = true;
|
||||
@@ -204,7 +205,7 @@ void Alsa9Buf::GetSoundCardDebugInfo()
|
||||
|
||||
if( card == 0 )
|
||||
LOG->Info( "No ALSA sound cards were found.");
|
||||
|
||||
|
||||
if( !PREFSMAN->m_iSoundDevice.Get().empty() )
|
||||
LOG->Info( "ALSA device overridden to \"%s\"", PREFSMAN->m_iSoundDevice.Get().c_str() );
|
||||
}
|
||||
@@ -231,11 +232,11 @@ RString Alsa9Buf::Init( int channels_,
|
||||
samplerate = 44100;
|
||||
else
|
||||
samplerate = iSampleRate;
|
||||
|
||||
|
||||
GetSoundCardDebugInfo();
|
||||
|
||||
|
||||
InitializeErrorHandler();
|
||||
|
||||
|
||||
/* Open the device. */
|
||||
int err;
|
||||
err = dsnd_pcm_open( &pcm, DeviceName(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK );
|
||||
@@ -277,7 +278,7 @@ int Alsa9Buf::GetNumFramesToFill()
|
||||
int ActualWriteahead = std::max( writeahead, chunksize*2 );
|
||||
|
||||
snd_pcm_sframes_t avail_frames = dsnd_pcm_avail_update(pcm);
|
||||
|
||||
|
||||
int total_frames = writeahead;
|
||||
if( avail_frames > total_frames )
|
||||
{
|
||||
@@ -297,7 +298,7 @@ int Alsa9Buf::GetNumFramesToFill()
|
||||
dsnd_pcm_forward( pcm, size );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( avail_frames < 0 )
|
||||
avail_frames = dsnd_pcm_avail_update(pcm);
|
||||
|
||||
@@ -336,7 +337,7 @@ bool Alsa9Buf::WaitUntilFramesCanBeFilled( int timeout_ms )
|
||||
return err == 1;
|
||||
}
|
||||
|
||||
void Alsa9Buf::Write( const int16_t *buffer, int frames )
|
||||
void Alsa9Buf::Write( const std::int16_t *buffer, int frames )
|
||||
{
|
||||
/* We should be able to write it all. If we don't, treat it as an error. */
|
||||
int wrote;
|
||||
@@ -387,7 +388,7 @@ bool Alsa9Buf::Recover( int r )
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t Alsa9Buf::GetPosition() const
|
||||
std::int64_t Alsa9Buf::GetPosition() const
|
||||
{
|
||||
if( dsnd_pcm_state(pcm) == SND_PCM_STATE_PREPARED )
|
||||
return last_cursor_pos;
|
||||
@@ -420,7 +421,7 @@ RString Alsa9Buf::GetHardwareID( RString name )
|
||||
|
||||
if( name.empty() )
|
||||
name = DeviceName();
|
||||
|
||||
|
||||
snd_ctl_t *handle;
|
||||
int err;
|
||||
err = dsnd_ctl_open( &handle, name, 0 );
|
||||
@@ -443,7 +444,7 @@ RString Alsa9Buf::GetHardwareID( RString name )
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -453,7 +454,7 @@ RString Alsa9Buf::GetHardwareID( RString name )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef ALSA9_HELPERS_H
|
||||
#define ALSA9_HELPERS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.h>
|
||||
@@ -11,7 +13,7 @@ private:
|
||||
int channels, samplebits;
|
||||
unsigned samplerate;
|
||||
int buffersize;
|
||||
int64_t last_cursor_pos;
|
||||
std::int64_t last_cursor_pos;
|
||||
|
||||
snd_pcm_uframes_t preferred_writeahead, preferred_chunksize;
|
||||
snd_pcm_uframes_t writeahead, chunksize;
|
||||
@@ -23,37 +25,37 @@ private:
|
||||
bool SetSWParams();
|
||||
|
||||
static void ErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...);
|
||||
|
||||
|
||||
public:
|
||||
static void InitializeErrorHandler();
|
||||
static void GetSoundCardDebugInfo();
|
||||
static RString GetHardwareID( RString name="" );
|
||||
|
||||
|
||||
Alsa9Buf();
|
||||
RString Init( int channels,
|
||||
int iWriteahead,
|
||||
int iChunkSize,
|
||||
int iSampleRate );
|
||||
~Alsa9Buf();
|
||||
|
||||
|
||||
int GetNumFramesToFill();
|
||||
bool WaitUntilFramesCanBeFilled( int timeout_ms );
|
||||
void Write( const int16_t *buffer, int frames );
|
||||
|
||||
void Write( const std::int16_t *buffer, int frames );
|
||||
|
||||
void Play();
|
||||
void Stop();
|
||||
void SetVolume(float vol);
|
||||
int GetSampleRate() const { return samplerate; }
|
||||
|
||||
int64_t GetPosition() const;
|
||||
int64_t GetPlayPos() const { return last_cursor_pos; }
|
||||
std::int64_t GetPosition() const;
|
||||
std::int64_t GetPlayPos() const { return last_cursor_pos; }
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -63,7 +65,7 @@ public:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "archutils/Win32/GetFileInformation.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <mmsystem.h>
|
||||
@@ -558,7 +559,7 @@ void DSoundBuf::release_output_buf( char *pBuffer, unsigned iBufferSize )
|
||||
m_bBufferLocked = false;
|
||||
}
|
||||
|
||||
int64_t DSoundBuf::GetPosition() const
|
||||
std::int64_t DSoundBuf::GetPosition() const
|
||||
{
|
||||
DWORD iCursor, iJunk;
|
||||
HRESULT hr = m_pBuffer->GetCurrentPosition( &iCursor, &iJunk );
|
||||
@@ -588,7 +589,7 @@ int64_t DSoundBuf::GetPosition() const
|
||||
if( iFramesBehind < 0 )
|
||||
iFramesBehind += buffersize_frames(); /* unwrap */
|
||||
|
||||
int64_t iRet = m_iWriteCursorPos - iFramesBehind;
|
||||
std::int64_t iRet = m_iWriteCursorPos - iFramesBehind;
|
||||
|
||||
/* Failsafe: never return a value smaller than we've already returned.
|
||||
* This can happen once in a while in underrun conditions. */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef DSOUND_HELPERS
|
||||
#define DSOUND_HELPERS 1
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <windows.h>
|
||||
#include <wtypes.h>
|
||||
@@ -36,7 +38,7 @@ public:
|
||||
enum { DYNAMIC_SAMPLERATE = -1 };
|
||||
|
||||
DSoundBuf();
|
||||
RString Init( DSound &ds, hw hardware,
|
||||
RString Init( DSound &ds, hw hardware,
|
||||
int iChannels, int iSampleRate, int iSampleBits, int iWriteAhead );
|
||||
|
||||
bool get_output_buf( char **pBuffer, unsigned *iBuffersize, int iChunksize );
|
||||
@@ -49,8 +51,8 @@ public:
|
||||
int GetSampleRate() const { return m_iSampleRate; }
|
||||
|
||||
~DSoundBuf();
|
||||
int64_t GetPosition() const;
|
||||
int64_t GetOutputPosition() const { return m_iWriteCursorPos; }
|
||||
std::int64_t GetPosition() const;
|
||||
std::int64_t GetOutputPosition() const { return m_iWriteCursorPos; }
|
||||
|
||||
private:
|
||||
int buffersize_frames() const { return m_iBufferSize / bytes_per_frame(); }
|
||||
@@ -65,11 +67,11 @@ private:
|
||||
int m_iVolume;
|
||||
|
||||
int m_iBufferSize;
|
||||
|
||||
|
||||
int m_iWriteCursor, m_iBufferBytesFilled; /* bytes */
|
||||
int m_iExtraWriteahead;
|
||||
int64_t m_iWriteCursorPos; /* frames */
|
||||
mutable int64_t m_iLastPosition;
|
||||
std::int64_t m_iWriteCursorPos; /* frames */
|
||||
mutable std::int64_t m_iLastPosition;
|
||||
bool m_bPlaying;
|
||||
|
||||
bool m_bBufferLocked;
|
||||
@@ -85,7 +87,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -95,7 +97,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "RageTimer.h"
|
||||
#include "RageUtil_CircularBuffer.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RageSoundBase;
|
||||
class RageTimer;
|
||||
class RageSoundMixBuffer;
|
||||
@@ -35,7 +37,7 @@ public:
|
||||
|
||||
/* A RageSound calls this to request it not be played. When this function
|
||||
* returns, snd is no longer valid; ensure no running threads are still
|
||||
* accessing it before returning. This must handle gracefully the case where
|
||||
* accessing it before returning. This must handle gracefully the case where
|
||||
* snd was not actually being played, though it may print a warning. */
|
||||
void StopMixing( RageSoundBase *pSound );
|
||||
|
||||
@@ -48,8 +50,8 @@ public:
|
||||
|
||||
/* Get the current hardware frame position, in the same time base as passed to
|
||||
* RageSound::CommitPlayingPosition. */
|
||||
int64_t GetHardwareFrame( RageTimer *pTimer ) const;
|
||||
virtual int64_t GetPosition() const = 0;
|
||||
std::int64_t GetHardwareFrame( RageTimer *pTimer ) const;
|
||||
virtual std::int64_t GetPosition() const = 0;
|
||||
void low_sample_count_workaround();
|
||||
|
||||
/* When a sound is finished playing (GetDataToPlay returns 0) and the sound has
|
||||
@@ -77,7 +79,7 @@ protected:
|
||||
* at once. This should generally be slightly larger than the sound writeahead,
|
||||
* to allow filling the buffer after an underrun. The default is 4096 frames. */
|
||||
void SetDecodeBufferSize( int frames );
|
||||
|
||||
|
||||
/* Override this to set the priority of the decoding thread, which should be above
|
||||
* normal priority but not realtime. */
|
||||
virtual void SetupDecodingThread() { }
|
||||
@@ -95,10 +97,10 @@ protected:
|
||||
* This function only mixes data; it will not lock any mutexes or do any file access, and
|
||||
* is safe to call from a realtime thread.
|
||||
*/
|
||||
void Mix( int16_t *pBuf, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame );
|
||||
void Mix( float *pBuf, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame );
|
||||
void Mix( std::int16_t *pBuf, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame );
|
||||
void Mix( float *pBuf, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame );
|
||||
|
||||
void MixDeinterlaced( float **pBufs, int iChannels, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame );
|
||||
void MixDeinterlaced( float **pBufs, int iChannels, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame );
|
||||
|
||||
private:
|
||||
/* This mutex is used for serializing with the decoder thread. Locking this mutex
|
||||
@@ -133,13 +135,13 @@ private:
|
||||
* HALTING: The main thread has called StopMixing or the data buffer is empty. The mixing
|
||||
* thread will flush any remaining buffered data without playing it, and then move the
|
||||
* sound to STOPPED.
|
||||
*
|
||||
*
|
||||
* The mixing thread operates without any locks. This can lead to a little overlap. For
|
||||
* example, if StopMixing() is called, moving the sound from PLAYING to HALTING, the mixing
|
||||
* thread might be in the middle of mixing data. Although HALTING means "discard buffered
|
||||
* data", some data will still be mixed. This is OK; the data is valid, and the flush will
|
||||
* happen on the next iteration.
|
||||
*
|
||||
*
|
||||
* The only state change made by the decoding thread is on EOF: the state is changed
|
||||
* from PLAYING to STOPPING. This is done while m_Mutex is held, to prevent
|
||||
* races with other threads.
|
||||
@@ -155,9 +157,9 @@ private:
|
||||
float m_Buffer[samples_per_block];
|
||||
float *m_BufferNext; // beginning of the unread data
|
||||
int m_FramesInBuffer; // total number of frames at m_BufferNext
|
||||
int64_t m_iPosition; // stream frame of m_BufferNext
|
||||
std::int64_t m_iPosition; // stream frame of m_BufferNext
|
||||
sound_block(): m_BufferNext(m_Buffer),
|
||||
m_FramesInBuffer(0), m_iPosition(0) {}
|
||||
m_FramesInBuffer(0), m_iPosition(0) {}
|
||||
};
|
||||
|
||||
struct Sound
|
||||
@@ -175,8 +177,8 @@ private:
|
||||
struct QueuedPosMap
|
||||
{
|
||||
int iFrames;
|
||||
int64_t iStreamFrame;
|
||||
int64_t iHardwareFrame;
|
||||
std::int64_t iStreamFrame;
|
||||
std::int64_t iHardwareFrame;
|
||||
};
|
||||
|
||||
CircBuf<QueuedPosMap> m_PosMapQueue;
|
||||
@@ -200,16 +202,16 @@ private:
|
||||
/* List of currently playing sounds: XXX no vector */
|
||||
Sound m_Sounds[32];
|
||||
|
||||
int64_t ClampHardwareFrame( int64_t iHardwareFrame ) const;
|
||||
mutable int64_t m_iMaxHardwareFrame;
|
||||
mutable int64_t m_iVMaxHardwareFrame;
|
||||
mutable int32_t soundDriverMaxSamples = 0;
|
||||
std::int64_t ClampHardwareFrame( std::int64_t iHardwareFrame ) const;
|
||||
mutable std::int64_t m_iMaxHardwareFrame;
|
||||
mutable std::int64_t m_iVMaxHardwareFrame;
|
||||
mutable std::int32_t soundDriverMaxSamples = 0;
|
||||
|
||||
bool m_bShutdownDecodeThread;
|
||||
|
||||
static int DecodeThread_start( void *p );
|
||||
void DecodeThread();
|
||||
RageSoundMixBuffer &MixIntoBuffer( int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame );
|
||||
RageSoundMixBuffer &MixIntoBuffer( int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame );
|
||||
RageThread m_DecodeThread;
|
||||
|
||||
int GetDataForSound( Sound &s );
|
||||
@@ -224,7 +226,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -234,7 +236,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "archutils/Unix/GetSysInfo.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
@@ -18,7 +19,7 @@ REGISTER_SOUND_DRIVER_CLASS2( ALSA-sw, ALSA9_Software );
|
||||
|
||||
static const int channels = 2;
|
||||
static const int samples_per_frame = channels;
|
||||
static const int bytes_per_frame = sizeof(int16_t) * samples_per_frame;
|
||||
static const int bytes_per_frame = sizeof(std::int16_t) * samples_per_frame;
|
||||
|
||||
/* Linux 2.6 has a fine-grained scheduler. We can almost always use a smaller buffer
|
||||
* size than in 2.4. XXX: Some cards can handle smaller buffer sizes than others. */
|
||||
@@ -53,7 +54,7 @@ bool RageSoundDriver_ALSA9_Software::GetData()
|
||||
if( frames_to_fill <= 0 )
|
||||
return false;
|
||||
|
||||
static int16_t *buf = nullptr;
|
||||
static std::int16_t *buf = nullptr;
|
||||
static int bufsize = 0;
|
||||
if( buf && bufsize < frames_to_fill )
|
||||
{
|
||||
@@ -62,12 +63,12 @@ bool RageSoundDriver_ALSA9_Software::GetData()
|
||||
}
|
||||
if( !buf )
|
||||
{
|
||||
buf = new int16_t[frames_to_fill*samples_per_frame];
|
||||
buf = new std::int16_t[frames_to_fill*samples_per_frame];
|
||||
bufsize = frames_to_fill;
|
||||
}
|
||||
|
||||
const int64_t play_pos = m_pPCM->GetPlayPos();
|
||||
const int64_t cur_play_pos = m_pPCM->GetPosition();
|
||||
const std::int64_t play_pos = m_pPCM->GetPlayPos();
|
||||
const std::int64_t cur_play_pos = m_pPCM->GetPosition();
|
||||
|
||||
this->Mix( buf, frames_to_fill, play_pos, cur_play_pos );
|
||||
m_pPCM->Write( buf, frames_to_fill );
|
||||
@@ -76,10 +77,10 @@ bool RageSoundDriver_ALSA9_Software::GetData()
|
||||
}
|
||||
|
||||
|
||||
int64_t RageSoundDriver_ALSA9_Software::GetPosition() const
|
||||
std::int64_t RageSoundDriver_ALSA9_Software::GetPosition() const
|
||||
{
|
||||
return m_pPCM->GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void RageSoundDriver_ALSA9_Software::SetupDecodingThread()
|
||||
{
|
||||
@@ -119,9 +120,9 @@ RString RageSoundDriver_ALSA9_Software::Init()
|
||||
return sError;
|
||||
|
||||
m_iSampleRate = m_pPCM->GetSampleRate();
|
||||
|
||||
|
||||
StartDecodeThread();
|
||||
|
||||
|
||||
m_MixingThread.SetName( "RageSoundDriver_ALSA9_Software" );
|
||||
m_MixingThread.Create( MixerThread_start, this );
|
||||
|
||||
@@ -138,7 +139,7 @@ RageSoundDriver_ALSA9_Software::~RageSoundDriver_ALSA9_Software()
|
||||
m_MixingThread.Wait();
|
||||
LOG->Trace("Mixer thread shut down.");
|
||||
}
|
||||
|
||||
|
||||
delete m_pPCM;
|
||||
|
||||
UnloadALSA();
|
||||
@@ -152,7 +153,7 @@ float RageSoundDriver_ALSA9_Software::GetPlayLatency() const
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -162,7 +163,7 @@ float RageSoundDriver_ALSA9_Software::GetPlayLatency() const
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include "RageSound.h"
|
||||
#include "RageThreads.h"
|
||||
#include "RageSoundDriver.h"
|
||||
|
||||
#include "ALSA9Helpers.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RageSoundDriver_ALSA9_Software: public RageSoundDriver
|
||||
{
|
||||
public:
|
||||
@@ -15,7 +16,7 @@ public:
|
||||
RString Init();
|
||||
|
||||
/* virtuals: */
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
float GetPlayLatency() const;
|
||||
int GetSampleRate() const { return m_iSampleRate; }
|
||||
|
||||
@@ -37,7 +38,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -47,7 +48,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "RageSoundDriver.h"
|
||||
#include "RageThreads.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
|
||||
class RageSoundDriver_AU: public RageSoundDriver
|
||||
@@ -13,11 +16,11 @@ public:
|
||||
~RageSoundDriver_AU();
|
||||
float GetPlayLatency() const;
|
||||
int GetSampleRate() const { return m_iSampleRate; }
|
||||
int64_t GetPosition() const;
|
||||
|
||||
std::int64_t GetPosition() const;
|
||||
|
||||
protected:
|
||||
void SetupDecodingThread();
|
||||
|
||||
|
||||
private:
|
||||
static OSStatus Render( void *inRefCon,
|
||||
AudioUnitRenderActionFlags *ioActionFlags,
|
||||
@@ -41,7 +44,7 @@ private:
|
||||
/*
|
||||
* (c) 2004-2006 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -51,7 +54,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include "RageLog.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "archutils/Darwin/DarwinThreadHelpers.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <AudioToolbox/AudioServices.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
@@ -32,20 +35,20 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
AudioDeviceID OutputDevice;
|
||||
OSStatus error;
|
||||
UInt32 size = sizeof( AudioDeviceID );
|
||||
|
||||
|
||||
if( (error = AudioUnitGetProperty(au, kAudioOutputUnitProperty_CurrentDevice,
|
||||
kAudioUnitScope_Global, 0, &OutputDevice, &size)) )
|
||||
{
|
||||
LOG->Warn("No output device: %s", FormatOSError(error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AudioObjectPropertyAddress RateAddr = {
|
||||
kAudioDevicePropertyNominalSampleRate,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
Float64 rate = 0.0;
|
||||
size = sizeof( Float64 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &RateAddr, 0, NULL, &size, &rate)) )
|
||||
@@ -55,29 +58,29 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
}
|
||||
if( rate == desiredRate )
|
||||
return;
|
||||
|
||||
|
||||
AudioObjectPropertyAddress AvailableRatesAddr = {
|
||||
kAudioDevicePropertyAvailableNominalSampleRates,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
if( (error = AudioObjectGetPropertyDataSize(OutputDevice, &AvailableRatesAddr, 0, nullptr, &size)) )
|
||||
{
|
||||
LOG->Warn("Couldn't get available nominal sample rates info: %s", FormatOSError(error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const int num = size/sizeof(AudioValueRange);
|
||||
AudioValueRange *ranges = new AudioValueRange[num];
|
||||
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &AvailableRatesAddr, 0, NULL, &size, ranges)) )
|
||||
{
|
||||
LOG->Warn("Couldn't get available nominal sample rates: %s", FormatOSError(error));
|
||||
delete[] ranges;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Float64 bestRate = 0.0;
|
||||
for( int i = 0; i < num; ++i )
|
||||
{
|
||||
@@ -89,7 +92,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
/* XXX: If the desired rate is supported by the device, then change it, if not
|
||||
* then we should select the "best" rate. I don't really know what such a best
|
||||
* rate would be. The rate closest to the desired value? A multiple of 2?
|
||||
* For now give up if the desired sample rate isn't available. */
|
||||
* For now give up if the desired sample rate isn't available. */
|
||||
}
|
||||
delete[] ranges;
|
||||
if( bestRate == 0.0 )
|
||||
@@ -104,40 +107,40 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
RString RageSoundDriver_AU::Init()
|
||||
{
|
||||
AudioComponentDescription desc;
|
||||
|
||||
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
desc.componentFlags = 0;
|
||||
desc.componentFlagsMask = 0;
|
||||
|
||||
|
||||
AudioComponent comp = AudioComponentFindNext(NULL, &desc);
|
||||
//Component comp = FindNextComponent( NULL, &desc );
|
||||
|
||||
if( comp == nullptr )
|
||||
|
||||
if( comp == nullptr )
|
||||
return "Failed to find the default output unit.";
|
||||
|
||||
|
||||
OSStatus error = AudioComponentInstanceNew( comp, &m_OutputUnit );
|
||||
|
||||
|
||||
if( error != noErr || m_OutputUnit == nullptr )
|
||||
return ssprintf("Could not open the default output unit: %s", FormatOSError(error));
|
||||
|
||||
|
||||
// Set up a callback function to generate output to the output unit
|
||||
AURenderCallbackStruct input;
|
||||
input.inputProc = Render;
|
||||
input.inputProcRefCon = this;
|
||||
|
||||
error = AudioUnitSetProperty( m_OutputUnit,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
|
||||
error = AudioUnitSetProperty( m_OutputUnit,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input,
|
||||
0,
|
||||
&input,
|
||||
0,
|
||||
&input,
|
||||
sizeof(input) );
|
||||
if( error != noErr )
|
||||
return ssprintf("Failed to set render callback: %s", FormatOSError(error));
|
||||
|
||||
|
||||
AudioStreamBasicDescription streamFormat;
|
||||
|
||||
|
||||
streamFormat.mSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
|
||||
streamFormat.mFormatID = kAudioFormatLinearPCM;
|
||||
streamFormat.mFormatFlags = kFormatFlags;
|
||||
@@ -146,12 +149,12 @@ RString RageSoundDriver_AU::Init()
|
||||
streamFormat.mBytesPerFrame = kBytesPerFrame;
|
||||
streamFormat.mChannelsPerFrame = kChannelsPerFrame;
|
||||
streamFormat.mBitsPerChannel = kBitsPerChannel;
|
||||
|
||||
|
||||
if( streamFormat.mSampleRate <= 0.0 )
|
||||
streamFormat.mSampleRate = 44100.0;
|
||||
m_iSampleRate = int( streamFormat.mSampleRate );
|
||||
m_TimeScale = streamFormat.mSampleRate / AudioGetHostClockFrequency();
|
||||
|
||||
|
||||
// Try to set the hardware sample rate.
|
||||
SetSampleRate( m_OutputUnit, streamFormat.mSampleRate );
|
||||
|
||||
@@ -165,7 +168,7 @@ RString RageSoundDriver_AU::Init()
|
||||
if( error != noErr )
|
||||
return ssprintf("Failed to set AU stream format: %s", FormatOSError(error));
|
||||
UInt32 renderQuality = kRenderQuality_Max;
|
||||
|
||||
|
||||
error = AudioUnitSetProperty( m_OutputUnit,
|
||||
kAudioUnitProperty_RenderQuality,
|
||||
kAudioUnitScope_Global,
|
||||
@@ -174,11 +177,11 @@ RString RageSoundDriver_AU::Init()
|
||||
sizeof(renderQuality) );
|
||||
if( error != noErr )
|
||||
LOG->Warn("Failed to set the maximum render quality: %s", FormatOSError(error));
|
||||
|
||||
|
||||
// Initialize the AU.
|
||||
if( (error = AudioUnitInitialize(m_OutputUnit)) )
|
||||
return ssprintf("Could not initialize the AudioUnit: %s", FormatOSError(error));
|
||||
|
||||
|
||||
StartDecodeThread();
|
||||
|
||||
if( (error = AudioOutputUnitStart(m_OutputUnit)) )
|
||||
@@ -202,9 +205,9 @@ RageSoundDriver_AU::~RageSoundDriver_AU()
|
||||
delete m_pNotificationThread;
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_AU::GetPosition() const
|
||||
std::int64_t RageSoundDriver_AU::GetPosition() const
|
||||
{
|
||||
return int64_t( m_TimeScale * AudioGetCurrentHostTime() );
|
||||
return std::int64_t( m_TimeScale * AudioGetCurrentHostTime() );
|
||||
}
|
||||
|
||||
|
||||
@@ -223,55 +226,55 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
AudioDeviceID OutputDevice;
|
||||
UInt32 size = sizeof( AudioDeviceID );
|
||||
Float64 sampleRate;
|
||||
|
||||
|
||||
if( (error = AudioUnitGetProperty(m_OutputUnit, kAudioOutputUnitProperty_CurrentDevice,
|
||||
kAudioUnitScope_Global, 0, &OutputDevice, &size)) )
|
||||
{
|
||||
LOG->Warn("No output device: %s", FormatOSError(error));
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
AudioObjectPropertyAddress RateAddr = {
|
||||
kAudioDevicePropertyNominalSampleRate,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
size = sizeof( Float64 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &RateAddr, 0, nullptr, &size, &sampleRate)) )
|
||||
{
|
||||
LOG->Warn("Couldn't get the device sample rate: %s", FormatOSError(error));
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
AudioObjectPropertyAddress BufferAddr = {
|
||||
kAudioDevicePropertyBufferFrameSize,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
size = sizeof( UInt32 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &BufferAddr, 0, nullptr, &size, &bufferSize)) )
|
||||
{
|
||||
LOG->Warn("Couldn't determine buffer size: %s", FormatOSError(error));
|
||||
bufferSize = 0;
|
||||
}
|
||||
|
||||
|
||||
UInt32 frames;
|
||||
|
||||
|
||||
AudioObjectPropertyAddress LatencyAddr = {
|
||||
kAudioDevicePropertyLatency,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
size = sizeof( UInt32 );
|
||||
if( (error = AudioObjectGetPropertyData(OutputDevice, &LatencyAddr, 0, nullptr, &size, &frames)) )
|
||||
{
|
||||
LOG->Warn("Couldn't get device latency: %s", FormatOSError(error));
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
|
||||
AudioObjectPropertyAddress SafetyAddr = {
|
||||
kAudioDevicePropertySafetyOffset,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
@@ -294,7 +297,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
if( (error = AudioObjectGetPropertyDataSize(OutputDevice, &StreamsAddr, 0, nullptr, &size)) )
|
||||
{
|
||||
LOG->Warn("Device has no streams: %s", FormatOSError(error));
|
||||
@@ -314,13 +317,13 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
delete[] streams;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
AudioObjectPropertyAddress LatencyAddr = {
|
||||
kAudioDevicePropertyLatency,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyElementWildcard
|
||||
};
|
||||
|
||||
|
||||
if( (error = AudioObjectGetPropertyData(streams[0], &LatencyAddr, 0, nullptr, &size, &frames)) )
|
||||
{
|
||||
LOG->Warn("Stream does not report latency: %s", FormatOSError(error));
|
||||
@@ -329,10 +332,10 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
delete[] streams;
|
||||
bufferSize += frames;
|
||||
} while( false );
|
||||
|
||||
|
||||
return float( bufferSize / sampleRate );
|
||||
}
|
||||
|
||||
|
||||
|
||||
OSStatus RageSoundDriver_AU::Render( void *inRefCon,
|
||||
AudioUnitRenderActionFlags *ioActionFlags,
|
||||
@@ -347,22 +350,22 @@ OSStatus RageSoundDriver_AU::Render( void *inRefCon,
|
||||
This->m_pIOThread = new RageThreadRegister( "HAL I/O thread" );
|
||||
|
||||
AudioBuffer &buf = ioData->mBuffers[0];
|
||||
int64_t now = int64_t( This->m_TimeScale * AudioGetCurrentHostTime() );
|
||||
int64_t next = int64_t( This->m_TimeScale * inTimeStamp->mHostTime );
|
||||
|
||||
std::int64_t now = std::int64_t( This->m_TimeScale * AudioGetCurrentHostTime() );
|
||||
std::int64_t next = std::int64_t( This->m_TimeScale * inTimeStamp->mHostTime );
|
||||
|
||||
This->Mix( (float *)buf.mData, inNumberFrames, next, now );
|
||||
if( unlikely(This->m_bDone) )
|
||||
{
|
||||
AudioOutputUnitStop( This->m_OutputUnit );
|
||||
This->m_Semaphore.Post();
|
||||
}
|
||||
}
|
||||
return noErr;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2004-2007 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -372,7 +375,7 @@ OSStatus RageSoundDriver_AU::Render( void *inRefCon,
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
REGISTER_SOUND_DRIVER_CLASS2( DirectSound-sw, DSound_Software );
|
||||
|
||||
static const int channels = 2;
|
||||
@@ -42,7 +44,7 @@ void RageSoundDriver_DSound_Software::MixerThread()
|
||||
{
|
||||
char *pLockedBuf;
|
||||
unsigned iLen;
|
||||
const int64_t iPlayPos = m_pPCM->GetOutputPosition(); /* must be called before get_output_buf */
|
||||
const std::int64_t iPlayPos = m_pPCM->GetOutputPosition(); /* must be called before get_output_buf */
|
||||
|
||||
if( !m_pPCM->get_output_buf(&pLockedBuf, &iLen, chunksize()) )
|
||||
{
|
||||
@@ -50,7 +52,7 @@ void RageSoundDriver_DSound_Software::MixerThread()
|
||||
continue;
|
||||
}
|
||||
|
||||
this->Mix( (int16_t *) pLockedBuf, iLen/bytes_per_frame, iPlayPos, m_pPCM->GetPosition() );
|
||||
this->Mix( (std::int16_t *) pLockedBuf, iLen/bytes_per_frame, iPlayPos, m_pPCM->GetPosition() );
|
||||
|
||||
m_pPCM->release_output_buf( pLockedBuf, iLen );
|
||||
}
|
||||
@@ -60,7 +62,7 @@ void RageSoundDriver_DSound_Software::MixerThread()
|
||||
m_pPCM->Stop();
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_DSound_Software::GetPosition() const
|
||||
std::int64_t RageSoundDriver_DSound_Software::GetPosition() const
|
||||
{
|
||||
return m_pPCM->GetPosition();
|
||||
}
|
||||
@@ -146,7 +148,7 @@ int RageSoundDriver_DSound_Software::GetSampleRate() const
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -156,7 +158,7 @@ int RageSoundDriver_DSound_Software::GetSampleRate() const
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "RageThreads.h"
|
||||
#include "RageSoundDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RageSoundDriver_DSound_Software: public RageSoundDriver
|
||||
{
|
||||
public:
|
||||
@@ -12,10 +14,10 @@ public:
|
||||
virtual ~RageSoundDriver_DSound_Software();
|
||||
RString Init();
|
||||
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
float GetPlayLatency() const;
|
||||
int GetSampleRate() const;
|
||||
|
||||
|
||||
protected:
|
||||
void SetupDecodingThread();
|
||||
|
||||
@@ -36,7 +38,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -46,7 +48,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "RageSoundReader.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
static const int channels = 2;
|
||||
|
||||
@@ -50,7 +51,7 @@ int RageSoundDriver::DecodeThread_start( void *p )
|
||||
static int g_iTotalAhead = 0;
|
||||
static int g_iTotalAheadCount = 0;
|
||||
|
||||
RageSoundMixBuffer &RageSoundDriver::MixIntoBuffer( int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame )
|
||||
RageSoundMixBuffer &RageSoundDriver::MixIntoBuffer( int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame )
|
||||
{
|
||||
ASSERT_M( m_DecodeThread.IsCreated(), "RageSoundDriver::StartDecodeThread() was never called" );
|
||||
|
||||
@@ -90,9 +91,9 @@ RageSoundMixBuffer &RageSoundDriver::MixIntoBuffer( int iFrames, int64_t iFrameN
|
||||
if( !s.m_StartTime.IsZero() && iCurrentFrame != -1 )
|
||||
{
|
||||
/* If the sound is supposed to start at a time past this buffer, insert silence. */
|
||||
const int64_t iFramesUntilThisBuffer = iFrameNumber - iCurrentFrame;
|
||||
const std::int64_t iFramesUntilThisBuffer = iFrameNumber - iCurrentFrame;
|
||||
const float fSecondsBeforeStart = -s.m_StartTime.Ago();
|
||||
const int64_t iFramesBeforeStart = int64_t(fSecondsBeforeStart * GetSampleRate());
|
||||
const std::int64_t iFramesBeforeStart = std::int64_t(fSecondsBeforeStart * GetSampleRate());
|
||||
const int iSilentFramesInThisBuffer = clamp( int(iFramesBeforeStart-iFramesUntilThisBuffer), 0, iFramesLeft );
|
||||
|
||||
iGotFrames += iSilentFramesInThisBuffer;
|
||||
@@ -160,19 +161,19 @@ RageSoundMixBuffer &RageSoundDriver::MixIntoBuffer( int iFrames, int64_t iFrameN
|
||||
return mix;
|
||||
}
|
||||
|
||||
void RageSoundDriver::Mix( int16_t *pBuf, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame )
|
||||
void RageSoundDriver::Mix( std::int16_t *pBuf, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame )
|
||||
{
|
||||
memset( pBuf, 0, iFrames*channels*sizeof(int16_t) );
|
||||
memset( pBuf, 0, iFrames*channels*sizeof(std::int16_t) );
|
||||
MixIntoBuffer( iFrames, iFrameNumber, iCurrentFrame ).read( pBuf );
|
||||
}
|
||||
|
||||
void RageSoundDriver::Mix( float *pBuf, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame )
|
||||
void RageSoundDriver::Mix( float *pBuf, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame )
|
||||
{
|
||||
memset( pBuf, 0, iFrames*channels*sizeof(float) );
|
||||
MixIntoBuffer( iFrames, iFrameNumber, iCurrentFrame ).read( pBuf );
|
||||
}
|
||||
|
||||
void RageSoundDriver::MixDeinterlaced( float **pBufs, int iChannels, int iFrames, int64_t iFrameNumber, int64_t iCurrentFrame )
|
||||
void RageSoundDriver::MixDeinterlaced( float **pBufs, int iChannels, int iFrames, std::int64_t iFrameNumber, std::int64_t iCurrentFrame )
|
||||
{
|
||||
for (int i = 0; i < iChannels; ++i )
|
||||
memset( pBufs[i], 0, iFrames*sizeof(float) );
|
||||
@@ -473,7 +474,7 @@ RageSoundDriver::~RageSoundDriver()
|
||||
}
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver::ClampHardwareFrame( int64_t iHardwareFrame ) const
|
||||
std::int64_t RageSoundDriver::ClampHardwareFrame( std::int64_t iHardwareFrame ) const
|
||||
{
|
||||
/* It's sometimes possible for the hardware position to move backwards, usually
|
||||
* on underrun. We can try to prevent this in each driver, but it's an obscure
|
||||
@@ -488,7 +489,7 @@ int64_t RageSoundDriver::ClampHardwareFrame( int64_t iHardwareFrame ) const
|
||||
|
||||
|
||||
//iHardwareFrame %= 0x800000; // debug test a sample value max of about 3 minutes so I dont have to spend an hour per test
|
||||
int64_t diff = iHardwareFrame - m_iMaxHardwareFrame;
|
||||
std::int64_t diff = iHardwareFrame - m_iMaxHardwareFrame;
|
||||
if( diff < 0 )
|
||||
{
|
||||
diff = 0;
|
||||
@@ -533,7 +534,7 @@ int64_t RageSoundDriver::ClampHardwareFrame( int64_t iHardwareFrame ) const
|
||||
return m_iVMaxHardwareFrame;
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver::GetHardwareFrame( RageTimer *pTimestamp=nullptr ) const
|
||||
std::int64_t RageSoundDriver::GetHardwareFrame( RageTimer *pTimestamp=nullptr ) const
|
||||
{
|
||||
if( pTimestamp == nullptr )
|
||||
return ClampHardwareFrame( GetPosition() );
|
||||
@@ -548,7 +549,7 @@ int64_t RageSoundDriver::GetHardwareFrame( RageTimer *pTimestamp=nullptr ) const
|
||||
* severe performance problems, anyway.
|
||||
*/
|
||||
int iTries = 3;
|
||||
int64_t iPositionFrames;
|
||||
std::int64_t iPositionFrames;
|
||||
do
|
||||
{
|
||||
pTimestamp->Touch();
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "ProductInfo.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
REGISTER_SOUND_DRIVER_CLASS( JACK );
|
||||
|
||||
RageSoundDriver_JACK::RageSoundDriver_JACK() :
|
||||
@@ -116,7 +118,7 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
||||
const char **ports = nullptr;
|
||||
if( portNames.size() == 0 )
|
||||
{
|
||||
// The user has NOT specified any ports to connect to. Search
|
||||
// The user has NOT specified any ports to connect to. Search
|
||||
// for all physical sinks and use the first two.
|
||||
ports = jack_get_ports( client, nullptr, nullptr, JackPortIsInput | JackPortIsPhysical );
|
||||
if( ports == nullptr )
|
||||
@@ -137,11 +139,11 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
||||
else
|
||||
{
|
||||
// The user has specified ports to connect to. Loop through
|
||||
// them to find two that are valid, then use them. If we find
|
||||
// them to find two that are valid, then use them. If we find
|
||||
// only one that is valid, connect both channels to it.
|
||||
// Use jack_port_by_name to ensure ports exist, then
|
||||
// jack_port_name to use their canonical name. (I'm not sure
|
||||
// if that second step is necessary, I've seen something about
|
||||
// jack_port_name to use their canonical name. (I'm not sure
|
||||
// if that second step is necessary, I've seen something about
|
||||
// "aliases" in the docs.)
|
||||
for ( RString const &portName : portNames )
|
||||
{
|
||||
@@ -163,12 +165,12 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
||||
}
|
||||
if( port_out_l == nullptr )
|
||||
return "All specified sinks are invalid.";
|
||||
|
||||
|
||||
if( port_out_r == nullptr )
|
||||
// Only found one valid sink. Going mono!
|
||||
port_out_r = port_out_l;
|
||||
}
|
||||
|
||||
|
||||
RString ret = RString();
|
||||
|
||||
if( jack_connect( client, jack_port_name(port_l), port_out_l ) != 0 )
|
||||
@@ -182,7 +184,7 @@ RString RageSoundDriver_JACK::ConnectPorts()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_JACK::GetPosition() const
|
||||
std::int64_t RageSoundDriver_JACK::GetPosition() const
|
||||
{
|
||||
return jack_frame_time(client);
|
||||
}
|
||||
@@ -230,7 +232,7 @@ int RageSoundDriver_JACK::SampleRateTrampoline(jack_nframes_t nframes, void *arg
|
||||
/*
|
||||
* (c) 2013 Devin J. Pohly
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -240,7 +242,7 @@ int RageSoundDriver_JACK::SampleRateTrampoline(jack_nframes_t nframes, void *arg
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define RAGE_SOUND_JACK
|
||||
|
||||
#include "RageSoundDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <jack/jack.h>
|
||||
|
||||
#define USE_RAGE_SOUND_JACK
|
||||
@@ -15,7 +18,7 @@ public:
|
||||
RString Init();
|
||||
|
||||
int GetSampleRate() const;
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
|
||||
private:
|
||||
jack_client_t *client;
|
||||
@@ -39,7 +42,7 @@ private:
|
||||
/*
|
||||
* (c) 2013 Devin J. Pohly
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -49,7 +52,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "RageUtil.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
REGISTER_SOUND_DRIVER_CLASS( Null );
|
||||
|
||||
const int channels = 2;
|
||||
@@ -13,7 +15,7 @@ void RageSoundDriver_Null::Update()
|
||||
/* "Play" frames. */
|
||||
while( m_iLastCursorPos < GetPosition()+1024*4 )
|
||||
{
|
||||
int16_t buf[256*channels];
|
||||
std::int16_t buf[256*channels];
|
||||
this->Mix( buf, 256, m_iLastCursorPos, GetPosition() );
|
||||
m_iLastCursorPos += 256;
|
||||
}
|
||||
@@ -21,9 +23,9 @@ void RageSoundDriver_Null::Update()
|
||||
RageSoundDriver::Update();
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_Null::GetPosition() const
|
||||
std::int64_t RageSoundDriver_Null::GetPosition() const
|
||||
{
|
||||
return int64_t( RageTimer::GetTimeSinceStart() * m_iSampleRate );
|
||||
return std::int64_t( RageTimer::GetTimeSinceStart() * m_iSampleRate );
|
||||
}
|
||||
|
||||
RageSoundDriver_Null::RageSoundDriver_Null()
|
||||
@@ -43,7 +45,7 @@ int RageSoundDriver_Null::GetSampleRate() const
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -53,7 +55,7 @@ int RageSoundDriver_Null::GetSampleRate() const
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
|
||||
#include "RageSoundDriver.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RageSoundDriver_Null: public RageSoundDriver
|
||||
{
|
||||
public:
|
||||
RageSoundDriver_Null();
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
int GetSampleRate() const;
|
||||
void Update();
|
||||
|
||||
private:
|
||||
int64_t m_iLastCursorPos;
|
||||
std::int64_t m_iLastCursorPos;
|
||||
int m_iSampleRate;
|
||||
};
|
||||
#define USE_RAGE_SOUND_NULL
|
||||
@@ -22,7 +24,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Aaron VonderHaar
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -32,7 +34,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
#include "RageSound.h"
|
||||
#include "RageSoundManager.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if defined(HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
#include <sys/select.h>
|
||||
@@ -78,12 +80,12 @@ bool RageSoundDriver_OSS::GetData()
|
||||
|
||||
if( !ab.fragments )
|
||||
return false;
|
||||
|
||||
|
||||
const int chunksize = ab.fragsize;
|
||||
|
||||
static int16_t *buf = nullptr;
|
||||
|
||||
static std::int16_t *buf = nullptr;
|
||||
if(!buf)
|
||||
buf = new int16_t[chunksize / sizeof(int16_t)];
|
||||
buf = new std::int16_t[chunksize / sizeof(std::int16_t)];
|
||||
|
||||
this->Mix( buf, chunksize/bytes_per_frame, last_cursor_pos, GetPosition() );
|
||||
|
||||
@@ -99,10 +101,10 @@ bool RageSoundDriver_OSS::GetData()
|
||||
|
||||
/* XXX: There's a race on last_cursor_pos here: new data might be written after the
|
||||
* ioctl returns, incrementing last_cursor_pos. */
|
||||
int64_t RageSoundDriver_OSS::GetPosition() const
|
||||
std::int64_t RageSoundDriver_OSS::GetPosition() const
|
||||
{
|
||||
ASSERT( fd != -1 );
|
||||
|
||||
|
||||
int delay;
|
||||
if(ioctl(fd, SNDCTL_DSP_GETODELAY, &delay) == -1)
|
||||
FAIL_M( ssprintf("RageSoundDriver_OSS: ioctl(SNDCTL_DSP_GETODELAY): %s", strerror(errno)) );
|
||||
@@ -190,7 +192,7 @@ RString RageSoundDriver_OSS::Init()
|
||||
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_CHANNELS, %i): %s", i, strerror(errno) );
|
||||
if(i != channels)
|
||||
return ssprintf( "RageSoundDriver_OSS: Wanted %i channels, got %i instead", channels, i );
|
||||
|
||||
|
||||
i = 44100;
|
||||
if(ioctl(fd, SNDCTL_DSP_SPEED, &i) == -1 )
|
||||
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SPEED, %i): %s", i, strerror(errno) );
|
||||
@@ -200,7 +202,7 @@ RString RageSoundDriver_OSS::Init()
|
||||
if(ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &i) == -1)
|
||||
return ssprintf( "RageSoundDriver_OSS: ioctl(SNDCTL_DSP_SETFRAGMENT, %i): %s", i, strerror(errno) );
|
||||
StartDecodeThread();
|
||||
|
||||
|
||||
MixingThread.SetName( "RageSoundDriver_OSS" );
|
||||
MixingThread.Create( MixerThread_start, this );
|
||||
|
||||
@@ -230,7 +232,7 @@ float RageSoundDriver_OSS::GetPlayLatency() const
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -240,7 +242,7 @@ float RageSoundDriver_OSS::GetPlayLatency() const
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "RageThreads.h"
|
||||
#include "RageTimer.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class RageSoundDriver_OSS: public RageSoundDriver
|
||||
{
|
||||
int fd;
|
||||
@@ -18,13 +20,13 @@ class RageSoundDriver_OSS: public RageSoundDriver
|
||||
RageThread MixingThread;
|
||||
|
||||
static RString CheckOSSVersion( int fd );
|
||||
|
||||
|
||||
public:
|
||||
bool GetData();
|
||||
int GetSampleRate() const { return samplerate; }
|
||||
|
||||
/* virtuals: */
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
float GetPlayLatency() const;
|
||||
void SetupDecodingThread();
|
||||
|
||||
@@ -38,7 +40,7 @@ public:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
/* Register the RageSoundDriver_Pulseaudio class as sound driver "Pulse" */
|
||||
REGISTER_SOUND_DRIVER_CLASS2( Pulse, PulseAudio );
|
||||
@@ -181,7 +182,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
||||
*
|
||||
* "The server tries to assure that at least tlength bytes are always
|
||||
* available in the per-stream server-side playback buffer. It is
|
||||
* recommended to set this to (uint32_t) -1, which will initialize
|
||||
* recommended to set this to (std::uint32_t) -1, which will initialize
|
||||
* this to a value that is deemed sensible by the server. However,
|
||||
* this value will default to something like 2s, i.e. for applications
|
||||
* that have specific latency requirements this value should be set to
|
||||
@@ -194,10 +195,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
||||
|
||||
/* maxlength: Maximum length of the buffer
|
||||
*
|
||||
* "Setting this to (uint32_t) -1 will initialize this to the maximum
|
||||
* "Setting this to (std::uint32_t) -1 will initialize this to the maximum
|
||||
* value supported by server, which is recommended."
|
||||
*
|
||||
* (uint32_t)-1 is NOT working here, setting it to tlength*2, like
|
||||
* (std::uint32_t)-1 is NOT working here, setting it to tlength*2, like
|
||||
* openal-soft-pulseaudio does.
|
||||
*/
|
||||
attr.maxlength = attr.tlength*2;
|
||||
@@ -206,10 +207,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
||||
*
|
||||
* "The server does not request less than minreq bytes from the client,
|
||||
* instead waits until the buffer is free enough to request more bytes
|
||||
* at once. It is recommended to set this to (uint32_t) -1, which will
|
||||
* at once. It is recommended to set this to (std::uint32_t) -1, which will
|
||||
* initialize this to a value that is deemed sensible by the server."
|
||||
*
|
||||
* (uint32_t)-1 is NOT working here, setting it to 0, like
|
||||
* (std::uint32_t)-1 is NOT working here, setting it to 0, like
|
||||
* openal-soft-pulseaudio does.
|
||||
*/
|
||||
attr.minreq = 0;
|
||||
@@ -218,10 +219,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
||||
*
|
||||
* "The server does not start with playback before at least prebuf
|
||||
* bytes are available in the buffer. It is recommended to set this
|
||||
* to (uint32_t) -1, which will initialize this to the same value as
|
||||
* to (std::uint32_t) -1, which will initialize this to the same value as
|
||||
* tlength"
|
||||
*/
|
||||
attr.prebuf = (uint32_t)-1;
|
||||
attr.prebuf = (std::uint32_t)-1;
|
||||
|
||||
/* log the used target buffer length */
|
||||
LOG->Trace("Pulse: using target buffer length of %i bytes", attr.tlength);
|
||||
@@ -300,7 +301,7 @@ void RageSoundDriver_PulseAudio::StreamStateCb(pa_stream *s)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_PulseAudio::GetPosition() const
|
||||
std::int64_t RageSoundDriver_PulseAudio::GetPosition() const
|
||||
{
|
||||
return m_LastPosition;
|
||||
}
|
||||
@@ -317,10 +318,10 @@ void RageSoundDriver_PulseAudio::StreamWriteCb(pa_stream *s, std::size_t length)
|
||||
* maybe the requested length is given in frames instead of bytes */
|
||||
length *= 2;
|
||||
#endif
|
||||
const std::size_t nbframes = length / sizeof(int16_t); /* we use 16-bit frames */
|
||||
std::vector<int16_t> buf(nbframes);
|
||||
int64_t pos1 = m_LastPosition;
|
||||
int64_t pos2 = pos1 + nbframes/2; /* Mix() position in stereo frames */
|
||||
const std::size_t nbframes = length / sizeof(std::int16_t); /* we use 16-bit frames */
|
||||
std::vector<std::int16_t> buf(nbframes);
|
||||
std::int64_t pos1 = m_LastPosition;
|
||||
std::int64_t pos2 = pos1 + nbframes/2; /* Mix() position in stereo frames */
|
||||
this->Mix( buf.data(), pos2-pos1, pos1, pos2);
|
||||
if(pa_stream_write(m_PulseStream, buf.data(), length, nullptr, 0, PA_SEEK_RELATIVE) < 0)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "RageSoundDriver.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
@@ -17,11 +18,11 @@ public:
|
||||
|
||||
RString Init();
|
||||
|
||||
inline int64_t GetPosition() const;
|
||||
inline std::int64_t GetPosition() const;
|
||||
inline int GetSampleRate() const { return m_SampleRate; };
|
||||
|
||||
protected:
|
||||
int64_t m_LastPosition;
|
||||
std::int64_t m_LastPosition;
|
||||
int m_SampleRate;
|
||||
char *m_Error;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define _INC_MMREG
|
||||
#define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */
|
||||
@@ -1022,7 +1023,7 @@ bool WinWdmStream::SubmitPacket( int iPacket, RString &sError )
|
||||
#include <windows.h>
|
||||
namespace
|
||||
{
|
||||
void MapChannels( const int16_t *pIn, int16_t *pOut, int iInChannels, int iOutChannels, int iFrames, const int *pChannelMap )
|
||||
void MapChannels( const std::int16_t *pIn, std::int16_t *pOut, int iInChannels, int iOutChannels, int iFrames, const int *pChannelMap )
|
||||
{
|
||||
for( int i = 0; i < iFrames; ++i )
|
||||
{
|
||||
@@ -1046,7 +1047,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void MapChannels( const int16_t *pIn, int16_t *pOut, int iInChannels, int iOutChannels, int iFrames )
|
||||
void MapChannels( const std::int16_t *pIn, std::int16_t *pOut, int iInChannels, int iOutChannels, int iFrames )
|
||||
{
|
||||
static const int i1ChannelMap[] = { -2 };
|
||||
static const int i4ChannelMap[] = { 0, 1, 0, 1 };
|
||||
@@ -1064,7 +1065,7 @@ namespace
|
||||
MapChannels( pIn, pOut, iInChannels, iOutChannels, iFrames, pChannelMap );
|
||||
}
|
||||
|
||||
void MapSampleFormatFromInt16( const int16_t *pIn, void *pOut, int iSamples, DeviceSampleFormat FromFormat )
|
||||
void MapSampleFormatFromInt16( const std::int16_t *pIn, void *pOut, int iSamples, DeviceSampleFormat FromFormat )
|
||||
{
|
||||
switch( FromFormat )
|
||||
{
|
||||
@@ -1089,7 +1090,7 @@ namespace
|
||||
}
|
||||
case DeviceSampleFormat_Int32:
|
||||
{
|
||||
int16_t *pOutBuf = (int16_t *) pOut;
|
||||
std::int16_t *pOutBuf = (std::int16_t *) pOut;
|
||||
for( int i = 0; i < iSamples; ++i )
|
||||
{
|
||||
*pOutBuf++ = 0;
|
||||
@@ -1109,29 +1110,29 @@ void RageSoundDriver_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos,
|
||||
if( m_pStream->m_iDeviceOutputChannels == iChannels &&
|
||||
m_pStream->m_DeviceSampleFormat == DeviceSampleFormat_Int16 )
|
||||
{
|
||||
int16_t *pBuf = (int16_t *) pData;
|
||||
std::int16_t *pBuf = (std::int16_t *) pData;
|
||||
this->Mix( pBuf, iFrames, iLastCursorPos, iCurrentFrame );
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t *pBuf = (int16_t *) alloca( iFrames * iChannels * sizeof(int16_t) );
|
||||
this->Mix( (int16_t *) pBuf, iFrames, iLastCursorPos, iCurrentFrame );
|
||||
std::int16_t *pBuf = (std::int16_t *) alloca( iFrames * iChannels * sizeof(std::int16_t) );
|
||||
this->Mix( (std::int16_t *) pBuf, iFrames, iLastCursorPos, iCurrentFrame );
|
||||
|
||||
/* If the device has other than 2 channels, convert. */
|
||||
if( m_pStream->m_iDeviceOutputChannels != iChannels )
|
||||
{
|
||||
int16_t *pTempBuf = (int16_t *) alloca( iFrames * m_pStream->m_iBytesPerOutputSample * m_pStream->m_iDeviceOutputChannels );
|
||||
MapChannels( (int16_t *) pBuf, pTempBuf, iChannels, m_pStream->m_iDeviceOutputChannels, iFrames );
|
||||
std::int16_t *pTempBuf = (std::int16_t *) alloca( iFrames * m_pStream->m_iBytesPerOutputSample * m_pStream->m_iDeviceOutputChannels );
|
||||
MapChannels( (std::int16_t *) pBuf, pTempBuf, iChannels, m_pStream->m_iDeviceOutputChannels, iFrames );
|
||||
pBuf = pTempBuf;
|
||||
}
|
||||
|
||||
/* If the device format isn't int16_t, convert. */
|
||||
/* If the device format isn't std::int16_t, convert. */
|
||||
if( m_pStream->m_DeviceSampleFormat != DeviceSampleFormat_Int16 )
|
||||
{
|
||||
int iSamples = iFrames * m_pStream->m_iDeviceOutputChannels;
|
||||
void *pTempBuf = alloca( iSamples * m_pStream->m_iBytesPerOutputSample );
|
||||
MapSampleFormatFromInt16( (int16_t *) pBuf, pTempBuf, iSamples, m_pStream->m_DeviceSampleFormat );
|
||||
pBuf = (int16_t *) pTempBuf;
|
||||
MapSampleFormatFromInt16( (std::int16_t *) pBuf, pTempBuf, iSamples, m_pStream->m_DeviceSampleFormat );
|
||||
pBuf = (std::int16_t *) pTempBuf;
|
||||
}
|
||||
|
||||
memcpy( pData, pBuf, iFrames * m_pStream->m_iDeviceOutputChannels * m_pStream->m_iBytesPerOutputSample );
|
||||
@@ -1139,7 +1140,7 @@ void RageSoundDriver_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos,
|
||||
|
||||
bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError )
|
||||
{
|
||||
uint64_t iCurrentFrame = GetPosition();
|
||||
std::uint64_t iCurrentFrame = GetPosition();
|
||||
// if( iCurrentFrame == m_iLastCursorPos )
|
||||
// LOG->Trace( "underrun" );
|
||||
|
||||
@@ -1233,7 +1234,7 @@ void RageSoundDriver_WDMKS::SetupDecodingThread()
|
||||
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_WDMKS::GetPosition() const
|
||||
std::int64_t RageSoundDriver_WDMKS::GetPosition() const
|
||||
{
|
||||
KSAUDIO_POSITION pos;
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "RageSoundDriver.h"
|
||||
#include "RageThreads.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
struct WinWdmStream;
|
||||
@@ -15,7 +18,7 @@ public:
|
||||
~RageSoundDriver_WDMKS();
|
||||
RString Init();
|
||||
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
float GetPlayLatency() const;
|
||||
int GetSampleRate() const;
|
||||
|
||||
@@ -41,7 +44,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2006 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -51,7 +54,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
REGISTER_SOUND_DRIVER_CLASS( WaveOut );
|
||||
|
||||
const int channels = 2;
|
||||
@@ -70,7 +72,7 @@ bool RageSoundDriver_WaveOut::GetData()
|
||||
return false;
|
||||
|
||||
/* Call the callback. */
|
||||
this->Mix( (int16_t *) m_aBuffers[b].lpData, chunksize_frames, m_iLastCursorPos, GetPosition() );
|
||||
this->Mix( (std::int16_t *) m_aBuffers[b].lpData, chunksize_frames, m_iLastCursorPos, GetPosition() );
|
||||
|
||||
MMRESULT ret = waveOutWrite( m_hWaveOut, &m_aBuffers[b], sizeof(m_aBuffers[b]) );
|
||||
if( ret != MMSYSERR_NOERROR )
|
||||
@@ -88,7 +90,7 @@ void RageSoundDriver_WaveOut::SetupDecodingThread()
|
||||
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
|
||||
}
|
||||
|
||||
int64_t RageSoundDriver_WaveOut::GetPosition() const
|
||||
std::int64_t RageSoundDriver_WaveOut::GetPosition() const
|
||||
{
|
||||
MMTIME tm;
|
||||
tm.wType = TIME_SAMPLES;
|
||||
@@ -136,7 +138,7 @@ RString RageSoundDriver_WaveOut::Init()
|
||||
}
|
||||
}
|
||||
deviceIds.push_back(WAVE_MAPPER); // Fallback to WAVE_MAPPER
|
||||
|
||||
|
||||
MMRESULT ret = MMSYSERR_ERROR;
|
||||
for (UINT id : deviceIds) {
|
||||
ret = waveOutOpen( &m_hWaveOut, id, &fmt, (DWORD_PTR) m_hSoundEvent, NULL, CALLBACK_EVENT );
|
||||
@@ -209,7 +211,7 @@ float RageSoundDriver_WaveOut::GetPlayLatency() const
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -219,7 +221,7 @@ float RageSoundDriver_WaveOut::GetPlayLatency() const
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "RageSoundDriver.h"
|
||||
#include "RageThreads.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
@@ -13,7 +16,7 @@ public:
|
||||
~RageSoundDriver_WaveOut();
|
||||
RString Init();
|
||||
|
||||
int64_t GetPosition() const;
|
||||
std::int64_t GetPosition() const;
|
||||
float GetPlayLatency() const;
|
||||
int GetSampleRate() const { return m_iSampleRate; }
|
||||
|
||||
@@ -37,7 +40,7 @@ private:
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -47,7 +50,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef THREADS_H
|
||||
#define THREADS_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/* This is the low-level implementation; you probably want RageThreads. */
|
||||
class RageMutex;
|
||||
class RageTimer;
|
||||
@@ -16,7 +18,7 @@ public:
|
||||
* implementation-defined, except that each thread has exactly one ID
|
||||
* and each ID corresponds to one thread. (This means that Win32
|
||||
* thread handles are not acceptable as ThreadIds.) */
|
||||
virtual uint64_t GetThreadId() const = 0;
|
||||
virtual std::uint64_t GetThreadId() const = 0;
|
||||
|
||||
virtual int Wait() = 0;
|
||||
};
|
||||
@@ -69,23 +71,23 @@ public:
|
||||
};
|
||||
|
||||
// These functions must be implemented by the thread implementation.
|
||||
ThreadImpl *MakeThread( int (*fn)(void *), void *data, uint64_t *piThreadID );
|
||||
ThreadImpl *MakeThread( int (*fn)(void *), void *data, std::uint64_t *piThreadID );
|
||||
ThreadImpl *MakeThisThread();
|
||||
MutexImpl *MakeMutex( RageMutex *pParent );
|
||||
EventImpl *MakeEvent( MutexImpl *pMutex );
|
||||
SemaImpl *MakeSemaphore( int iInitialValue );
|
||||
uint64_t GetThisThreadId();
|
||||
std::uint64_t GetThisThreadId();
|
||||
|
||||
/* Since ThreadId is implementation-defined, we can't define a universal
|
||||
* invalid value. Return the invalid value for this implementation. */
|
||||
uint64_t GetInvalidThreadId();
|
||||
std::uint64_t GetInvalidThreadId();
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -95,7 +97,7 @@ uint64_t GetInvalidThreadId();
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include "RageThreads.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <errno.h>
|
||||
#include <cstdint>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(UNIX)
|
||||
@@ -37,7 +38,7 @@ void ThreadImpl_Pthreads::Resume()
|
||||
ResumeThread( threadHandle );
|
||||
}
|
||||
|
||||
uint64_t ThreadImpl_Pthreads::GetThreadId() const
|
||||
std::uint64_t ThreadImpl_Pthreads::GetThreadId() const
|
||||
{
|
||||
return threadHandle;
|
||||
}
|
||||
@@ -78,7 +79,7 @@ static void *StartThread( void *pData )
|
||||
return new int(iRet);
|
||||
}
|
||||
|
||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThreadID )
|
||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, std::uint64_t *piThreadID )
|
||||
{
|
||||
ThreadImpl_Pthreads *thread = new ThreadImpl_Pthreads;
|
||||
thread->m_pFunc = pFunc;
|
||||
@@ -226,12 +227,12 @@ void MutexImpl_Pthreads::Unlock()
|
||||
pthread_mutex_unlock( &mutex );
|
||||
}
|
||||
|
||||
uint64_t GetThisThreadId()
|
||||
std::uint64_t GetThisThreadId()
|
||||
{
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
uint64_t GetInvalidThreadId()
|
||||
std::uint64_t GetInvalidThreadId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "Threads.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
@@ -16,17 +18,17 @@ public:
|
||||
* Keep a list of child PIDs, so we can send them SIGKILL. This has
|
||||
* an added bonus: if this is corrupted, we'll just send signals and
|
||||
* they'll fail; we won't blow up (unless we're root). */
|
||||
uint64_t threadHandle;
|
||||
std::uint64_t threadHandle;
|
||||
|
||||
// These are only used during initialization.
|
||||
int (*m_pFunc)( void *pData );
|
||||
void *m_pData;
|
||||
uint64_t *m_piThreadID;
|
||||
std::uint64_t *m_piThreadID;
|
||||
SemaImpl *m_StartFinishedSem;
|
||||
|
||||
void Halt( bool Kill );
|
||||
void Resume();
|
||||
uint64_t GetThreadId() const;
|
||||
std::uint64_t GetThreadId() const;
|
||||
int Wait();
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "RageTimer.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
const int MAX_THREADS=128;
|
||||
|
||||
static MutexImpl_Win32 *g_pThreadIdMutex = nullptr;
|
||||
@@ -15,10 +17,10 @@ static void InitThreadIdMutex()
|
||||
g_pThreadIdMutex = new MutexImpl_Win32(nullptr);
|
||||
}
|
||||
|
||||
static uint64_t g_ThreadIds[MAX_THREADS];
|
||||
static std::uint64_t g_ThreadIds[MAX_THREADS];
|
||||
static HANDLE g_ThreadHandles[MAX_THREADS];
|
||||
|
||||
HANDLE Win32ThreadIdToHandle( uint64_t iID )
|
||||
HANDLE Win32ThreadIdToHandle( std::uint64_t iID )
|
||||
{
|
||||
for( int i = 0; i < MAX_THREADS; ++i )
|
||||
{
|
||||
@@ -42,9 +44,9 @@ void ThreadImpl_Win32::Resume()
|
||||
ResumeThread( ThreadHandle );
|
||||
}
|
||||
|
||||
uint64_t ThreadImpl_Win32::GetThreadId() const
|
||||
std::uint64_t ThreadImpl_Win32::GetThreadId() const
|
||||
{
|
||||
return (uint64_t) ThreadId;
|
||||
return (std::uint64_t) ThreadId;
|
||||
}
|
||||
|
||||
int ThreadImpl_Win32::Wait()
|
||||
@@ -109,7 +111,7 @@ static DWORD WINAPI StartThread( LPVOID pData )
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int GetOpenSlot( uint64_t iID )
|
||||
static int GetOpenSlot( std::uint64_t iID )
|
||||
{
|
||||
InitThreadIdMutex();
|
||||
|
||||
@@ -135,7 +137,7 @@ ThreadImpl *MakeThisThread()
|
||||
SetThreadName( GetCurrentThreadId(), RageThread::GetCurrentThreadName() );
|
||||
|
||||
const HANDLE CurProc = GetCurrentProcess();
|
||||
int ret = DuplicateHandle( CurProc, GetCurrentThread(), CurProc,
|
||||
int ret = DuplicateHandle( CurProc, GetCurrentThread(), CurProc,
|
||||
&thread->ThreadHandle, 0, false, DUPLICATE_SAME_ACCESS );
|
||||
|
||||
if( !ret )
|
||||
@@ -154,14 +156,14 @@ ThreadImpl *MakeThisThread()
|
||||
return thread;
|
||||
}
|
||||
|
||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThreadID )
|
||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, std::uint64_t *piThreadID )
|
||||
{
|
||||
ThreadImpl_Win32 *thread = new ThreadImpl_Win32;
|
||||
thread->m_pFunc = pFunc;
|
||||
thread->m_pData = pData;
|
||||
|
||||
thread->ThreadHandle = CreateThread( nullptr, 0, &StartThread, thread, CREATE_SUSPENDED, &thread->ThreadId );
|
||||
*piThreadID = (uint64_t) thread->ThreadId;
|
||||
*piThreadID = (std::uint64_t) thread->ThreadId;
|
||||
ASSERT_M( thread->ThreadHandle != nullptr, ssprintf("%s", werr_ssprintf(GetLastError(), "CreateThread").c_str() ) );
|
||||
|
||||
int slot = GetOpenSlot( thread->ThreadId );
|
||||
@@ -247,12 +249,12 @@ void MutexImpl_Win32::Unlock()
|
||||
sm_crash( werr_ssprintf( GetLastError(), "ReleaseMutex failed" ) );
|
||||
}
|
||||
|
||||
uint64_t GetThisThreadId()
|
||||
std::uint64_t GetThisThreadId()
|
||||
{
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
uint64_t GetInvalidThreadId()
|
||||
std::uint64_t GetInvalidThreadId()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -452,12 +454,12 @@ void SemaImpl_Win32::Post()
|
||||
|
||||
bool SemaImpl_Win32::Wait()
|
||||
{
|
||||
int len = 15000;
|
||||
int len = 15000;
|
||||
int tries = 5;
|
||||
|
||||
while( tries-- )
|
||||
{
|
||||
/* Wait for 15 seconds. If it takes longer than that, we're
|
||||
/* Wait for 15 seconds. If it takes longer than that, we're
|
||||
* probably deadlocked. */
|
||||
if( SimpleWaitForSingleObject( sem, len ) )
|
||||
{
|
||||
@@ -491,7 +493,7 @@ SemaImpl *MakeSemaphore( int iInitialValue )
|
||||
/*
|
||||
* (c) 2001-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -501,7 +503,7 @@ SemaImpl *MakeSemaphore( int iInitialValue )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef THREADS_WIN32_H
|
||||
#define THREADS_WIN32_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Threads.h"
|
||||
#if defined(_WINDOWS)
|
||||
# include <windows.h>
|
||||
@@ -19,11 +21,11 @@ public:
|
||||
|
||||
void Halt( bool Kill );
|
||||
void Resume();
|
||||
uint64_t GetThreadId() const;
|
||||
std::uint64_t GetThreadId() const;
|
||||
int Wait();
|
||||
};
|
||||
|
||||
HANDLE Win32ThreadIdToHandle( uint64_t iID );
|
||||
HANDLE Win32ThreadIdToHandle( std::uint64_t iID );
|
||||
|
||||
class MutexImpl_Win32: public MutexImpl
|
||||
{
|
||||
@@ -82,7 +84,7 @@ private:
|
||||
/*
|
||||
* (c) 2001-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -92,7 +94,7 @@ private:
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user