diff --git a/src/ActorFrame.cpp b/src/ActorFrame.cpp index 14f5f5918a..9053cf8ad4 100644 --- a/src/ActorFrame.cpp +++ b/src/ActorFrame.cpp @@ -10,9 +10,11 @@ #include "RageDisplay.h" #include "ScreenDimensions.h" +#include + /* Tricky: We need ActorFrames created in Lua to auto delete their children. - * We don't want classes that derive from ActorFrame to auto delete their + * We don't want classes that derive from ActorFrame to auto delete their * children. The name "ActorFrame" is widely used in Lua, so we'll have * that string instead create an ActorFrameAutoDeleteChildren object. */ @@ -146,7 +148,7 @@ void ActorFrame::AddChild( Actor *pActor ) #endif ASSERT( pActor != nullptr ); - ASSERT( reinterpret_cast(pActor) != static_cast(0xC0000005) ); + ASSERT( reinterpret_cast(pActor) != static_cast(0xC0000005) ); m_SubActors.push_back( pActor ); pActor->SetParent( this ); @@ -226,7 +228,7 @@ void ActorFrame::DrawPrimitives() m_bClearZBuffer = false; } - // Don't set Actor-defined render states because we won't be drawing + // Don't set Actor-defined render states because we won't be drawing // any geometry that belongs to this object. // Actor::DrawPrimitives(); @@ -577,7 +579,7 @@ void ActorFrame::HandleMessage( const Message &msg ) if( msg.IsBroadcast() ) return; - for( unsigned i=0; iHandleMessage( msg ); @@ -593,7 +595,7 @@ void ActorFrame::SetDrawByZPosition( bool b ) // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the ActorFrame. */ +/** @brief Allow Lua to have access to the ActorFrame. */ class LunaActorFrame : public Luna { public: @@ -659,7 +661,7 @@ public: p->SetDrawFunction( ref ); COMMON_RETURN_SELF; } - + luaL_checktype( L, 1, LUA_TFUNCTION ); LuaReference ref; @@ -683,7 +685,7 @@ public: p->SetUpdateFunction( ref ); COMMON_RETURN_SELF; } - + luaL_checktype( L, 1, LUA_TFUNCTION ); LuaReference ref; @@ -769,7 +771,7 @@ public: ADD_METHOD( AddChildFromPath ); ADD_METHOD( RemoveChild ); ADD_METHOD( RemoveAllChildren ); - + } }; @@ -779,7 +781,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorFrame, Actor ) /* * (c) 2001-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 @@ -789,7 +791,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorFrame, Actor ) * 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 diff --git a/src/ActorFrameTexture.cpp b/src/ActorFrameTexture.cpp index 8a9578f525..1d4317c88a 100644 --- a/src/ActorFrameTexture.cpp +++ b/src/ActorFrameTexture.cpp @@ -5,6 +5,8 @@ #include "RageLog.h" #include "ActorUtil.h" +#include + REGISTER_ACTOR_CLASS_WITH_NAME( ActorFrameTextureAutoDeleteChildren, ActorFrameTexture ); ActorFrameTexture *ActorFrameTexture::Copy() const { return new ActorFrameTexture(*this); } @@ -14,7 +16,7 @@ ActorFrameTexture::ActorFrameTexture() m_bAlphaBuffer = false; m_bFloat = false; m_bPreserveTexture = false; - static uint64_t i = 0; + static std::uint64_t i = 0; ++i; m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i ); @@ -84,7 +86,7 @@ void ActorFrameTexture::DrawPrimitives() // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the ActorFrameTexture. */ +/** @brief Allow Lua to have access to the ActorFrameTexture. */ class LunaActorFrameTexture : public Luna { public: @@ -107,7 +109,7 @@ public: } return 1; } - + LunaActorFrameTexture() { ADD_METHOD( Create ); @@ -126,7 +128,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorFrameTexture, ActorFrame ) /* * (c) 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 @@ -136,7 +138,7 @@ LUA_REGISTER_DERIVED_CLASS( ActorFrameTexture, ActorFrame ) * 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 diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index e6640b1297..595ef201f8 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -14,6 +14,7 @@ #include #include +#include #include const float min_state_delay= 0.0001f; @@ -237,16 +238,16 @@ void ActorMultiVertex::DrawPrimitives() for( std::size_t i=0; i < TS.vertices.size(); i++ ) { - // RageVColor uses a uint8_t for each channel. 0-255. + // RageVColor uses a std::uint8_t for each channel. 0-255. // RageColor uses a float. 0-1. // So each channel of the RageVColor needs to be converted to a float, // multiplied by the channel from the RageColor, then the result - // converted to uint8_t. If implicit conversion is allowed to happen, - // sometimes the compiler decides to turn the RageColor into a uint8_t, + // converted to std::uint8_t. If implicit conversion is allowed to happen, + // sometimes the compiler decides to turn the RageColor into a std::uint8_t, // which makes any value other than 1 into 0. Thus, the explicit // conversions. -Kyz #define MULT_COLOR_ELEMENTS(color_a, color_b) \ - color_a= static_cast(static_cast(color_a) * color_b); + color_a= static_cast(static_cast(color_a) * color_b); // RageVColor * RageColor MULT_COLOR_ELEMENTS(TS.vertices[i].c.b, m_pTempState->diffuse[0].b); MULT_COLOR_ELEMENTS(TS.vertices[i].c.r, m_pTempState->diffuse[0].r); diff --git a/src/CreateZip.cpp b/src/CreateZip.cpp index 4fb5c6874b..2dcfa21307 100644 --- a/src/CreateZip.cpp +++ b/src/CreateZip.cpp @@ -1,6 +1,7 @@ #include "global.h" #include +#include #include #if defined(_WINDOWS) @@ -339,7 +340,7 @@ typedef unsigned IPos; // A Pos is an index in the character window. Pos is used -typedef int64_t lutime_t; // define it ourselves since we don't include time.h +typedef std::int64_t lutime_t; // define it ourselves since we don't include time.h typedef struct iztimes { lutime_t atime,mtime,ctime; diff --git a/src/CryptManager.cpp b/src/CryptManager.cpp index 5e6e5ab8a1..60624c921a 100644 --- a/src/CryptManager.cpp +++ b/src/CryptManager.cpp @@ -16,6 +16,8 @@ #include "LuaReference.h" #include "LuaManager.h" +#include + CryptManager* CRYPTMAN = nullptr; // global and accessible from anywhere in our program static const RString PRIVATE_KEY_PATH = "Data/private.rsa"; @@ -62,9 +64,9 @@ bool CryptManager::VerifyFileWithFile( RString sPath, RString sSignatureFile ) void CryptManager::GetRandomBytes( void *pData, int iBytes ) { - uint8_t *pBuf = (uint8_t *) pData; + std::uint8_t *pBuf = (std::uint8_t *) pData; while( iBytes-- ) - *pBuf++ = (uint8_t) RandomInt( 256 ); + *pBuf++ = (std::uint8_t) RandomInt( 256 ); } #else @@ -463,7 +465,7 @@ RString CryptManager::GetPublicKeyFileName() /* Generate a version 4 random UUID. */ RString CryptManager::GenerateRandomUUID() { - uint32_t buf[4]; + std::uint32_t buf[4]; CryptManager::GetRandomBytes( buf, sizeof(buf) ); buf[1] &= 0xFFFF0FFF; diff --git a/src/ImageCache.cpp b/src/ImageCache.cpp index c8d4951561..4c2c30711f 100644 --- a/src/ImageCache.cpp +++ b/src/ImageCache.cpp @@ -21,6 +21,7 @@ #include #include +#include static Preference g_bPalettedImageCache( "PalettedImageCache", false ); @@ -188,8 +189,8 @@ void ImageCache::ReadFromDisk() struct ImageTexture: public RageTexture { - uintptr_t m_uTexHandle; - uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay + std::uintptr_t m_uTexHandle; + std::uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay /* This is a reference to a pointer in g_ImagePathToImage. */ RageSurface *&m_pImage; int m_iWidth, m_iHeight; diff --git a/src/LuaManager.cpp b/src/LuaManager.cpp index 1e2f3103c6..f61f9d25c2 100644 --- a/src/LuaManager.cpp +++ b/src/LuaManager.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include // conversion for lua functions. @@ -420,8 +421,8 @@ LuaThreadVariable::LuaThreadVariable( lua_State *L ) RString LuaThreadVariable::GetCurrentThreadIDString() { - uint64_t iID = RageThread::GetCurrentThreadID(); - return ssprintf( "%08x%08x", uint32_t(iID >> 32), uint32_t(iID) ); + std::uint64_t iID = RageThread::GetCurrentThreadID(); + return ssprintf( "%08x%08x", std::uint32_t(iID >> 32), std::uint32_t(iID) ); } bool LuaThreadVariable::PushThreadTable( lua_State *L, bool bCreate ) diff --git a/src/Model.cpp b/src/Model.cpp index 1a3c99be47..4d31a721d0 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -14,6 +14,7 @@ #include "PrefsManager.h" #include +#include REGISTER_ACTOR_CLASS( Model ); @@ -541,7 +542,7 @@ void Model::PlayAnimation( const RString &sAniName, float fPlayRate ) { // int iBoneIndex = (pMesh->m_iBoneIndex!=-1) ? pMesh->m_iBoneIndex : bone; RageVector3 &pos = Vertices[j].p; - int8_t bone = Vertices[j].bone; + std::int8_t bone = Vertices[j].bone; if( bone != -1 ) { pos[0] -= m_vpBones[bone].m_Absolute.m[3][0]; @@ -698,7 +699,7 @@ void Model::UpdateTempGeometry() RageVector3 &tempNormal = tempVertices[j].n; const RageVector3 &originalPos = origVertices[j].p; const RageVector3 &originalNormal = origVertices[j].n; - int8_t bone = origVertices[j].bone; + std::int8_t bone = origVertices[j].bone; if( bone == -1 ) { diff --git a/src/ModelTypes.h b/src/ModelTypes.h index 819f2bc06b..6b8a116984 100644 --- a/src/ModelTypes.h +++ b/src/ModelTypes.h @@ -5,9 +5,11 @@ #include "RageTypes.h" +#include + struct msTriangle { - uint16_t nVertexIndices[3]; + std::uint16_t nVertexIndices[3]; }; @@ -18,7 +20,7 @@ struct msMesh std::vector Vertices; - // OPTIMIZATION: If all verts in a mesh are transformed by the same bone, + // OPTIMIZATION: If all verts in a mesh are transformed by the same bone, // then send the transform to the graphics card for the whole mesh instead // of transforming each vertex on the CPU; char m_iBoneIndex; // -1 = no bone @@ -146,7 +148,7 @@ struct myBone_t /* * (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 @@ -156,7 +158,7 @@ struct myBone_t * 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 diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index 8435a2241f..69a61d3972 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -12,6 +12,7 @@ #include #include +#include #include // TODO: Remove these constants that aren't time signature-aware @@ -144,7 +145,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS int iHeadRow; if( !out.IsHoldNoteAtRow( iTrack, iIndex, &iHeadRow ) ) { - int n = intptr_t(endLine) - intptr_t(beginLine); + int n = std::intptr_t(endLine) - std::intptr_t(beginLine); LOG->Warn( "Unmatched 3 in \"%.*s\"", n, beginLine ); } else diff --git a/src/NoteDisplay.cpp b/src/NoteDisplay.cpp index d81c3248ea..d80211e1a8 100644 --- a/src/NoteDisplay.cpp +++ b/src/NoteDisplay.cpp @@ -20,6 +20,7 @@ #include "Style.h" #include +#include static Preference g_bRenderEarlierNotesOnTop( "RenderEarlierNotesOnTop", false ); @@ -1358,7 +1359,7 @@ void NoteDisplay::DrawActor(const TapNote& tn, Actor* pActor, NotePart part, break; case NoteColorType_ProgressAlternate: fScaledBeat = fBeat * cache->m_iNoteColorCount[part]; - if( fScaledBeat - int64_t(fScaledBeat) == 0.0f ) + if( fScaledBeat - std::int64_t(fScaledBeat) == 0.0f ) //we're on a boundary, so move to the previous frame. //doing it this way ensures that fScaledBeat is never negative so std::fmod works. fScaledBeat += cache->m_iNoteColorCount[part] - 1; diff --git a/src/Profile.cpp b/src/Profile.cpp index f05911be57..4abde6267c 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -28,6 +28,7 @@ #include #include +#include const RString STATS_XML = "Stats.xml"; const RString STATS_XML_GZ = "Stats.xml.gz"; @@ -1254,7 +1255,7 @@ ProfileLoadResult Profile::LoadStatsFromDir(RString dir, bool require_signature) if(compressed) { RString sError; - uint32_t iCRC32; + std::uint32_t iCRC32; RageFileObjInflate *pInflate = GunzipFile(pFile.release(), sError, &iCRC32); if(pInflate == nullptr) { diff --git a/src/RageBitmapTexture.h b/src/RageBitmapTexture.h index 74153d52ae..fc3907d92f 100644 --- a/src/RageBitmapTexture.h +++ b/src/RageBitmapTexture.h @@ -5,6 +5,8 @@ #include "RageTexture.h" +#include + class RageBitmapTexture : public RageTexture { public: @@ -13,12 +15,12 @@ public: /* only called by RageTextureManager::InvalidateTextures */ virtual void Invalidate() { m_uTexHandle = 0; /* don't Destroy() */} virtual void Reload(); - virtual uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay + virtual std::uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay private: void Create(); // called by constructor and Reload void Destroy(); - uintptr_t m_uTexHandle; // treat as unsigned in OpenGL, IDirect3DTexture9* for D3D + std::uintptr_t m_uTexHandle; // treat as unsigned in OpenGL, IDirect3DTexture9* for D3D }; #endif diff --git a/src/RageDisplay.cpp b/src/RageDisplay.cpp index 8858babe18..4c64a095ee 100644 --- a/src/RageDisplay.cpp +++ b/src/RageDisplay.cpp @@ -17,6 +17,7 @@ #include #include +#include // Statistics stuff RageTimer g_LastCheckTimer; @@ -653,7 +654,7 @@ RageSurface *RageDisplay::CreateSurfaceFromPixfmt( RagePixelFormat pixfmt, RageSurface *surf = CreateSurfaceFrom( width, height, tpf->bpp, tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3], - (uint8_t *) pixels, pitch ); + (std::uint8_t *) pixels, pitch ); return surf; } diff --git a/src/RageDisplay.h b/src/RageDisplay.h index f723926456..a8e7ab6510 100644 --- a/src/RageDisplay.h +++ b/src/RageDisplay.h @@ -7,6 +7,7 @@ #include "ModelTypes.h" #include +#include #include class DisplaySpec; @@ -200,7 +201,7 @@ struct RageTextureLock /* Given a surface with a format and no pixel data, lock the texture into the * surface. The data is write-only. */ - virtual void Lock( uintptr_t iTexHandle, RageSurface *pSurface ) = 0; + virtual void Lock( std::uintptr_t iTexHandle, RageSurface *pSurface ) = 0; /* Unlock and update the texture. If bChanged is false, the texture update * may be omitted. */ @@ -256,23 +257,23 @@ public: /* return 0 if failed or internal texture resource handle * (unsigned in OpenGL, texture pointer in D3D) */ - virtual uintptr_t CreateTexture( + virtual std::uintptr_t CreateTexture( RagePixelFormat pixfmt, // format of img and of texture in video mem RageSurface* img, // must be in pixfmt bool bGenerateMipMaps ) = 0; virtual void UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t iTexHandle, RageSurface* img, int xoffset, int yoffset, int width, int height ) = 0; - virtual void DeleteTexture( uintptr_t iTexHandle ) = 0; + virtual void DeleteTexture( std::uintptr_t iTexHandle ) = 0; /* Return an object to lock pixels for streaming. If not supported, returns nullptr. * Delete the object normally. */ virtual RageTextureLock *CreateTextureLock() { return nullptr; } virtual void ClearAllTextures() = 0; virtual int GetNumTextureUnits() = 0; - virtual void SetTexture( TextureUnit, uintptr_t /* iTexture */ ) = 0; + virtual void SetTexture( TextureUnit, std::uintptr_t /* iTexture */ ) = 0; virtual void SetTextureMode( TextureUnit, TextureMode ) = 0; virtual void SetTextureWrapping( TextureUnit, bool ) = 0; virtual int GetMaxTextureSize() const = 0; @@ -288,9 +289,9 @@ public: * DeleteTexture. (UpdateTexture is not permitted.) Returns 0 if render-to- * texture is unsupported. */ - virtual uintptr_t CreateRenderTarget( const RenderTargetParam &, int & /* iTextureWidthOut */, int & /* iTextureHeightOut */ ) { return 0; } + virtual std::uintptr_t CreateRenderTarget( const RenderTargetParam &, int & /* iTextureWidthOut */, int & /* iTextureHeightOut */ ) { return 0; } - virtual uintptr_t GetRenderTarget() { return 0; } + virtual std::uintptr_t GetRenderTarget() { return 0; } /* Set the render target, or 0 to resume rendering to the framebuffer. An active render * target may not be used as a texture. If bPreserveTexture is true, the contents @@ -298,7 +299,7 @@ public: * bPreserveTexture is true the first time a render target is used, behave as if * bPreserveTexture was false. */ - virtual void SetRenderTarget( uintptr_t /* iHandle */, bool /* bPreserveTexture */ = true ) { } + virtual void SetRenderTarget( std::uintptr_t /* iHandle */, bool /* bPreserveTexture */ = true ) { } virtual bool IsZTestEnabled() const = 0; virtual bool IsZWriteEnabled() const = 0; @@ -359,9 +360,9 @@ public: }; bool SaveScreenshot( RString sPath, GraphicsFileFormat format ); - virtual RString GetTextureDiagnostics( uintptr_t /* id */ ) const { return RString(); } + virtual RString GetTextureDiagnostics( std::uintptr_t /* id */ ) const { return RString(); } virtual RageSurface* CreateScreenshot() = 0; // allocates a surface. Caller must delete it. - virtual RageSurface *GetTexture( uintptr_t /* iTexture */ ) { return nullptr; } // allocates a surface. Caller must delete it. + virtual RageSurface *GetTexture( std::uintptr_t /* iTexture */ ) { return nullptr; } // allocates a surface. Caller must delete it. protected: virtual void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) = 0; diff --git a/src/RageDisplay_D3D.cpp b/src/RageDisplay_D3D.cpp index 93c5dad2d5..64395fc3fc 100644 --- a/src/RageDisplay_D3D.cpp +++ b/src/RageDisplay_D3D.cpp @@ -26,6 +26,7 @@ #include #include +#include #include // Globals @@ -45,13 +46,13 @@ const D3DFORMAT g_DefaultAdapterFormat = D3DFMT_X8R8G8B8; /* Direct3D doesn't associate a palette with textures. Instead, we load a * palette into a slot. We need to keep track of which texture's palette is * stored in what slot. */ -std::map g_TexResourceToPaletteIndex; +std::map g_TexResourceToPaletteIndex; std::list g_PaletteIndex; struct TexturePalette { PALETTEENTRY p[256]; }; -std::map g_TexResourceToTexturePalette; +std::map g_TexResourceToTexturePalette; // Load the palette, if any, for the given texture into a palette slot, and make it current. -static void SetPalette( uintptr_t TexResource ) +static void SetPalette( std::uintptr_t TexResource ) { // If the texture isn't paletted, we have nothing to do. if( g_TexResourceToTexturePalette.find(TexResource) == g_TexResourceToTexturePalette.end() ) @@ -64,7 +65,7 @@ static void SetPalette( uintptr_t TexResource ) UINT iPalIndex = static_cast(g_PaletteIndex.front()); // If any other texture is currently using this slot, mark that palette unloaded. - for( std::map::iterator i = g_TexResourceToPaletteIndex.begin(); i != g_TexResourceToPaletteIndex.end(); ++i ) + for( std::map::iterator i = g_TexResourceToPaletteIndex.begin(); i != g_TexResourceToPaletteIndex.end(); ++i ) { if( i->second != iPalIndex ) continue; @@ -795,7 +796,7 @@ public: for( std::size_t j=0; j vIndices; + static std::vector vIndices; std::size_t uOldSize = vIndices.size(); std::size_t uNewSize = std::max(uOldSize, static_cast(iNumIndices)); vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ ) + for( std::uint16_t i=(std::uint16_t)uOldSize/6; i<(std::uint16_t)iNumQuads; i++ ) { vIndices[i*6+0] = i*4+0; vIndices[i*6+1] = i*4+1; @@ -887,11 +888,11 @@ void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static std::vector vIndices; + static std::vector vIndices; std::size_t uOldSize = vIndices.size(); std::size_t uNewSize = std::max(uOldSize, static_cast(iNumIndices)); vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ ) + for( std::uint16_t i=(std::uint16_t)uOldSize/6; i<(std::uint16_t)iNumQuads; i++ ) { vIndices[i*6+0] = i*2+0; vIndices[i*6+1] = i*2+1; @@ -922,11 +923,11 @@ void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[] int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static std::vector vIndices; + static std::vector vIndices; std::size_t uOldSize = vIndices.size(); std::size_t uNewSize = std::max(uOldSize, static_cast(iNumIndices)); vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ ) + for( std::uint16_t i=(std::uint16_t)uOldSize/12; i<(std::uint16_t)iNumPieces; i++ ) { // { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 } vIndices[i*12+0] = i*3+1; @@ -1049,7 +1050,7 @@ int RageDisplay_D3D::GetNumTextureUnits() return g_DeviceCaps.MaxSimultaneousTextures; } -void RageDisplay_D3D::SetTexture( TextureUnit tu, uintptr_t iTexture ) +void RageDisplay_D3D::SetTexture( TextureUnit tu, std::uintptr_t iTexture ) { // g_DeviceCaps.MaxSimultaneousTextures = 1; if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported @@ -1357,7 +1358,7 @@ void RageDisplay_D3D::SetCullMode( CullMode mode ) } } -void RageDisplay_D3D::DeleteTexture( uintptr_t iTexHandle ) +void RageDisplay_D3D::DeleteTexture( std::uintptr_t iTexHandle ) { if( iTexHandle == 0 ) return; @@ -1373,7 +1374,7 @@ void RageDisplay_D3D::DeleteTexture( uintptr_t iTexHandle ) } -uintptr_t RageDisplay_D3D::CreateTexture( +std::uintptr_t RageDisplay_D3D::CreateTexture( RagePixelFormat pixfmt, RageSurface* img, bool bGenerateMipMaps ) @@ -1386,7 +1387,7 @@ uintptr_t RageDisplay_D3D::CreateTexture( RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s", img->w, img->h, RagePixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() ); - uintptr_t uTexHandle = reinterpret_cast(pTex); + std::uintptr_t uTexHandle = reinterpret_cast(pTex); if( pixfmt == RagePixelFormat_PAL ) { @@ -1412,7 +1413,7 @@ uintptr_t RageDisplay_D3D::CreateTexture( } void RageDisplay_D3D::UpdateTexture( - uintptr_t uTexHandle, + std::uintptr_t uTexHandle, RageSurface* img, int xoffset, int yoffset, int width, int height ) { diff --git a/src/RageDisplay_D3D.h b/src/RageDisplay_D3D.h index a3412132e3..ebfc92a990 100644 --- a/src/RageDisplay_D3D.h +++ b/src/RageDisplay_D3D.h @@ -5,6 +5,8 @@ #include "RageDisplay.h" +#include + class RageDisplay_D3D: public RageDisplay { public: @@ -17,26 +19,26 @@ public: void ResolutionChanged(); const RagePixelFormatDesc *GetPixelFormatDesc(RagePixelFormat pf) const; - bool BeginFrame(); + bool BeginFrame(); void EndFrame(); ActualVideoModeParams GetActualVideoModeParams() const; void SetBlendMode( BlendMode mode ); bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false ); bool SupportsThreadedRendering(); bool SupportsPerVertexMatrixScale() { return false; } - uintptr_t CreateTexture( - RagePixelFormat pixfmt, - RageSurface* img, - bool bGenerateMipMaps ); - void UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t CreateTexture( + RagePixelFormat pixfmt, RageSurface* img, - int xoffset, int yoffset, int width, int height + bool bGenerateMipMaps ); + void UpdateTexture( + std::uintptr_t iTexHandle, + RageSurface* img, + int xoffset, int yoffset, int width, int height ); - void DeleteTexture( uintptr_t iTexHandle ); + void DeleteTexture( std::uintptr_t iTexHandle ); void ClearAllTextures(); int GetNumTextureUnits(); - void SetTexture( TextureUnit tu, uintptr_t iTexture ); + void SetTexture( TextureUnit tu, std::uintptr_t iTexture ); void SetTextureMode( TextureUnit tu, TextureMode tm ); void SetTextureWrapping( TextureUnit tu, bool b ); int GetMaxTextureSize() const; @@ -49,7 +51,7 @@ public: void ClearZBuffer(); void SetCullMode( CullMode mode ); void SetAlphaTest( bool b ); - void SetMaterial( + void SetMaterial( const RageColor &emissive, const RageColor &ambient, const RageColor &diffuse, @@ -58,11 +60,11 @@ public: ); void SetLighting( bool b ); void SetLightOff( int index ); - void SetLightDirectional( - int index, - const RageColor &ambient, - const RageColor &diffuse, - const RageColor &specular, + void SetLightDirectional( + int index, + const RageColor &ambient, + const RageColor &diffuse, + const RageColor &specular, const RageVector3 &dir ); void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); @@ -82,7 +84,7 @@ protected: RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ); RageSurface* CreateScreenshot(); - RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); + RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); void SendCurrentMatrices(); }; diff --git a/src/RageDisplay_GLES2.cpp b/src/RageDisplay_GLES2.cpp index 48f8eebc08..0990e46f85 100644 --- a/src/RageDisplay_GLES2.cpp +++ b/src/RageDisplay_GLES2.cpp @@ -17,6 +17,7 @@ #include #include +#include #ifdef NO_GL_FLUSH #define glFlush() @@ -562,7 +563,7 @@ RageDisplay_GLES2::SupportsPerVertexMatrixScale() return true; } -uintptr_t +std::uintptr_t RageDisplay_GLES2::CreateTexture( RagePixelFormat pixfmt, RageSurface* img, @@ -575,7 +576,7 @@ RageDisplay_GLES2::CreateTexture( void RageDisplay_GLES2::UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t iTexHandle, RageSurface* img, int xoffset, int yoffset, int width, int height ) @@ -584,7 +585,7 @@ RageDisplay_GLES2::UpdateTexture( } void -RageDisplay_GLES2::DeleteTexture( uintptr_t iTexHandle ) +RageDisplay_GLES2::DeleteTexture( std::uintptr_t iTexHandle ) { // TODO } @@ -616,7 +617,7 @@ SetTextureUnit( TextureUnit tu ) } void -RageDisplay_GLES2::SetTexture( TextureUnit tu, uintptr_t iTexture ) +RageDisplay_GLES2::SetTexture( TextureUnit tu, std::uintptr_t iTexture ) { if (!SetTextureUnit( tu )) return; diff --git a/src/RageDisplay_GLES2.h b/src/RageDisplay_GLES2.h index 29a46d79d1..1b570d5037 100644 --- a/src/RageDisplay_GLES2.h +++ b/src/RageDisplay_GLES2.h @@ -1,6 +1,8 @@ #ifndef RAGE_DISPLAY_GLES2_H #define RAGE_DISPLAY_GLES2_H +#include + class RageDisplay_GLES2: public RageDisplay { public: @@ -18,18 +20,18 @@ public: void SetBlendMode( BlendMode mode ); bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false ); bool SupportsPerVertexMatrixScale(); - uintptr_t CreateTexture( + std::uintptr_t CreateTexture( RagePixelFormat pixfmt, RageSurface* img, bool bGenerateMipMaps ); void UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t iTexHandle, RageSurface* img, int xoffset, int yoffset, int width, int height ); - void DeleteTexture( uintptr_t iTexHandle ); + void DeleteTexture( std::uintptr_t iTexHandle ); void ClearAllTextures(); int GetNumTextureUnits(); - void SetTexture( TextureUnit tu, uintptr_t iTexture ); + void SetTexture( TextureUnit tu, std::uintptr_t iTexture ); void SetTextureMode( TextureUnit tu, TextureMode tm ); void SetTextureWrapping( TextureUnit tu, bool b ); int GetMaxTextureSize() const; @@ -51,11 +53,11 @@ public: ); void SetLighting( bool b ); void SetLightOff( int index ); - void SetLightDirectional( - int index, - const RageColor &ambient, - const RageColor &diffuse, - const RageColor &specular, + void SetLightDirectional( + int index, + const RageColor &ambient, + const RageColor &diffuse, + const RageColor &specular, const RageVector3 &dir ); void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); @@ -79,7 +81,7 @@ protected: RString TryVideoMode( const VideoModeParams &p, bool &bNewDeviceOut ); RageSurface* CreateScreenshot(); - RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); + RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); bool SupportsSurfaceFormat( RagePixelFormat pixfmt ); bool SupportsRenderToTexture() const { return true; } }; diff --git a/src/RageDisplay_Null.h b/src/RageDisplay_Null.h index dd1c9806d0..75c35a9b40 100644 --- a/src/RageDisplay_Null.h +++ b/src/RageDisplay_Null.h @@ -3,6 +3,8 @@ #ifndef RAGE_DISPLAY_NULL_H #define RAGE_DISPLAY_NULL_H +#include + class RageDisplay_Null: public RageDisplay { public: @@ -19,19 +21,19 @@ public: void SetBlendMode( BlendMode ) { } bool SupportsTextureFormat( RagePixelFormat, bool /* realtime */ =false ) { return true; } bool SupportsPerVertexMatrixScale() { return false; } - uintptr_t CreateTexture( + std::uintptr_t CreateTexture( RagePixelFormat, RageSurface* /* img */, bool /* bGenerateMipMaps */ ) { return 1; } void UpdateTexture( - uintptr_t /* iTexHandle */, + std::uintptr_t /* iTexHandle */, RageSurface* /* img */, int /* xoffset */, int /* yoffset */, int /* width */, int /* height */ ) { } - void DeleteTexture( uintptr_t /* iTexHandle */ ) { } + void DeleteTexture( std::uintptr_t /* iTexHandle */ ) { } void ClearAllTextures() { } int GetNumTextureUnits() { return 1; } - void SetTexture( TextureUnit, uintptr_t /* iTexture */ ) { } + void SetTexture( TextureUnit, std::uintptr_t /* iTexture */ ) { } void SetTextureMode( TextureUnit, TextureMode ) { } void SetTextureWrapping( TextureUnit, bool ) { } int GetMaxTextureSize() const { return 2048; } @@ -53,11 +55,11 @@ public: ) { } void SetLighting( bool ) { } void SetLightOff( int /* index */ ) { } - void SetLightDirectional( - int /* index */, - const RageColor & /* unreferenced: ambient */, - const RageColor & /* unreferenced: diffuse */, - const RageColor & /* unreferenced: specular */, + void SetLightDirectional( + int /* index */, + const RageColor & /* unreferenced: ambient */, + const RageColor & /* unreferenced: diffuse */, + const RageColor & /* unreferenced: specular */, const RageVector3 & /* unreferenced: dir */ ) { } void SetSphereEnvironmentMapping( TextureUnit /* tu */, bool /* b */ ) { } @@ -79,7 +81,7 @@ protected: VideoModeParams m_Params; RString TryVideoMode( const VideoModeParams &p, bool & /* bNewDeviceOut */ ) { m_Params = p; return RString(); } RageSurface* CreateScreenshot(); - RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); + RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ); bool SupportsSurfaceFormat( RagePixelFormat ) { return true; } }; diff --git a/src/RageDisplay_OGL.cpp b/src/RageDisplay_OGL.cpp index c68677a611..e60e4b287e 100644 --- a/src/RageDisplay_OGL.cpp +++ b/src/RageDisplay_OGL.cpp @@ -21,6 +21,7 @@ using namespace RageDisplay_Legacy_Helpers; #include #include +#include #include #if defined(WINDOWS) @@ -64,7 +65,7 @@ static const GLenum RageSpriteVertexFormat = GL_T2F_C4F_N3F_V3F; /* If we support texture matrix scaling, a handle to the vertex program: */ static GLhandleARB g_bTextureMatrixShader = 0; -static std::map g_mapRenderTargets; +static std::map g_mapRenderTargets; static RenderTarget *g_pCurrentRenderTarget = nullptr; static LowLevelWindow *g_pWind; @@ -799,7 +800,7 @@ RString RageDisplay_Legacy::TryVideoMode( const VideoModeParams &p, bool &bNewDe /* Delete all render targets. They may have associated resources other than * the texture itself. */ - for (std::pair &rt : g_mapRenderTargets) + for (std::pair &rt : g_mapRenderTargets) delete rt.second; g_mapRenderTargets.clear(); @@ -926,7 +927,7 @@ RageSurface* RageDisplay_Legacy::CreateScreenshot() return image; } -RageSurface *RageDisplay_Legacy::GetTexture( uintptr_t iTexture ) +RageSurface *RageDisplay_Legacy::GetTexture( std::uintptr_t iTexture ) { if (iTexture == 0) return nullptr; // XXX @@ -1070,7 +1071,7 @@ public: for( unsigned k=0; k<3; k++ ) { int iVertexIndexInVBO = meshInfo.iVertexStart + Triangles[j].nVertexIndices[k]; - m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (uint16_t) iVertexIndexInVBO; + m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (std::uint16_t) iVertexIndexInVBO; } } } @@ -1512,11 +1513,11 @@ void RageDisplay_Legacy::DrawSymmetricQuadStripInternal( const RageSpriteVertex int iNumIndices = iNumTriangles*3; // make a temporary index buffer - static std::vector vIndices; + static std::vector vIndices; unsigned uOldSize = vIndices.size(); unsigned uNewSize = std::max(uOldSize,(unsigned)iNumIndices); vIndices.resize( uNewSize ); - for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ ) + for( std::uint16_t i=(std::uint16_t)uOldSize/12; i<(std::uint16_t)iNumPieces; i++ ) { // { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 } vIndices[i*12+0] = i*3+1; @@ -1686,7 +1687,7 @@ int RageDisplay_Legacy::GetNumTextureUnits() return g_iMaxTextureUnits; } -void RageDisplay_Legacy::SetTexture( TextureUnit tu, uintptr_t iTexture ) +void RageDisplay_Legacy::SetTexture( TextureUnit tu, std::uintptr_t iTexture ) { if (!SetTextureUnit( tu )) return; @@ -2113,7 +2114,7 @@ void RageDisplay_Legacy::EndConcurrentRendering() g_pWind->EndConcurrentRendering(); } -void RageDisplay_Legacy::DeleteTexture( uintptr_t iTexture ) +void RageDisplay_Legacy::DeleteTexture( std::uintptr_t iTexture ) { if (iTexture == 0) return; @@ -2198,7 +2199,7 @@ void SetPixelMapForSurface( int glImageFormat, int glTexFormat, const RageSurfac DebugAssertNoGLError(); } -uintptr_t RageDisplay_Legacy::CreateTexture( +std::uintptr_t RageDisplay_Legacy::CreateTexture( RagePixelFormat pixfmt, RageSurface* pImg, bool bGenerateMipMaps ) @@ -2243,7 +2244,7 @@ uintptr_t RageDisplay_Legacy::CreateTexture( SetTextureUnit( TextureUnit_1 ); // allocate OpenGL texture resource - uintptr_t iTexHandle; + std::uintptr_t iTexHandle; glGenTextures( 1, reinterpret_cast(&iTexHandle) ); ASSERT( iTexHandle != 0 ); @@ -2359,7 +2360,7 @@ public: m_iTexHandle = 0; } - void Lock( uintptr_t iTexHandle, RageSurface *pSurface ) + void Lock( std::uintptr_t iTexHandle, RageSurface *pSurface ) { ASSERT( m_iTexHandle == 0 ); ASSERT( pSurface->pixels == nullptr ); @@ -2373,7 +2374,7 @@ public: glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, iSize, nullptr, GL_STREAM_DRAW ); void *pSurfaceMemory = glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY ); - pSurface->pixels = (uint8_t *) pSurfaceMemory; + pSurface->pixels = (std::uint8_t *) pSurfaceMemory; pSurface->pixels_owned = false; } @@ -2381,7 +2382,7 @@ public: { glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB ); - pSurface->pixels = (uint8_t *) BUFFER_OFFSET(0); + pSurface->pixels = (std::uint8_t *) BUFFER_OFFSET(0); if (bChanged) DISPLAY->UpdateTexture( m_iTexHandle, pSurface, 0, 0, pSurface->w, pSurface->h ); @@ -2405,7 +2406,7 @@ private: GLuint m_iBuffer; - uintptr_t m_iTexHandle; + std::uintptr_t m_iTexHandle; }; RageTextureLock *RageDisplay_Legacy::CreateTextureLock() @@ -2417,7 +2418,7 @@ RageTextureLock *RageDisplay_Legacy::CreateTextureLock() } void RageDisplay_Legacy::UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t iTexHandle, RageSurface* pImg, int iXOffset, int iYOffset, int iWidth, int iHeight ) { @@ -2459,16 +2460,16 @@ public: RenderTarget_FramebufferObject(); ~RenderTarget_FramebufferObject(); void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ); - uintptr_t GetTexture() const { return m_iTexHandle; } + std::uintptr_t GetTexture() const { return m_iTexHandle; } void StartRenderingTo(); void FinishRenderingTo(); virtual bool InvertY() const { return true; } private: - uintptr_t m_iFrameBufferHandle; - uintptr_t m_iTexHandle; - uintptr_t m_iDepthBufferHandle; + std::uintptr_t m_iFrameBufferHandle; + std::uintptr_t m_iTexHandle; + std::uintptr_t m_iDepthBufferHandle; }; RenderTarget_FramebufferObject::RenderTarget_FramebufferObject() @@ -2591,7 +2592,7 @@ bool RageDisplay_Legacy::SupportsFullscreenBorderlessWindow() const * particularly GeForce 2, but is simpler and faster when available. */ -uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ) +std::uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ) { RenderTarget *pTarget; if (GLEW_EXT_framebuffer_object) @@ -2601,22 +2602,22 @@ uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m pTarget->Create( param, iTextureWidthOut, iTextureHeightOut ); - uintptr_t iTexture = pTarget->GetTexture(); + std::uintptr_t iTexture = pTarget->GetTexture(); ASSERT( g_mapRenderTargets.find(iTexture) == g_mapRenderTargets.end() ); g_mapRenderTargets[iTexture] = pTarget; return iTexture; } -uintptr_t RageDisplay_Legacy::GetRenderTarget() +std::uintptr_t RageDisplay_Legacy::GetRenderTarget() { - for( std::map::const_iterator it = g_mapRenderTargets.begin(); it != g_mapRenderTargets.end(); ++it ) + for( std::map::const_iterator it = g_mapRenderTargets.begin(); it != g_mapRenderTargets.end(); ++it ) if( it->second == g_pCurrentRenderTarget ) return it->first; return 0; } -void RageDisplay_Legacy::SetRenderTarget( uintptr_t iTexture, bool bPreserveTexture ) +void RageDisplay_Legacy::SetRenderTarget( std::uintptr_t iTexture, bool bPreserveTexture ) { if (iTexture == 0) { @@ -2695,7 +2696,7 @@ void RageDisplay_Legacy::SetLineWidth(float fWidth) glLineWidth(fWidth); } -RString RageDisplay_Legacy::GetTextureDiagnostics(uintptr_t iTexture) const +RString RageDisplay_Legacy::GetTextureDiagnostics(std::uintptr_t iTexture) const { /* s << (bGenerateMipMaps? "gluBuild2DMipmaps":"glTexImage2D"); diff --git a/src/RageDisplay_OGL.h b/src/RageDisplay_OGL.h index f713dbe745..88868e2dfe 100644 --- a/src/RageDisplay_OGL.h +++ b/src/RageDisplay_OGL.h @@ -11,6 +11,8 @@ #include "RageTextureRenderTarget.h" #include "Sprite.h" +#include + /* Making an OpenGL call doesn't also flush the error state; if we happen * to have an error from a previous call, then the assert below will fail. * Flush it. */ @@ -53,23 +55,23 @@ public: void SetBlendMode( BlendMode mode ); bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false ); bool SupportsPerVertexMatrixScale(); - uintptr_t CreateTexture( + std::uintptr_t CreateTexture( RagePixelFormat pixfmt, RageSurface* img, bool bGenerateMipMaps ); void UpdateTexture( - uintptr_t iTexHandle, + std::uintptr_t iTexHandle, RageSurface* img, int xoffset, int yoffset, int width, int height ); - void DeleteTexture( uintptr_t iTexHandle ); + void DeleteTexture( std::uintptr_t iTexHandle ); bool UseOffscreenRenderTarget(); - RageSurface *GetTexture( uintptr_t iTexture ); + RageSurface *GetTexture( std::uintptr_t iTexture ); RageTextureLock *CreateTextureLock(); void ClearAllTextures(); int GetNumTextureUnits(); - void SetTexture( TextureUnit tu, uintptr_t iTexture ); + void SetTexture( TextureUnit tu, std::uintptr_t iTexture ); void SetTextureMode( TextureUnit tu, TextureMode tm ); void SetTextureWrapping( TextureUnit tu, bool b ); int GetMaxTextureSize() const; @@ -78,9 +80,9 @@ public: bool IsEffectModeSupported( EffectMode effect ); bool SupportsRenderToTexture() const; bool SupportsFullscreenBorderlessWindow() const; - uintptr_t CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ); - uintptr_t GetRenderTarget(); - void SetRenderTarget( uintptr_t iHandle, bool bPreserveTexture ); + std::uintptr_t CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ); + std::uintptr_t GetRenderTarget(); + void SetRenderTarget( std::uintptr_t iHandle, bool bPreserveTexture ); bool IsZWriteEnabled() const; bool IsZTestEnabled() const; void SetZWrite( bool b ); @@ -98,11 +100,11 @@ public: ); void SetLighting( bool b ); void SetLightOff( int index ); - void SetLightDirectional( - int index, - const RageColor &ambient, - const RageColor &diffuse, - const RageColor &specular, + void SetLightDirectional( + int index, + const RageColor &ambient, + const RageColor &diffuse, + const RageColor &specular, const RageVector3 &dir ); void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); @@ -115,7 +117,7 @@ public: virtual void SetPolygonMode( PolygonMode pm ); virtual void SetLineWidth( float fWidth ); - RString GetTextureDiagnostics( uintptr_t id ) const; + RString GetTextureDiagnostics( std::uintptr_t id ) const; protected: void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ); @@ -131,7 +133,7 @@ protected: RageSurface* CreateScreenshot(); RagePixelFormat GetImgPixelFormat( RageSurface* &img, bool &FreeImg, int width, int height, bool bPalettedTexture ); bool SupportsSurfaceFormat( RagePixelFormat pixfmt ); - + void SendCurrentMatrices(); private: diff --git a/src/RageDisplay_OGL_Helpers.h b/src/RageDisplay_OGL_Helpers.h index 34fd20a433..3f81ac5c64 100644 --- a/src/RageDisplay_OGL_Helpers.h +++ b/src/RageDisplay_OGL_Helpers.h @@ -1,15 +1,17 @@ #ifndef RAGE_DISPLAY_OGL_HELPERS_H #define RAGE_DISPLAY_OGL_HELPERS_H +/* Import RageDisplay, for types. Do not include RageDisplay_Legacy.h. */ +#include "RageDisplay.h" + +#include + #if defined(WIN32) #include #endif #include -/* Import RageDisplay, for types. Do not include RageDisplay_Legacy.h. */ -#include "RageDisplay.h" - /* Windows defines GL_EXT_paletted_texture incompletely: */ #ifndef GL_TEXTURE_INDEX_SIZE_EXT #define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED @@ -28,7 +30,7 @@ public: virtual ~RenderTarget() { } virtual void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ) = 0; - virtual uintptr_t GetTexture() const = 0; + virtual std::uintptr_t GetTexture() const = 0; /* Render to this RenderTarget. */ virtual void StartRenderingTo() = 0; diff --git a/src/RageException.cpp b/src/RageException.cpp index ec4458f660..82910c6e52 100644 --- a/src/RageException.cpp +++ b/src/RageException.cpp @@ -5,6 +5,7 @@ #include "RageThreads.h" #include +#include #if defined(_WINDOWS) && defined(DEBUG) #include @@ -14,7 +15,7 @@ using CrashHandler::IsDebuggerPresent; using CrashHandler::DebugBreak; #endif -static uint64_t g_HandlerThreadID = RageThread::GetInvalidThreadID(); +static std::uint64_t g_HandlerThreadID = RageThread::GetInvalidThreadID(); static void (*g_CleanupHandler)( const RString &sError ) = nullptr; void RageException::SetCleanupHandler( void (*pHandler)(const RString &sError) ) { diff --git a/src/RageFile.cpp b/src/RageFile.cpp index ba6ddab9ff..d41387a167 100644 --- a/src/RageFile.cpp +++ b/src/RageFile.cpp @@ -13,6 +13,7 @@ #include "RageFileDriver.h" #include +#include RageFile::RageFile() { @@ -110,7 +111,7 @@ void RageFile::EnableCRC32( bool on ) m_File->EnableCRC32( on ); } -bool RageFile::GetCRC32( uint32_t *iRet ) +bool RageFile::GetCRC32( std::uint32_t *iRet ) { ASSERT_OPEN; return m_File->GetCRC32( iRet ); @@ -266,50 +267,50 @@ void FileReading::Seek( RageFileBasic &f, int iOffset, RString &sError ) sError = "Unexpected end of file"; } -uint8_t FileReading::read_8( RageFileBasic &f, RString &sError ) +std::uint8_t FileReading::read_8( RageFileBasic &f, RString &sError ) { - uint8_t val; - ReadBytes( f, &val, sizeof(uint8_t), sError ); + std::uint8_t val; + ReadBytes( f, &val, sizeof(std::uint8_t), sError ); if( sError.size() == 0 ) return val; else return 0; } -uint16_t FileReading::read_u16_le( RageFileBasic &f, RString &sError ) +std::uint16_t FileReading::read_u16_le( RageFileBasic &f, RString &sError ) { - uint16_t val; - ReadBytes( f, &val, sizeof(uint16_t), sError ); + std::uint16_t val; + ReadBytes( f, &val, sizeof(std::uint16_t), sError ); if( sError.size() == 0 ) return Swap16LE( val ); else return 0; } -int16_t FileReading::read_16_le( RageFileBasic &f, RString &sError ) +std::int16_t FileReading::read_16_le( RageFileBasic &f, RString &sError ) { - int16_t val; - ReadBytes( f, &val, sizeof(int16_t), sError ); + std::int16_t val; + ReadBytes( f, &val, sizeof(std::int16_t), sError ); if( sError.size() == 0 ) return Swap16LE( val ); else return 0; } -uint32_t FileReading::read_u32_le( RageFileBasic &f, RString &sError ) +std::uint32_t FileReading::read_u32_le( RageFileBasic &f, RString &sError ) { - uint32_t val; - ReadBytes( f, &val, sizeof(uint32_t), sError ); + std::uint32_t val; + ReadBytes( f, &val, sizeof(std::uint32_t), sError ); if( sError.size() == 0 ) return Swap32LE( val ); else return 0; } -int32_t FileReading::read_32_le( RageFileBasic &f, RString &sError ) +std::int32_t FileReading::read_32_le( RageFileBasic &f, RString &sError ) { - int32_t val; - ReadBytes( f, &val, sizeof(int32_t), sError ); + std::int32_t val; + ReadBytes( f, &val, sizeof(std::int32_t), sError ); if( sError.size() == 0 ) return Swap32LE( val ); else diff --git a/src/RageFile.h b/src/RageFile.h index b0070b62c6..9797ac08bd 100644 --- a/src/RageFile.h +++ b/src/RageFile.h @@ -6,6 +6,7 @@ #include "RageFileBasic.h" #include +#include struct lua_State; @@ -77,7 +78,7 @@ public: int PutLine( const RString &str ); void EnableCRC32( bool on=true ); - bool GetCRC32( uint32_t *iRet ); + bool GetCRC32( std::uint32_t *iRet ); // Lua virtual void PushSelf( lua_State *L ); @@ -102,11 +103,11 @@ namespace FileReading void SkipBytes( RageFileBasic &f, int size, RString &sError ); void Seek( RageFileBasic &f, int iOffset, RString &sError ); RString ReadString( RageFileBasic &f, int size, RString &sError ); - uint8_t read_8( RageFileBasic &f, RString &sError ); - int16_t read_16_le( RageFileBasic &f, RString &sError ); - uint16_t read_u16_le( RageFileBasic &f, RString &sError ); - int32_t read_32_le( RageFileBasic &f, RString &sError ); - uint32_t read_u32_le( RageFileBasic &f, RString &sError ); + std::uint8_t read_8( RageFileBasic &f, RString &sError ); + std::int16_t read_16_le( RageFileBasic &f, RString &sError ); + std::uint16_t read_u16_le( RageFileBasic &f, RString &sError ); + std::int32_t read_32_le( RageFileBasic &f, RString &sError ); + std::uint32_t read_u32_le( RageFileBasic &f, RString &sError ); }; #endif diff --git a/src/RageFileBasic.cpp b/src/RageFileBasic.cpp index f8f975069a..8f70caa30a 100644 --- a/src/RageFileBasic.cpp +++ b/src/RageFileBasic.cpp @@ -4,6 +4,7 @@ #include "RageUtil_AutoPtr.h" #include +#include REGISTER_CLASS_TRAITS( RageFileBasic, pCopy->Copy() ); @@ -313,7 +314,7 @@ void RageFileObj::EnableCRC32( bool bOn ) m_iCRC32 = 0; } -bool RageFileObj::GetCRC32( uint32_t *iRet ) +bool RageFileObj::GetCRC32( std::uint32_t *iRet ) { if( !m_bCRC32Enabled ) return false; diff --git a/src/RageFileBasic.h b/src/RageFileBasic.h index 389dbef086..996fab9ecc 100644 --- a/src/RageFileBasic.h +++ b/src/RageFileBasic.h @@ -6,6 +6,7 @@ #include "global.h" #include +#include /* This is a simple file I/O interface. Although most of these operations * are straightforward, there are several of them; most of the time, you'll @@ -54,7 +55,7 @@ public: virtual int PutLine( const RString &str ) = 0; virtual void EnableCRC32( bool on=true ) = 0; - virtual bool GetCRC32( uint32_t *iRet ) = 0; + virtual bool GetCRC32( std::uint32_t *iRet ) = 0; virtual int GetFileSize() const = 0; @@ -94,7 +95,7 @@ public: int PutLine( const RString &str ); void EnableCRC32( bool on=true ); - bool GetCRC32( uint32_t *iRet ); + bool GetCRC32( std::uint32_t *iRet ); virtual int GetFileSize() const = 0; virtual int GetFD() { return -1; } @@ -155,7 +156,7 @@ private: * This is only meaningful if EnableCRC32() is called at the very start of the * file, and no seeking is performed. */ bool m_bCRC32Enabled; - uint32_t m_iCRC32; + std::uint32_t m_iCRC32; // Swallow up warnings. If they must be used, define them. RageFileObj& operator=(const RageFileObj& rhs); diff --git a/src/RageFileDriverDeflate.cpp b/src/RageFileDriverDeflate.cpp index 5fff4fb519..dc110ef52f 100644 --- a/src/RageFileDriverDeflate.cpp +++ b/src/RageFileDriverDeflate.cpp @@ -6,6 +6,7 @@ #include "RageUtil.h" #include +#include #include #if defined(_WINDOWS) @@ -313,7 +314,7 @@ int RageFileObjDeflate::FlushInternal() * Parse a .gz file, check the header CRC16 if present, and return the data * CRC32 and a decompressor. pFile will be deleted. */ -RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t *iCRC32 ) +RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, std::uint32_t *iCRC32 ) { std::unique_ptr pFile(pFile_); @@ -335,8 +336,8 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t } } - uint8_t iCompressionMethod = FileReading::read_8( *pFile, sError ); - uint8_t iFlags = FileReading::read_8( *pFile, sError ); + std::uint8_t iCompressionMethod = FileReading::read_8( *pFile, sError ); + std::uint8_t iFlags = FileReading::read_8( *pFile, sError ); FileReading::read_32_le( *pFile, sError ); /* time */ FileReading::read_8( *pFile, sError ); /* xfl */ FileReading::read_8( *pFile, sError ); /* os */ @@ -365,7 +366,7 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t if( iFlags & FEXTRA ) { - int16_t iSize = FileReading::read_16_le( *pFile, sError ); + std::int16_t iSize = FileReading::read_16_le( *pFile, sError ); FileReading::SkipBytes( *pFile, iSize, sError ); } @@ -380,12 +381,12 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t { /* Get the CRC of the data read so far. Be sure to do this before * reading iExpectedCRC16. */ - uint32_t iActualCRC32; + std::uint32_t iActualCRC32; bool bOK = pFile->GetCRC32( &iActualCRC32 ); ASSERT( bOK ); - uint16_t iExpectedCRC16 = FileReading::read_u16_le( *pFile, sError ); - uint16_t iActualCRC16 = int16_t( iActualCRC32 & 0xFFFF ); + std::uint16_t iExpectedCRC16 = FileReading::read_u16_le( *pFile, sError ); + std::uint16_t iActualCRC16 = std::int16_t( iActualCRC32 & 0xFFFF ); if( sError != "" ) return nullptr; @@ -410,8 +411,8 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t FileReading::Seek( *pFile, iFooterPos, sError ); - uint32_t iExpectedCRC32 = FileReading::read_u32_le( *pFile, sError ); - uint32_t iUncompressedSize = FileReading::read_u32_le( *pFile, sError ); + std::uint32_t iExpectedCRC32 = FileReading::read_u32_le( *pFile, sError ); + std::uint32_t iUncompressedSize = FileReading::read_u32_le( *pFile, sError ); if( iCRC32 != nullptr ) *iCRC32 = iExpectedCRC32; @@ -486,12 +487,12 @@ int RageFileObjGzip::Finish() return -1; /* Read the CRC of the data that's been written. */ - uint32_t iCRC; + std::uint32_t iCRC; bool bOK = this->GetCRC32( &iCRC ); ASSERT( bOK ); /* Figure out the size of the data. */ - uint32_t iSize = Tell() - m_iDataStartOffset; + std::uint32_t iSize = Tell() - m_iDataStartOffset; /* Write the CRC and size directly to the file, so they don't get compressed. */ iCRC = Swap32LE( iCRC ); @@ -532,7 +533,7 @@ bool GunzipString( const RString &sIn, RString &sOut, RString &sError ) RageFileObjMem *mem = new RageFileObjMem; mem->PutString( sIn ); - uint32_t iCRC32; + std::uint32_t iCRC32; RageFileBasic *pFile = GunzipFile( mem, sError, &iCRC32 ); if( pFile == nullptr ) return false; diff --git a/src/RageFileDriverDeflate.h b/src/RageFileDriverDeflate.h index 57079c89b2..0294b1580d 100644 --- a/src/RageFileDriverDeflate.h +++ b/src/RageFileDriverDeflate.h @@ -6,6 +6,7 @@ #include "RageFileBasic.h" #include +#include typedef struct z_stream_s z_stream; @@ -69,7 +70,7 @@ private: int m_iDataStartOffset; }; -RageFileObjInflate *GunzipFile( RageFileBasic *pFile, RString &sError, uint32_t *iCRC32 ); +RageFileObjInflate *GunzipFile( RageFileBasic *pFile, RString &sError, std::uint32_t *iCRC32 ); /* Quick helpers: */ void GzipString( const RString &sIn, RString &sOut ); diff --git a/src/RageFileManager.cpp b/src/RageFileManager.cpp index eeb195a335..cbc47d760d 100644 --- a/src/RageFileManager.cpp +++ b/src/RageFileManager.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #if defined(WIN32) @@ -117,7 +118,7 @@ std::size_t zipRead(void *pOpaque, mz_uint64 file_ofs, void *pBuf, std::size_t n RageFile *f = static_cast(pOpaque); const int pos = f->Seek(file_ofs); - if (pos >= 0 && static_cast(pos) != file_ofs) + if (pos >= 0 && static_cast(pos) != file_ofs) { return 0; } diff --git a/src/RageModelGeometry.cpp b/src/RageModelGeometry.cpp index 392664c455..b4730ef47a 100644 --- a/src/RageModelGeometry.cpp +++ b/src/RageModelGeometry.cpp @@ -5,6 +5,8 @@ #include "RageMath.h" #include "RageDisplay.h" +#include + #define MS_MAX_NAME 32 RageModelGeometry::RageModelGeometry () @@ -29,7 +31,7 @@ void RageModelGeometry::OptimizeBones() // check to see if all vertices have the same bone index bool bAllVertsUseSameBone = true; - + char iBoneIndex = mesh.Vertices[0].bone; for (unsigned j = 1; j < mesh.Vertices.size(); j++) @@ -69,8 +71,8 @@ void RageModelGeometry::MergeMeshes( int iFromIndex, int iToIndex ) { for( int j=0; j<3; j++ ) { - uint16_t &iIndex = meshTo.Triangles[i].nVertexIndices[j]; - iIndex = uint16_t(iIndex + iShiftTriangleVertexIndicesBy); + std::uint16_t &iIndex = meshTo.Triangles[i].nVertexIndices[j]; + iIndex = std::uint16_t(iIndex + iShiftTriangleVertexIndicesBy); } } } @@ -147,7 +149,7 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo mesh.sName = szName; // mesh.nFlags = nFlags; - mesh.nMaterialIndex = (uint8_t) nIndex; + mesh.nMaterialIndex = (std::uint8_t) nIndex; mesh.m_iBoneIndex = -1; @@ -190,7 +192,7 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo v.t[0] = v.p[0] / v.t[0]; v.t[1] = v.p[1] / v.t[1]; } - v.bone = (uint8_t) nIndex; + v.bone = (std::uint8_t) nIndex; RageVec3AddToBounds( v.p, m_vMins, m_vMaxs ); } @@ -237,8 +239,8 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo if( f.GetLine( sLine ) <= 0 ) THROW; - uint16_t nIndices[3]; - uint16_t nNormalIndices[3]; + std::uint16_t nIndices[3]; + std::uint16_t nNormalIndices[3]; if( sscanf (sLine, "%d %hu %hu %hu %hu %hu %hu %d", &nFlags, &nIndices[0], &nIndices[1], &nIndices[2], diff --git a/src/RageSound.cpp b/src/RageSound.cpp index f43ff37bd0..d26c9c9db6 100644 --- a/src/RageSound.cpp +++ b/src/RageSound.cpp @@ -37,6 +37,7 @@ #include "RageSoundReader_ThreadedBuffer.h" #include +#include #define samplerate() m_pSource->GetSampleRate() @@ -268,7 +269,7 @@ void RageSound::LoadSoundReader( RageSoundReader *pSound ) * conditions are masked and will be seen on the next call. Otherwise, the requested * number of frames will always be returned. */ -int RageSound::GetDataToPlay( float *pBuffer, int iFrames, int64_t &iStreamFrame, int &iFramesStored ) +int RageSound::GetDataToPlay( float *pBuffer, int iFrames, std::int64_t &iStreamFrame, int &iFramesStored ) { /* We only update m_iStreamFrame; only take a shared lock, so we don't block the main thread. */ // LockMut(m_Mutex); @@ -317,7 +318,7 @@ int RageSound::GetDataToPlay( float *pBuffer, int iFrames, int64_t &iStreamFrame } /* Indicate that a block of audio data has been written to the device. */ -void RageSound::CommitPlayingPosition( int64_t iHardwareFrame, int64_t iStreamFrame, int iGotFrames ) +void RageSound::CommitPlayingPosition( std::int64_t iHardwareFrame, std::int64_t iStreamFrame, int iGotFrames ) { m_Mutex.Lock(); m_HardwareToStreamMap.Insert( iHardwareFrame, iGotFrames, iStreamFrame ); @@ -372,7 +373,7 @@ void RageSound::SoundIsFinishedPlaying() return; /* Get our current hardware position. */ - int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition(nullptr); + std::int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition(nullptr); m_Mutex.Lock(); @@ -474,16 +475,16 @@ float RageSound::GetLengthSeconds() return iLength / 1000.f; // ms -> secs } -int RageSound::GetSourceFrameFromHardwareFrame( int64_t iHardwareFrame, bool *bApproximate ) const +int RageSound::GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame, bool *bApproximate ) const { if( m_HardwareToStreamMap.IsEmpty() || m_StreamToSourceMap.IsEmpty() ) return 0; bool bApprox; - int64_t iStreamFrame = m_HardwareToStreamMap.Search( iHardwareFrame, &bApprox ); + std::int64_t iStreamFrame = m_HardwareToStreamMap.Search( iHardwareFrame, &bApprox ); if( bApproximate && bApprox ) *bApproximate = true; - int64_t iSourceFrame = m_StreamToSourceMap.Search( iStreamFrame, &bApprox ); + std::int64_t iSourceFrame = m_StreamToSourceMap.Search( iStreamFrame, &bApprox ); if( bApproximate && bApprox ) *bApproximate = true; return (int) iSourceFrame; @@ -499,7 +500,7 @@ int RageSound::GetSourceFrameFromHardwareFrame( int64_t iHardwareFrame, bool *bA float RageSound::GetPositionSeconds( bool *bApproximate, RageTimer *pTimestamp ) const { /* Get our current hardware position. */ - int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition( pTimestamp ); + std::int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition( pTimestamp ); /* Lock the mutex after calling SOUNDMAN->GetPosition(). We must not make driver * calls with our mutex locked (driver mutex < sound mutex). */ diff --git a/src/RageSound.h b/src/RageSound.h index 89f1937ce3..beaa33824c 100644 --- a/src/RageSound.h +++ b/src/RageSound.h @@ -7,6 +7,8 @@ #include "RageTimer.h" #include "RageSoundPosMap.h" +#include + class RageSoundReader; struct lua_State; @@ -16,8 +18,8 @@ class RageSoundBase public: virtual ~RageSoundBase() { } virtual void SoundIsFinishedPlaying() = 0; - virtual int GetDataToPlay( float *buffer, int size, int64_t &iStreamFrame, int &got_bytes ) = 0; - virtual void CommitPlayingPosition( int64_t iFrameno, int64_t iPosition, int iBytesRead ) = 0; + virtual int GetDataToPlay( float *buffer, int size, std::int64_t &iStreamFrame, int &got_bytes ) = 0; + virtual void CommitPlayingPosition( std::int64_t iFrameno, std::int64_t iPosition, int iBytesRead ) = 0; virtual RageTimer GetStartTime() const { return RageZeroTimer; } virtual RString GetLoadedFilePath() const = 0; }; @@ -92,7 +94,7 @@ public: * * If cache == false, we'll always stream the sound on demand, which * makes loads much faster. - * + * * If the file failed to load, false is returned, Error() is set * and a null sample will be loaded. This makes failed loads nonfatal; * they can be ignored most of the time, so we continue to work if a file @@ -100,7 +102,7 @@ public: */ bool Load( RString sFile, bool bPrecache, const RageSoundLoadParams *pParams = nullptr ); - /* Using this version means the "don't care" about caching. Currently, + /* Using this version means the "don't care" about caching. Currently, * this always will not cache the sound; this may become a preference. */ bool Load( RString sFile ); @@ -159,12 +161,12 @@ private: /* Current position of the output sound, in frames. If < 0, nothing will play * until it becomes positive. */ - int64_t m_iStreamFrame; + std::int64_t m_iStreamFrame; /* Hack: When we stop a playing sound, we can't ask the driver the position * (we're not playing); and we can't seek back to the current playing position * when we stop (too slow), but we want to be able to report the position we - * were at when we stopped without jumping to the last position we buffered. + * were at when we stopped without jumping to the last position we buffered. * Keep track of the position after a seek or stop, so we can return a sane * position when stopped, and when playing but pos_map hasn't yet been filled. */ int m_iStoppedSourceFrame; @@ -173,7 +175,7 @@ private: RString m_sError; - int GetSourceFrameFromHardwareFrame( int64_t iHardwareFrame, bool *bApproximate = nullptr ) const; + int GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame, bool *bApproximate = nullptr ) const; bool SetPositionFrames( int frames = -1 ); RageSoundParams::StopMode_t GetStopMode() const; // resolves M_AUTO @@ -187,8 +189,8 @@ public: * it signals the stream to stop; once it's flushed, SoundStopped will be * called. Until then, SOUNDMAN->GetPosition can still be called; the sound * is still playing. */ - int GetDataToPlay( float *pBuffer, int iSize, int64_t &iStreamFrame, int &iBytesRead ); - void CommitPlayingPosition( int64_t iHardwareFrame, int64_t iStreamFrame, int iGotFrames ); + int GetDataToPlay( float *pBuffer, int iSize, std::int64_t &iStreamFrame, int &iBytesRead ); + void CommitPlayingPosition( std::int64_t iHardwareFrame, std::int64_t iStreamFrame, int iGotFrames ); }; #endif diff --git a/src/RageSoundManager.cpp b/src/RageSoundManager.cpp index 8ed8f892ad..1723d32915 100644 --- a/src/RageSoundManager.cpp +++ b/src/RageSoundManager.cpp @@ -21,6 +21,8 @@ #include "arch/Sound/RageSoundDriver.h" +#include + /* * The lock ordering requirements are: * RageSound::Lock before g_SoundManMutex @@ -98,7 +100,7 @@ bool RageSoundManager::Pause( RageSoundBase *pSound, bool bPause ) return m_pDriver->PauseMixing( pSound, bPause ); } -int64_t RageSoundManager::GetPosition( RageTimer *pTimer ) const +std::int64_t RageSoundManager::GetPosition( RageTimer *pTimer ) const { if( m_pDriver == nullptr ) return 0; @@ -112,7 +114,7 @@ void RageSoundManager::Update() { std::map::iterator it, next; it = m_mapPreloadedSounds.begin(); - + while( it != m_mapPreloadedSounds.end() ) { next = it; ++next; @@ -179,7 +181,7 @@ void RageSoundManager::AddLoadedSound( const RString &sPath_, RageSoundReader_Pr std::map::const_iterator it; it = m_mapPreloadedSounds.find( sPath ); ASSERT_M( it == m_mapPreloadedSounds.end(), sPath ); - + m_mapPreloadedSounds[sPath] = pSound->Copy(); } diff --git a/src/RageSoundManager.h b/src/RageSoundManager.h index a5998e8d2a..72b58ebefe 100644 --- a/src/RageSoundManager.h +++ b/src/RageSoundManager.h @@ -3,10 +3,12 @@ #ifndef RAGE_SOUND_MANAGER_H #define RAGE_SOUND_MANAGER_H -#include -#include #include "RageUtil_CircularBuffer.h" +#include +#include +#include + class RageSound; class RageSoundBase; class RageSoundDriver; @@ -37,7 +39,7 @@ public: void StartMixing( RageSoundBase *snd ); /* used by RageSound */ void StopMixing( RageSoundBase *snd ); /* used by RageSound */ bool Pause( RageSoundBase *snd, bool bPause ); /* used by RageSound */ - int64_t GetPosition( RageTimer *pTimer ) const; /* used by RageSound */ + std::int64_t GetPosition( RageTimer *pTimer ) const; /* used by RageSound */ float GetPlayLatency() const; int GetDriverSampleRate() const; diff --git a/src/RageSoundMixBuffer.cpp b/src/RageSoundMixBuffer.cpp index 17c7355c7d..78ce49873b 100644 --- a/src/RageSoundMixBuffer.cpp +++ b/src/RageSoundMixBuffer.cpp @@ -3,6 +3,7 @@ #include "RageUtil.h" #include +#include #if defined(MACOSX) #include "archutils/Darwin/VectorHelper.h" @@ -75,7 +76,7 @@ void RageSoundMixBuffer::write( const float *pBuf, unsigned iSize, int iSourceSt } } -void RageSoundMixBuffer::read( int16_t *pBuf ) +void RageSoundMixBuffer::read( std::int16_t *pBuf ) { for( unsigned iPos = 0; iPos < m_iBufUsed; ++iPos ) { diff --git a/src/RageSoundMixBuffer.h b/src/RageSoundMixBuffer.h index 0634680364..020f0a39d3 100644 --- a/src/RageSoundMixBuffer.h +++ b/src/RageSoundMixBuffer.h @@ -3,6 +3,8 @@ #ifndef RAGE_SOUND_MIX_BUFFER_H #define RAGE_SOUND_MIX_BUFFER_H +#include + class RageSoundMixBuffer { public: @@ -15,7 +17,7 @@ public: /* Extend the buffer as if write() was called with a buffer of silence. */ void Extend( unsigned iSamples ); - void read( int16_t *pBuf ); + void read( std::int16_t *pBuf ); void read( float *pBuf ); void read_deinterlace( float **pBufs, int channels ); float *read() { return m_pMixbuf; } diff --git a/src/RageSoundPosMap.cpp b/src/RageSoundPosMap.cpp index c710f13a23..4cd779ab3e 100644 --- a/src/RageSoundPosMap.cpp +++ b/src/RageSoundPosMap.cpp @@ -6,6 +6,7 @@ #include #include +#include #include /* The number of frames we should keep pos_map data for. This being too high @@ -14,8 +15,8 @@ const int pos_map_backlog_frames = 100000; struct pos_map_t { - int64_t m_iSourceFrame; - int64_t m_iDestFrame; + std::int64_t m_iSourceFrame; + std::int64_t m_iDestFrame; int m_iFrames; float m_fSourceToDestRatio; @@ -53,7 +54,7 @@ pos_map_queue &pos_map_queue::operator=( const pos_map_queue &rhs ) return *this; } -void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFrame, float fSourceToDestRatio ) +void pos_map_queue::Insert( std::int64_t iSourceFrame, int iFrames, std::int64_t iDestFrame, float fSourceToDestRatio ) { if( !m_pImpl->m_Queue.empty() ) { @@ -120,7 +121,7 @@ void pos_map_impl::Cleanup() m_Queue.erase( m_Queue.begin(), it ); } -int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const +std::int64_t pos_map_queue::Search( std::int64_t iSourceFrame, bool *bApproximate ) const { if( bApproximate ) *bApproximate = false; @@ -134,7 +135,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const /* iSourceFrame is probably in pos_map. Search to figure out what position * it maps to. */ - int64_t iClosestPosition = 0, iClosestPositionDist = INT_MAX; + std::int64_t iClosestPosition = 0, iClosestPositionDist = INT_MAX; const pos_map_t *pClosestBlock = &*m_pImpl->m_Queue.begin(); /* print only */ for (pos_map_t const &pm : m_pImpl->m_Queue) { @@ -149,7 +150,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const } /* See if the current position is close to the beginning of this block. */ - int64_t dist = llabs( pm.m_iSourceFrame - iSourceFrame ); + std::int64_t dist = llabs( pm.m_iSourceFrame - iSourceFrame ); if( dist < iClosestPositionDist ) { iClosestPositionDist = dist; diff --git a/src/RageSoundPosMap.h b/src/RageSoundPosMap.h index 006d712243..98201fab0b 100644 --- a/src/RageSoundPosMap.h +++ b/src/RageSoundPosMap.h @@ -3,6 +3,8 @@ #ifndef RAGE_SOUND_POS_MAP_H #define RAGE_SOUND_POS_MAP_H +#include + struct pos_map_impl; class pos_map_queue { @@ -13,10 +15,10 @@ public: pos_map_queue &operator=( const pos_map_queue &rhs ); /* Insert a mapping from iSourceFrame to iDestFrame, containing iFrames. */ - void Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFrame, float fSourceToDestRatio = 1.0f ); + void Insert( std::int64_t iSourceFrame, int iFrames, std::int64_t iDestFrame, float fSourceToDestRatio = 1.0f ); /* Return the iDestFrame for the given iSourceFrame. */ - int64_t Search( int64_t iSourceFrame, bool *bApproximate ) const; + std::int64_t Search( std::int64_t iSourceFrame, bool *bApproximate ) const; /* Erase all mappings. */ void Clear(); diff --git a/src/RageSoundReader_Chain.h b/src/RageSoundReader_Chain.h index da2eb6801e..b48057253c 100644 --- a/src/RageSoundReader_Chain.h +++ b/src/RageSoundReader_Chain.h @@ -5,6 +5,7 @@ #include "RageSoundReader.h" +#include #include class RageSoundReader_Chain: public RageSoundReader @@ -30,7 +31,7 @@ public: /* Return the number of added sounds. */ int GetNumSounds() const { return m_aSounds.size(); } - + int GetLength() const; int GetLength_Fast() const; int SetPosition( int iFrame ); @@ -59,7 +60,7 @@ private: float fPan; RageSoundReader *pSound; // nullptr if not activated - int GetOffsetFrame( int iSampleRate ) const { return int( int64_t(iOffsetMS) * iSampleRate / 1000 ); } + int GetOffsetFrame( int iSampleRate ) const { return int( std::int64_t(iOffsetMS) * iSampleRate / 1000 ); } bool operator<( const Sound &rhs ) const { return iOffsetMS < rhs.iOffsetMS; } }; std::vector m_aSounds; diff --git a/src/RageSoundReader_MP3.cpp b/src/RageSoundReader_MP3.cpp index 8d15a43c6e..804bfc8ebc 100644 --- a/src/RageSoundReader_MP3.cpp +++ b/src/RageSoundReader_MP3.cpp @@ -5,8 +5,9 @@ #include "RageLog.h" #include "RageUtil.h" -#include #include +#include +#include #include #include "mad.h" @@ -188,7 +189,7 @@ struct madlib_t bitrate = 0; } - uint8_t inbuf[16384]; + std::uint8_t inbuf[16384]; float outbuf[8192]; int outpos; unsigned outleft; @@ -213,7 +214,7 @@ struct madlib_t return mad_timer_compare( timer1, timer2 ) < 0; } }; - + typedef std::map tocmap_t; tocmap_t tocmap; @@ -283,7 +284,7 @@ bool RageSoundReader_MP3::handle_first_frame() /* * "Info" tags are written by some tools. They're just Xing tags, but for * CBR files. - * + * * However, DWI's decoder, BASS, doesn't understand this, and treats it as a * corrupt frame, outputting a frame of silence. Let's ignore the tag, so * it'll be treated as an invalid frame, so we match DWI sync. @@ -458,7 +459,7 @@ int RageSoundReader_MP3::do_mad_frame_decode( bool headers_only ) continue; } - /* We've decoded the first frame of data. + /* We've decoded the first frame of data. * * We want mad->Timer to represent the timestamp of the first sample of the * currently decoded frame. Don't increment mad->Timer on the first frame, @@ -730,7 +731,7 @@ int RageSoundReader_MP3::Read( float *buf, int iFrames ) bool RageSoundReader_MP3::MADLIB_rewind() { m_pFile->Seek(0); - + mad_frame_mute(&mad->Frame); mad_synth_mute(&mad->Synth); mad_timer_reset(&mad->Timer); @@ -765,7 +766,7 @@ bool RageSoundReader_MP3::MADLIB_rewind() * 3. We can seek from any position to any higher position by decoding headers. * (SetPosition_hard) * - * Both 1 and 2 will leave the position behind the actual requested position; + * Both 1 and 2 will leave the position behind the actual requested position; * combine them with 3 to catch up. Never do 3 alone in "fast" mode, since it's * slow if it ends up seeking from the beginning of the file. Never do 2 in * "precise" mode. @@ -867,7 +868,7 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame ) * already decoded the frame, synth it, too. */ mad_timer_t next_frame_timer = mad->Timer; mad_timer_add( &next_frame_timer, mad->framelength ); - + if( mad_timer_compare(desired, next_frame_timer) < 0 ) { if( !synthed ) @@ -937,7 +938,7 @@ int RageSoundReader_MP3::SetPosition_estimate( int iFrame ) seekpos += mad->header_bytes; seek_stream_to_byte( seekpos ); - /* We've jumped across the file, so the decoder is currently desynced. + /* We've jumped across the file, so the decoder is currently desynced. * Don't use resync(); it's slow. Just decode a few frames. */ for( int i = 0; i < 2; ++i ) { @@ -965,7 +966,7 @@ int RageSoundReader_MP3::SetPosition( int iFrame ) int ret = SetPosition_toc( iFrame, false ); if( ret <= 0 ) return ret; /* it set the error */ - + /* Align exactly. */ return SetPosition_hard( iFrame ); } diff --git a/src/RageSoundReader_Preload.cpp b/src/RageSoundReader_Preload.cpp index 46f40b0b64..cea2af8a62 100644 --- a/src/RageSoundReader_Preload.cpp +++ b/src/RageSoundReader_Preload.cpp @@ -8,6 +8,7 @@ #include "Preference.h" #include +#include /* If true, preloaded sounds are stored in 16-bit instead of floats. Most * processing happens after preloading, and it's usually a waste to store high- @@ -17,7 +18,7 @@ Preference g_bSoundPreload16bit( "SoundPreload16bit", true ); /* If a sound is smaller than this, we'll load it entirely into memory. */ Preference g_iSoundPreloadMaxSamples( "SoundPreloadMaxSamples", 1024*1024 ); -#define samplesize (m_bBufferIs16Bit? sizeof(int16_t):sizeof(float)) +#define samplesize (m_bBufferIs16Bit? sizeof(std::int16_t):sizeof(float)) #define framesize (samplesize * m_iChannels) bool RageSoundReader_Preload::PreloadSound( RageSoundReader *&pSound ) @@ -92,7 +93,7 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource ) /* Add the buffer. */ if( m_bBufferIs16Bit ) { - int16_t buffer16[1024]; + std::int16_t buffer16[1024]; RageSoundUtil::ConvertFloatToNativeInt16( buffer, buffer16, iCnt*m_iChannels ); m_Buffer.Get()->append( (char *) buffer16, (char *) (buffer16+iCnt*m_iChannels) ); } @@ -151,7 +152,7 @@ int RageSoundReader_Preload::Read( float *pBuffer, int iFrames ) return END_OF_FILE; if( m_bBufferIs16Bit ) { - const int16_t *pIn = (const int16_t *) (m_Buffer->data() + (m_iPosition * framesize)); + const std::int16_t *pIn = (const std::int16_t *) (m_Buffer->data() + (m_iPosition * framesize)); RageSoundUtil::ConvertNativeInt16ToFloat( pIn, pBuffer, iFrames * m_iChannels ); } else diff --git a/src/RageSoundReader_Resample_Good.cpp b/src/RageSoundReader_Resample_Good.cpp index eca5ab418c..ce5ce88a65 100644 --- a/src/RageSoundReader_Resample_Good.cpp +++ b/src/RageSoundReader_Resample_Good.cpp @@ -14,6 +14,7 @@ #include #include +#include #include /* Filter length. This must be a power of 2. */ @@ -538,7 +539,7 @@ private: int RageSoundReader_Resample_Good::GetNextSourceFrame() const { - int64_t iPosition = m_pSource->GetNextSourceFrame(); + std::int64_t iPosition = m_pSource->GetNextSourceFrame(); iPosition -= m_apResamplers[0]->GetFilled(); iPosition *= m_iSampleRate; @@ -638,7 +639,7 @@ RageSoundReader_Resample_Good::~RageSoundReader_Resample_Good() int RageSoundReader_Resample_Good::SetPosition( int iFrame ) { Reset(); - iFrame = (int) SCALE( iFrame, 0, (int64_t) m_iSampleRate, 0, (int64_t) m_pSource->GetSampleRate() ); + iFrame = (int) SCALE( iFrame, 0, (std::int64_t) m_iSampleRate, 0, (std::int64_t) m_pSource->GetSampleRate() ); return m_pSource->SetPosition( iFrame ); } diff --git a/src/RageSoundReader_Vorbisfile.cpp b/src/RageSoundReader_Vorbisfile.cpp index fca7869e1a..124f2145e5 100644 --- a/src/RageSoundReader_Vorbisfile.cpp +++ b/src/RageSoundReader_Vorbisfile.cpp @@ -13,6 +13,7 @@ #include #include +#include #include static std::size_t OggRageFile_read_func( void *ptr, std::size_t size, std::size_t nmemb, void *datasource ) @@ -184,7 +185,7 @@ int RageSoundReader_Vorbisfile::Read( float *buf, int iFrames ) { int bstream; #if defined(INTEGER_VORBIS) - int ret = ov_read( vf, (char *) buf, iFrames * channels * sizeof(int16_t), &bstream ); + int ret = ov_read( vf, (char *) buf, iFrames * channels * sizeof(std::int16_t), &bstream ); #else // float vorbis decoder float **pcm; int ret = ov_read_float( vf, &pcm, iFrames, &bstream ); @@ -217,11 +218,11 @@ int RageSoundReader_Vorbisfile::Read( float *buf, int iFrames ) #if defined(INTEGER_VORBIS) if( ret > 0 ) { - int iSamplesRead = ret / sizeof(int16_t); + int iSamplesRead = ret / sizeof(std::int16_t); iFramesRead = iSamplesRead / channels; /* Convert in reverse, so we can do it in-place. */ - const int16_t *pIn = (int16_t *) buf; + const std::int16_t *pIn = (std::int16_t *) buf; float *pOut = (float *) buf; for( int i = iSamplesRead-1; i >= 0; --i ) pOut[i] = pIn[i] / 32768.0f; diff --git a/src/RageSoundReader_WAV.cpp b/src/RageSoundReader_WAV.cpp index 5f7908d82d..b65aab0cab 100644 --- a/src/RageSoundReader_WAV.cpp +++ b/src/RageSoundReader_WAV.cpp @@ -15,6 +15,8 @@ #include "RageLog.h" #include "RageFileBasic.h" +#include + namespace { /* pBuf contains iSamples 8-bit samples; convert to 16-bit. pBuf must @@ -22,7 +24,7 @@ namespace void Convert8bitToFloat( void *pBuf, int iSamples ) { /* Convert in reverse, so we can do it in-place. */ - const uint8_t *pIn = (uint8_t *) pBuf; + const std::uint8_t *pIn = (std::uint8_t *) pBuf; float *pOut = (float *) pBuf; for( int i = iSamples-1; i >= 0; --i ) { @@ -37,11 +39,11 @@ namespace void ConvertLittleEndian16BitToFloat( void *pBuf, int iSamples ) { /* Convert in reverse, so we can do it in-place. */ - const int16_t *pIn = (int16_t *) pBuf; + const std::int16_t *pIn = (std::int16_t *) pBuf; float *pOut = (float *) pBuf; for( int i = iSamples-1; i >= 0; --i ) { - int16_t iSample = Swap16LE( pIn[i] ); + std::int16_t iSample = Swap16LE( pIn[i] ); pOut[i] = iSample / 32768.0f; } } @@ -56,7 +58,7 @@ namespace { pIn -= 3; - int32_t iSample = + std::int32_t iSample = (int(pIn[0]) << 0) | (int(pIn[1]) << 8) | (int(pIn[2]) << 16); @@ -72,11 +74,11 @@ namespace void ConvertLittleEndian32BitToFloat( void *pBuf, int iSamples ) { /* Convert in reverse, so we can do it in-place. */ - const int32_t *pIn = (int32_t *) pBuf; + const std::int32_t *pIn = (std::int32_t *) pBuf; float *pOut = (float *) pBuf; for( int i = iSamples-1; i >= 0; --i ) { - int32_t iSample = Swap32LE( pIn[i] ); + std::int32_t iSample = Swap32LE( pIn[i] ); pOut[i] = iSample / 2147483648.0f; } } @@ -163,13 +165,13 @@ struct WavReaderPCM: public WavReader int GetLength() const { const int iBytesPerSec = m_WavData.m_iSampleRate * m_WavData.m_iChannels * m_WavData.m_iBitsPerSample / 8; - int64_t iMS = (int64_t(m_WavData.m_iDataChunkSize) * 1000) / iBytesPerSec; + std::int64_t iMS = (std::int64_t(m_WavData.m_iDataChunkSize) * 1000) / iBytesPerSec; return (int) iMS; } int SetPosition( int iFrame ) { - int iByte = (int) (int64_t(iFrame) * m_WavData.m_iChannels * m_WavData.m_iBitsPerSample / 8); + int iByte = (int) (std::int64_t(iFrame) * m_WavData.m_iChannels * m_WavData.m_iBitsPerSample / 8); if( iByte > m_WavData.m_iDataChunkSize ) { m_File.Seek( m_WavData.m_iDataChunkSize+m_WavData.m_iDataChunkPos ); @@ -192,11 +194,11 @@ struct WavReaderPCM: public WavReader struct WavReaderADPCM: public WavReader { public: - std::vector m_iaCoef1, m_iaCoef2; - int16_t m_iFramesPerBlock; + std::vector m_iaCoef1, m_iaCoef2; + std::int16_t m_iFramesPerBlock; float *m_pBuffer; int m_iBufferAvail, m_iBufferUsed; - + WavReaderADPCM( RageFileBasic &f, const RageSoundReader_WAV::WavData &data ): WavReader(f, data) { @@ -219,7 +221,7 @@ public: m_File.Seek( m_WavData.m_iExtraFmtPos ); m_iFramesPerBlock = FileReading::read_16_le( m_File, m_sError ); - int16_t iNumCoef = FileReading::read_16_le( m_File, m_sError ); + std::int16_t iNumCoef = FileReading::read_16_le( m_File, m_sError ); m_iaCoef1.resize( iNumCoef ); m_iaCoef2.resize( iNumCoef ); for( int i = 0; i < iNumCoef; ++i ) @@ -255,8 +257,8 @@ public: if( m_File.Tell() >= m_WavData.m_iDataChunkSize+m_WavData.m_iDataChunkPos || m_File.AtEOF() ) return true; /* past the data chunk */ - int8_t iPredictor[2]; - int16_t iDelta[2], iSamp1[2], iSamp2[2]; + std::int8_t iPredictor[2]; + std::int16_t iDelta[2], iSamp1[2], iSamp2[2]; for( int i = 0; i < m_WavData.m_iChannels; ++i ) iPredictor[i] = FileReading::read_8( m_File, m_sError ); for( int i = 0; i < m_WavData.m_iChannels; ++i ) @@ -300,12 +302,12 @@ public: } for( int i = 0; i < m_WavData.m_iChannels; ++i ) - pBuffer[m_iBufferAvail++] = (int16_t)iSamp2[i] / 32768.0f; + pBuffer[m_iBufferAvail++] = (std::int16_t)iSamp2[i] / 32768.0f; for( int i = 0; i < m_WavData.m_iChannels; ++i ) - pBuffer[m_iBufferAvail++] = (int16_t)iSamp1[i] / 32768.0f; + pBuffer[m_iBufferAvail++] = (std::int16_t)iSamp1[i] / 32768.0f; - int8_t iBufSize = 0; - uint8_t iBuf = 0; + std::int8_t iBufSize = 0; + std::uint8_t iBuf = 0; bool bDone = false; for( int i = 2; !bDone && i < m_iFramesPerBlock; ++i ) @@ -326,39 +328,39 @@ public: } /* Store the nibble in signed char, so we get an arithmetic shift. */ - int8_t iErrorDelta = (int8_t)(iBuf) >> 4; - uint8_t iErrorDeltaUnsigned = iBuf >> 4; + std::int8_t iErrorDelta = (std::int8_t)(iBuf) >> 4; + std::uint8_t iErrorDeltaUnsigned = iBuf >> 4; iBuf <<= 4; --iBufSize; - int32_t iPredSample = (iSamp1[c] * iCoef1[c] + iSamp2[c] * iCoef2[c]) / (1<<8); + std::int32_t iPredSample = (iSamp1[c] * iCoef1[c] + iSamp2[c] * iCoef2[c]) / (1<<8); if( iPredSample < -32768 ) iPredSample = -32768; if( iPredSample > 32767 ) iPredSample = 32767; - - int16_t iNewSample = (int16_t)iPredSample + (iDelta[c] * iErrorDelta); + + std::int16_t iNewSample = (std::int16_t)iPredSample + (iDelta[c] * iErrorDelta); pBuffer[m_iBufferAvail++] = iNewSample / 32768.0f; static const int aAdaptionTable[] = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; - iDelta[c] = int16_t( (iDelta[c] * aAdaptionTable[iErrorDeltaUnsigned]) / (1<<8) ); - iDelta[c] = std::max( (int16_t) 16, iDelta[c] ); - + iDelta[c] = std::int16_t( (iDelta[c] * aAdaptionTable[iErrorDeltaUnsigned]) / (1<<8) ); + iDelta[c] = std::max( (std::int16_t) 16, iDelta[c] ); + iSamp2[c] = iSamp1[c]; iSamp1[c] = iNewSample; } } - + return true; } int Read( float *buf, int iFrames ) { int iGotFrames = 0; - + int iSample = 0; - + while( iGotFrames < (int) iFrames ) { if( m_iBufferUsed == m_iBufferAvail ) @@ -386,7 +388,7 @@ public: { const int iNumWholeBlocks = m_WavData.m_iDataChunkSize / m_WavData.m_iBlockAlign; const int iExtraBytes = m_WavData.m_iDataChunkSize - (iNumWholeBlocks*m_WavData.m_iBlockAlign); - + int iFrames = iNumWholeBlocks * m_iFramesPerBlock; const int iBlockHeaderSize = 7 * m_WavData.m_iChannels; @@ -394,11 +396,11 @@ public: { const int iExtraADPCMNibbles = std::max( 0, iExtraBytes-iBlockHeaderSize )*2; const int iExtraADPCMFrames = iExtraADPCMNibbles/m_WavData.m_iChannels; - + iFrames += 2+iExtraADPCMFrames; } - int iMS = int((int64_t(iFrames)*1000)/m_WavData.m_iSampleRate); + int iMS = int((std::int64_t(iFrames)*1000)/m_WavData.m_iSampleRate); return iMS; } @@ -441,7 +443,7 @@ public: int iFrame = iBlock * m_iFramesPerBlock; int iBufferRemainingBytes = m_iBufferAvail - m_iBufferUsed; - int iBufferRemainingFrames = iBufferRemainingBytes / (m_WavData.m_iChannels * sizeof(int16_t)); + int iBufferRemainingFrames = iBufferRemainingBytes / (m_WavData.m_iChannels * sizeof(std::int16_t)); iFrame -= iBufferRemainingFrames; return iFrame; @@ -492,7 +494,7 @@ RageSoundReader_FileReader::OpenResult RageSoundReader_WAV::Open( RageFileBasic while( !bGotFormatChunk || !bGotDataChunk ) { RString ChunkID = ReadString( *m_pFile, 4, sError ); - int32_t iChunkSize = FileReading::read_32_le( *m_pFile, sError ); + std::int32_t iChunkSize = FileReading::read_32_le( *m_pFile, sError ); if( sError.size() != 0 ) { @@ -625,7 +627,7 @@ RageSoundReader_WAV *RageSoundReader_WAV::Copy() const /* * (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 @@ -635,7 +637,7 @@ RageSoundReader_WAV *RageSoundReader_WAV::Copy() 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 diff --git a/src/RageSoundReader_WAV.h b/src/RageSoundReader_WAV.h index 53cf48d18d..9b03dc915f 100644 --- a/src/RageSoundReader_WAV.h +++ b/src/RageSoundReader_WAV.h @@ -6,6 +6,8 @@ #include "RageSoundReader_FileReader.h" #include "RageFile.h" +#include + struct WavReader; RString ReadString( RageFileBasic &f, int iSize, RString &sError ); @@ -28,8 +30,8 @@ public: struct WavData { - int32_t m_iDataChunkPos, m_iDataChunkSize, m_iExtraFmtPos, m_iSampleRate, m_iFormatTag; - int16_t m_iChannels, m_iBitsPerSample, m_iBlockAlign, m_iExtraFmtBytes; + std::int32_t m_iDataChunkPos, m_iDataChunkSize, m_iExtraFmtPos, m_iSampleRate, m_iFormatTag; + std::int16_t m_iChannels, m_iBitsPerSample, m_iBlockAlign, m_iExtraFmtBytes; }; private: @@ -43,7 +45,7 @@ private: /* * (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 @@ -53,7 +55,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 diff --git a/src/RageSoundUtil.cpp b/src/RageSoundUtil.cpp index 3c7f8ad785..99c40ccd8e 100644 --- a/src/RageSoundUtil.cpp +++ b/src/RageSoundUtil.cpp @@ -3,6 +3,7 @@ #include "RageUtil.h" #include +#include void RageSoundUtil::Attenuate( float *pBuf, int iSamples, float fVolume ) { @@ -81,7 +82,7 @@ void RageSoundUtil::ConvertMonoToStereoInPlace( float *data, int iFrames ) } } -void RageSoundUtil::ConvertNativeInt16ToFloat( const int16_t *pFrom, float *pTo, int iSamples ) +void RageSoundUtil::ConvertNativeInt16ToFloat( const std::int16_t *pFrom, float *pTo, int iSamples ) { for( int i = 0; i < iSamples; ++i ) { @@ -89,7 +90,7 @@ void RageSoundUtil::ConvertNativeInt16ToFloat( const int16_t *pFrom, float *pTo, } } -void RageSoundUtil::ConvertFloatToNativeInt16( const float *pFrom, int16_t *pTo, int iSamples ) +void RageSoundUtil::ConvertFloatToNativeInt16( const float *pFrom, std::int16_t *pTo, int iSamples ) { for( int i = 0; i < iSamples; ++i ) { diff --git a/src/RageSoundUtil.h b/src/RageSoundUtil.h index 6f92742bfc..067d3f72e4 100644 --- a/src/RageSoundUtil.h +++ b/src/RageSoundUtil.h @@ -1,5 +1,8 @@ #ifndef RAGE_SOUND_UTIL_H #define RAGE_SOUND_UTIL_H + +#include + /** @brief Simple utilities that operate on sound buffers. */ namespace RageSoundUtil { @@ -7,8 +10,8 @@ namespace RageSoundUtil void Pan( float *pBuffer, int iFrames, float fPos ); void Fade( float *pBuffer, int iFrames, int iChannels, float fStartVolume, float fEndVolume ); void ConvertMonoToStereoInPlace( float *pBuffer, int iFrames ); - void ConvertNativeInt16ToFloat( const int16_t *pFrom, float *pTo, int iSamples ); - void ConvertFloatToNativeInt16( const float *pFrom, int16_t *pTo, int iSamples ); + void ConvertNativeInt16ToFloat( const std::int16_t *pFrom, float *pTo, int iSamples ); + void ConvertFloatToNativeInt16( const float *pFrom, std::int16_t *pTo, int iSamples ); }; #endif diff --git a/src/RageSurface.cpp b/src/RageSurface.cpp index 1fbefe6469..45d9ea9bff 100644 --- a/src/RageSurface.cpp +++ b/src/RageSurface.cpp @@ -4,9 +4,10 @@ #include #include +#include -int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const +std::int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const { for( int i = 0; i < ncolors; ++i ) if( colors[i] == color ) @@ -15,7 +16,7 @@ int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const } /* XXX: untested */ -int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) const +std::int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) const { int iBest = -1; int iBestDist = INT_MAX; @@ -60,7 +61,7 @@ RageSurfaceFormat::RageSurfaceFormat( const RageSurfaceFormat &cpy ): } } -void RageSurfaceFormat::GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b ) const +void RageSurfaceFormat::GetRGB( std::uint32_t val, std::uint8_t *r, std::uint8_t *g, std::uint8_t *b ) const { if( BytesPerPixel == 1 ) { @@ -69,21 +70,21 @@ void RageSurfaceFormat::GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b *g = palette->colors[val].g; *b = palette->colors[val].b; } else { - *r = int8_t( (val & Mask[0]) >> Shift[0] << Loss[0] ); - *g = int8_t( (val & Mask[1]) >> Shift[1] << Loss[1] ); - *b = int8_t( (val & Mask[2]) >> Shift[2] << Loss[2] ); + *r = std::int8_t( (val & Mask[0]) >> Shift[0] << Loss[0] ); + *g = std::int8_t( (val & Mask[1]) >> Shift[1] << Loss[1] ); + *b = std::int8_t( (val & Mask[2]) >> Shift[2] << Loss[2] ); } } -bool RageSurfaceFormat::MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val ) const +bool RageSurfaceFormat::MapRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint32_t &val ) const { if( BytesPerPixel == 1 ) { RageSurfaceColor c( r, g, b, a ); - int32_t n = palette->FindColor( c ); + std::int32_t n = palette->FindColor( c ); if( n == -1 ) return false; - val = (uint32_t) n; + val = (std::uint32_t) n; } else { val = (r >> Loss[0] << Shift[0]) | @@ -136,7 +137,7 @@ RageSurface::RageSurface( const RageSurface &cpy ) pixels_owned = true; if( cpy.pixels ) { - pixels = new uint8_t[ pitch*h ]; + pixels = new std::uint8_t[ pitch*h ]; memcpy( pixels, cpy.pixels, pitch*h ); } else @@ -149,7 +150,7 @@ RageSurface::~RageSurface() delete [] pixels; } -static int GetShiftFromMask( uint32_t mask ) +static int GetShiftFromMask( std::uint32_t mask ) { if( !mask ) return 0; @@ -163,7 +164,7 @@ static int GetShiftFromMask( uint32_t mask ) return iShift; } -static int GetBitsFromMask( uint32_t mask ) +static int GetBitsFromMask( std::uint32_t mask ) { if( !mask ) return 0; @@ -181,7 +182,7 @@ static int GetBitsFromMask( uint32_t mask ) void SetupFormat( RageSurfaceFormat &fmt, - int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask ) + int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask ) { fmt.BitsPerPixel = BitsPerPixel; fmt.BytesPerPixel = BitsPerPixel/8; @@ -208,14 +209,14 @@ void SetupFormat( RageSurfaceFormat &fmt, fmt.Shift[2] = GetShiftFromMask( Bmask ); fmt.Shift[3] = GetShiftFromMask( Amask ); - fmt.Loss[0] = (uint8_t) (8-GetBitsFromMask( Rmask )); - fmt.Loss[1] = (uint8_t) (8-GetBitsFromMask( Gmask )); - fmt.Loss[2] = (uint8_t) (8-GetBitsFromMask( Bmask )); - fmt.Loss[3] = (uint8_t) (8-GetBitsFromMask( Amask )); + fmt.Loss[0] = (std::uint8_t) (8-GetBitsFromMask( Rmask )); + fmt.Loss[1] = (std::uint8_t) (8-GetBitsFromMask( Gmask )); + fmt.Loss[2] = (std::uint8_t) (8-GetBitsFromMask( Bmask )); + fmt.Loss[3] = (std::uint8_t) (8-GetBitsFromMask( Amask )); } } -RageSurface *CreateSurface( int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask ) +RageSurface *CreateSurface( int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask ) { RageSurface *pImg = new RageSurface; @@ -225,7 +226,7 @@ RageSurface *CreateSurface( int width, int height, int BitsPerPixel, uint32_t Rm pImg->h = height; pImg->flags = 0; pImg->pitch = width*BitsPerPixel/8; - pImg->pixels = new uint8_t[ pImg->pitch*height ]; + pImg->pixels = new std::uint8_t[ pImg->pitch*height ]; /* if( BitsPerPixel == 8 ) @@ -237,7 +238,7 @@ RageSurface *CreateSurface( int width, int height, int BitsPerPixel, uint32_t Rm return pImg; } -RageSurface *CreateSurfaceFrom( int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask, uint8_t *pPixels, uint32_t pitch ) +RageSurface *CreateSurfaceFrom( int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask, std::uint8_t *pPixels, std::uint32_t pitch ) { RageSurface *pImg = new RageSurface; diff --git a/src/RageSurface.h b/src/RageSurface.h index cac482672b..cb4bbd0d18 100644 --- a/src/RageSurface.h +++ b/src/RageSurface.h @@ -4,14 +4,15 @@ #define RAGE_SURFACE_H #include +#include #include /* XXX remove? */ -struct RageSurfaceColor +struct RageSurfaceColor { - uint8_t r, g, b, a; + std::uint8_t r, g, b, a; RageSurfaceColor(): r(0), g(0), b(0), a(0) { } - RageSurfaceColor( uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ ): + RageSurfaceColor( std::uint8_t r_, std::uint8_t g_, std::uint8_t b_, std::uint8_t a_ ): r(r_), g(g_), b(b_), a(a_) { } }; @@ -29,14 +30,14 @@ inline bool operator!=(RageSurfaceColor const &lhs, RageSurfaceColor const &rhs) return !operator==(lhs, rhs); } -struct RageSurfacePalette +struct RageSurfacePalette { RageSurfaceColor colors[256]; - int32_t ncolors; + std::int32_t ncolors; /* Find the exact color; returns -1 if not found. */ - int32_t FindColor( const RageSurfaceColor &color ) const; - int32_t FindClosestColor( const RageSurfaceColor &color ) const; + std::int32_t FindColor( const RageSurfaceColor &color ) const; + std::int32_t FindClosestColor( const RageSurfaceColor &color ) const; }; struct RageSurfaceFormat @@ -45,25 +46,25 @@ struct RageSurfaceFormat RageSurfaceFormat( const RageSurfaceFormat &cpy ); ~RageSurfaceFormat() = default; - int32_t BytesPerPixel; - int32_t BitsPerPixel; - std::array Mask; - std::array Shift; - std::array Loss; - uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */ - uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */ + std::int32_t BytesPerPixel; + std::int32_t BitsPerPixel; + std::array Mask; + std::array Shift; + std::array Loss; + std::uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */ + std::uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */ std::unique_ptr palette; - void GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b ) const; + void GetRGB( std::uint32_t val, std::uint8_t *r, std::uint8_t *g, std::uint8_t *b ) const; /* Return the decoded value for the given color; the result can be compared to * decodepixel() results. If the image is paletted and the color isn't found, * val is undefined and false is returned. */ - bool MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val ) const; + bool MapRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint32_t &val ) const; /* MapRGBA, but also do a nearest-match on palette colors. */ - uint32_t MapNearestRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const; - + std::uint32_t MapNearestRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a ) const; + bool operator== ( const RageSurfaceFormat &rhs ) const; /* Like operator==, but ignores the palette (which is really a part of the @@ -76,18 +77,18 @@ struct RageSurface RageSurfaceFormat *format; /* compatibility only */ RageSurfaceFormat fmt; - uint8_t *pixels; + std::uint8_t *pixels; bool pixels_owned; - int32_t w, h, pitch; - int32_t flags; + std::int32_t w, h, pitch; + std::int32_t flags; RageSurface(); RageSurface( const RageSurface &cpy ); ~RageSurface(); }; -RageSurface *CreateSurface( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask ); -RageSurface *CreateSurfaceFrom( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask, uint8_t *pPixels, uint32_t pitch ); +RageSurface *CreateSurface( int width, int height, int bpp, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask ); +RageSurface *CreateSurfaceFrom( int width, int height, int bpp, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask, std::uint8_t *pPixels, std::uint32_t pitch ); #endif diff --git a/src/RageSurfaceUtils.cpp b/src/RageSurfaceUtils.cpp index 5e752b8edd..632e0523eb 100644 --- a/src/RageSurfaceUtils.cpp +++ b/src/RageSurfaceUtils.cpp @@ -7,48 +7,49 @@ #include #include +#include -uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp ) +std::uint32_t RageSurfaceUtils::decodepixel( const std::uint8_t *p, int bpp ) { switch(bpp) { case 1: return *p; - case 2: return *(uint16_t *)p; + case 2: return *(std::uint16_t *)p; case 3: if constexpr ( Endian::big ) return p[0] << 16 | p[1] << 8 | p[2]; else return p[0] | p[1] << 8 | p[2] << 16; - case 4: return *(uint32_t *)p; + case 4: return *(std::uint32_t *)p; default: return 0; // shouldn't happen, but avoids warnings } } -void RageSurfaceUtils::encodepixel( uint8_t *p, int bpp, uint32_t pixel ) +void RageSurfaceUtils::encodepixel( std::uint8_t *p, int bpp, std::uint32_t pixel ) { switch(bpp) { - case 1: *p = uint8_t(pixel); break; - case 2: *(uint16_t *)p = uint16_t(pixel); break; + case 1: *p = std::uint8_t(pixel); break; + case 2: *(std::uint16_t *)p = std::uint16_t(pixel); break; case 3: if constexpr ( Endian::big ) { - p[0] = uint8_t((pixel >> 16) & 0xff); - p[1] = uint8_t((pixel >> 8) & 0xff); - p[2] = uint8_t(pixel & 0xff); + p[0] = std::uint8_t((pixel >> 16) & 0xff); + p[1] = std::uint8_t((pixel >> 8) & 0xff); + p[2] = std::uint8_t(pixel & 0xff); } else { - p[0] = uint8_t(pixel & 0xff); - p[1] = uint8_t((pixel >> 8) & 0xff); - p[2] = uint8_t((pixel >> 16) & 0xff); + p[0] = std::uint8_t(pixel & 0xff); + p[1] = std::uint8_t((pixel >> 8) & 0xff); + p[2] = std::uint8_t((pixel >> 16) & 0xff); } break; - case 4: *(uint32_t *)p = pixel; break; + case 4: *(std::uint32_t *)p = pixel; break; } } // Get and set colors without scaling to 0..255. -void RageSurfaceUtils::GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt, uint8_t *v ) +void RageSurfaceUtils::GetRawRGBAV( std::uint32_t pixel, const RageSurfaceFormat &fmt, std::uint8_t *v ) { if( fmt.BytesPerPixel == 1 ) { @@ -57,20 +58,20 @@ void RageSurfaceUtils::GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt v[2] = fmt.palette->colors[pixel].b; v[3] = fmt.palette->colors[pixel].a; } else { - v[0] = uint8_t((pixel & fmt.Rmask) >> fmt.Rshift); - v[1] = uint8_t((pixel & fmt.Gmask) >> fmt.Gshift); - v[2] = uint8_t((pixel & fmt.Bmask) >> fmt.Bshift); - v[3] = uint8_t((pixel & fmt.Amask) >> fmt.Ashift); + v[0] = std::uint8_t((pixel & fmt.Rmask) >> fmt.Rshift); + v[1] = std::uint8_t((pixel & fmt.Gmask) >> fmt.Gshift); + v[2] = std::uint8_t((pixel & fmt.Bmask) >> fmt.Bshift); + v[3] = std::uint8_t((pixel & fmt.Amask) >> fmt.Ashift); } } -void RageSurfaceUtils::GetRawRGBAV( const uint8_t *p, const RageSurfaceFormat &fmt, uint8_t *v ) +void RageSurfaceUtils::GetRawRGBAV( const std::uint8_t *p, const RageSurfaceFormat &fmt, std::uint8_t *v ) { - uint32_t pixel = decodepixel( p, fmt.BytesPerPixel ); + std::uint32_t pixel = decodepixel( p, fmt.BytesPerPixel ); GetRawRGBAV( pixel, fmt, v ); } -void RageSurfaceUtils::GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t *v ) +void RageSurfaceUtils::GetRGBAV( std::uint32_t pixel, const RageSurface *src, std::uint8_t *v ) { GetRawRGBAV(pixel, src->fmt, v); const RageSurfaceFormat *fmt = src->format; @@ -82,9 +83,9 @@ void RageSurfaceUtils::GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t v[3] = 255; } -void RageSurfaceUtils::GetRGBAV( const uint8_t *p, const RageSurface *src, uint8_t *v ) +void RageSurfaceUtils::GetRGBAV( const std::uint8_t *p, const RageSurface *src, std::uint8_t *v ) { - uint32_t pixel = decodepixel(p, src->format->BytesPerPixel); + std::uint32_t pixel = decodepixel(p, src->format->BytesPerPixel); if( src->format->BytesPerPixel == 1 ) // paletted { memcpy( v, &src->format->palette->colors[pixel], sizeof(RageSurfaceColor)); @@ -95,7 +96,7 @@ void RageSurfaceUtils::GetRGBAV( const uint8_t *p, const RageSurface *src, uint8 // Inverse of GetRawRGBAV. -uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v ) +std::uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v ) { return v[0] << fmt->Rshift | v[1] << fmt->Gshift | @@ -103,14 +104,14 @@ uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const uint v[3] << fmt->Ashift; } -void RageSurfaceUtils::SetRawRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v ) +void RageSurfaceUtils::SetRawRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v ) { - uint32_t pixel = SetRawRGBAV(src->format, v); + std::uint32_t pixel = SetRawRGBAV(src->format, v); encodepixel(p, src->format->BytesPerPixel, pixel); } // Inverse of GetRGBAV. -uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v ) +std::uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v ) { return (v[0] >> fmt->Loss[0]) << fmt->Shift[0] | (v[1] >> fmt->Loss[1]) << fmt->Shift[1] | @@ -118,14 +119,14 @@ uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t (v[3] >> fmt->Loss[3]) << fmt->Shift[3]; } -void RageSurfaceUtils::SetRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v ) +void RageSurfaceUtils::SetRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v ) { - uint32_t pixel = SetRGBAV(src->format, v); + std::uint32_t pixel = SetRGBAV(src->format, v); encodepixel(p, src->format->BytesPerPixel, pixel); } -void RageSurfaceUtils::GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] ) +void RageSurfaceUtils::GetBitsPerChannel( const RageSurfaceFormat *fmt, std::uint32_t bits[4] ) { // The actual bits stored in each color is 8-loss. for( int c = 0; c < 4; ++c ) @@ -146,7 +147,7 @@ void RageSurfaceUtils::CopySurface( const RageSurface *src, RageSurface *dest ) bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst, int width, int height, int bpp, - uint32_t R, uint32_t G, uint32_t B, uint32_t A ) + std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A ) { dst = CreateSurface( width, height, bpp, R, G, B, A ); @@ -164,7 +165,7 @@ bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst void RageSurfaceUtils::ConvertSurface(RageSurface *&image, int width, int height, int bpp, - uint32_t R, uint32_t G, uint32_t B, uint32_t A) + std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A) { RageSurface *ret_image; if( !ConvertSurface( image, ret_image, width, height, bpp, R, G, B, A ) ) @@ -176,7 +177,7 @@ void RageSurfaceUtils::ConvertSurface(RageSurface *&image, // Local helper for FixHiddenAlpha. -static void FindAlphaRGB(const RageSurface *img, uint8_t &r, uint8_t &g, uint8_t &b, bool reverse) +static void FindAlphaRGB(const RageSurface *img, std::uint8_t &r, std::uint8_t &g, std::uint8_t &b, bool reverse) { r = g = b = 0; @@ -188,13 +189,13 @@ static void FindAlphaRGB(const RageSurface *img, uint8_t &r, uint8_t &g, uint8_t for(int y = reverse? img->h-1:0; reverse? (y >=0):(y < img->h); reverse? (--y):(++y)) { - uint8_t *row = (uint8_t *)img->pixels + img->pitch*y; + std::uint8_t *row = (std::uint8_t *)img->pixels + img->pitch*y; if(reverse) row += img->format->BytesPerPixel * (img->w-1); for(int x = 0; x < img->w; ++x) { - uint32_t val = RageSurfaceUtils::decodepixel(row, img->format->BytesPerPixel); + std::uint32_t val = RageSurfaceUtils::decodepixel(row, img->format->BytesPerPixel); if( img->format->BitsPerPixel == 8 ) { if( img->format->palette->colors[val].a ) @@ -229,7 +230,7 @@ static void FindAlphaRGB(const RageSurface *img, uint8_t &r, uint8_t &g, uint8_t /* Local helper for FixHiddenAlpha. Set the underlying RGB values of all pixels * in img that are completely transparent. */ -static void SetAlphaRGB(const RageSurface *pImg, uint8_t r, uint8_t g, uint8_t b) +static void SetAlphaRGB(const RageSurface *pImg, std::uint8_t r, std::uint8_t g, std::uint8_t b) { // If it's a paletted surface, all we have to do is change the palette. if( pImg->format->BitsPerPixel == 8 ) @@ -249,15 +250,15 @@ static void SetAlphaRGB(const RageSurface *pImg, uint8_t r, uint8_t g, uint8_t b if( pImg->format->BitsPerPixel > 8 && !pImg->format->Amask ) return; - uint32_t trans; + std::uint32_t trans; pImg->format->MapRGBA( r, g, b, 0, trans ); for( int y = 0; y < pImg->h; ++y ) { - uint8_t *row = pImg->pixels + pImg->pitch*y; + std::uint8_t *row = pImg->pixels + pImg->pitch*y; for( int x = 0; x < pImg->w; ++x ) { - uint32_t val = RageSurfaceUtils::decodepixel( row, pImg->format->BytesPerPixel ); + std::uint32_t val = RageSurfaceUtils::decodepixel( row, pImg->format->BytesPerPixel ); if( val != trans && !(val&pImg->format->Amask) ) { RageSurfaceUtils::encodepixel( row, pImg->format->BytesPerPixel, trans ); @@ -289,10 +290,10 @@ void RageSurfaceUtils::FixHiddenAlpha( RageSurface *pImg ) if( pImg->format->BitsPerPixel != 8 && pImg->format->Amask == 0 ) return; - uint8_t r, g, b; + std::uint8_t r, g, b; FindAlphaRGB( pImg, r, g, b, false ); - uint8_t cr, cg, cb; // compare + std::uint8_t cr, cg, cb; // compare FindAlphaRGB( pImg, cr, cg, cb, true ); if( cr != r || cg != g || cb != b ) @@ -310,7 +311,7 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img ) const int NEEDS_NO_ALPHA=0, NEEDS_BOOL_ALPHA=1, NEEDS_FULL_ALPHA=2; int alpha_type = NEEDS_NO_ALPHA; - uint32_t max_alpha; + std::uint32_t max_alpha; if( img->format->BitsPerPixel == 8 ) { // Short circuit if we already know we have no transparency. @@ -337,13 +338,13 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img ) for(int y = 0; y < img->h; ++y) { - uint8_t *row = (uint8_t *)img->pixels + img->pitch*y; + std::uint8_t *row = (std::uint8_t *)img->pixels + img->pitch*y; for(int x = 0; x < img->w; ++x) { - uint32_t val = decodepixel(row, img->format->BytesPerPixel); + std::uint32_t val = decodepixel(row, img->format->BytesPerPixel); - uint32_t alpha; + std::uint32_t alpha; if( img->format->BitsPerPixel == 8 ) alpha = img->format->palette->colors[val].a; else @@ -373,10 +374,10 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img ) // Local helper for BlitTransform. -static inline void GetRawRGBAV_XY( const RageSurface *src, uint8_t *v, int x, int y ) +static inline void GetRawRGBAV_XY( const RageSurface *src, std::uint8_t *v, int x, int y ) { - const uint8_t *srcp = (const uint8_t *) src->pixels + (y * src->pitch); - const uint8_t *srcpx = srcp + (x * src->fmt.BytesPerPixel); + const std::uint8_t *srcp = (const std::uint8_t *) src->pixels + (y * src->pitch); + const std::uint8_t *srcpx = srcp + (x * src->fmt.BytesPerPixel); RageSurfaceUtils::GetRawRGBAV( srcpx, src->fmt, v ); } @@ -404,8 +405,8 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst, for( int y = 0; y < dst->h; ++y ) { - uint8_t *dstp = (uint8_t *) dst->pixels + (y * dst->pitch); /* line */ - uint8_t *dstpx = dstp; // pixel + std::uint8_t *dstp = (std::uint8_t *) dst->pixels + (y * dst->pitch); /* line */ + std::uint8_t *dstpx = dstp; // pixel const float start_y = scale(float(y), 0, float(dst->h), Coords[TL_Y], Coords[BL_Y]); const float end_y = scale(float(y), 0, float(dst->h), Coords[TR_Y], Coords[BR_Y]); @@ -436,7 +437,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst, src_y[1] = clamp(src_y[1], 0, src->h); // Decode our four pixels. - uint8_t v[4][4]; + std::uint8_t v[4][4]; GetRawRGBAV_XY(src, v[0], src_x[0], src_y[0]); GetRawRGBAV_XY(src, v[1], src_x[0], src_y[1]); GetRawRGBAV_XY(src, v[2], src_x[1], src_y[0]); @@ -447,7 +448,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst, float weight_y = src_yp - (src_y[0] + 0.5f); // Filter: - uint8_t out[4] = { 0,0,0,0 }; + std::uint8_t out[4] = { 0,0,0,0 }; for(int i = 0; i < 4; ++i) { float sum = 0; @@ -455,12 +456,12 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst, sum += v[1][i] * (1-weight_x) * (weight_y); sum += v[2][i] * (weight_x) * (1-weight_y); sum += v[3][i] * (weight_x) * (weight_y); - out[i] = (uint8_t) clamp( std::lrint(sum), 0L, 255L ); + out[i] = (std::uint8_t) clamp( std::lrint(sum), 0L, 255L ); } // If the source has no alpha, set the destination to opaque. if( src->format->Amask == 0 ) - out[3] = uint8_t( dst->format->Amask >> dst->format->Ashift ); + out[3] = std::uint8_t( dst->format->Amask >> dst->format->Ashift ); SetRawRGBAV(dstpx, dst, out); @@ -486,8 +487,8 @@ static bool blit_same_type( const RageSurface *src_surf, const RageSurface *dst_ src_surf->format->Amask != dst_surf->format->Amask ) return false; - const uint8_t *src = src_surf->pixels; - uint8_t *dst = dst_surf->pixels; + const std::uint8_t *src = src_surf->pixels; + std::uint8_t *dst = dst_surf->pixels; // If possible, memcpy the whole thing. if( src_surf->w == width && dst_surf->w == width && src_surf->pitch == dst_surf->pitch ) @@ -514,23 +515,23 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d if( src_surf->format->BytesPerPixel == 1 || dst_surf->format->BytesPerPixel == 1 ) return false; - const uint8_t *src = src_surf->pixels; - uint8_t *dst = dst_surf->pixels; + const std::uint8_t *src = src_surf->pixels; + std::uint8_t *dst = dst_surf->pixels; // Bytes to skip at the end of a line. const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel; const int dstskip = dst_surf->pitch - width*dst_surf->format->BytesPerPixel; - const std::array &src_shifts = src_surf->format->Shift; - const std::array &dst_shifts = dst_surf->format->Shift; - const std::array &src_masks = src_surf->format->Mask; - const std::array &dst_masks = dst_surf->format->Mask; + const std::array &src_shifts = src_surf->format->Shift; + const std::array &dst_shifts = dst_surf->format->Shift; + const std::array &src_masks = src_surf->format->Mask; + const std::array &dst_masks = dst_surf->format->Mask; - uint8_t lookup[4][256]; + std::uint8_t lookup[4][256]; for( int c = 0; c < 4; ++c ) { - const uint32_t max_src_val = src_masks[c] >> src_shifts[c]; - const uint32_t max_dst_val = dst_masks[c] >> dst_shifts[c]; + const std::uint32_t max_src_val = src_masks[c] >> src_shifts[c]; + const std::uint32_t max_dst_val = dst_masks[c] >> dst_shifts[c]; ASSERT( max_src_val <= 0xFF ); ASSERT( max_dst_val <= 0xFF ); @@ -539,7 +540,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d /* The source is missing a channel. Alpha defaults to opaque, other * channels default to 0. */ if( c == 3 ) - lookup[c][0] = (uint8_t) max_dst_val; + lookup[c][0] = (std::uint8_t) max_dst_val; else lookup[c][0] = 0; } else { @@ -570,11 +571,11 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d * Having separate formulas for increasing and decreasing resolution seems * strange; what's wrong here? */ if( max_src_val > max_dst_val ) - for( uint32_t i = 0; i <= max_src_val; ++i ) - lookup[c][i] = (uint8_t) SCALE( i, 0, max_src_val+1, 0, max_dst_val+1 ); + for( std::uint32_t i = 0; i <= max_src_val; ++i ) + lookup[c][i] = (std::uint8_t) SCALE( i, 0, max_src_val+1, 0, max_dst_val+1 ); else - for( uint32_t i = 0; i <= max_src_val; ++i ) - lookup[c][i] = (uint8_t) SCALE( i, 0, max_src_val, 0, max_dst_val ); + for( std::uint32_t i = 0; i <= max_src_val; ++i ) + lookup[c][i] = (std::uint8_t) SCALE( i, 0, max_src_val, 0, max_dst_val ); } } @@ -612,8 +613,8 @@ static bool blit_generic( const RageSurface *src_surf, const RageSurface *dst_su if( src_surf->format->BytesPerPixel != 1 || dst_surf->format->BytesPerPixel == 1 ) return false; - const uint8_t *src = src_surf->pixels; - uint8_t *dst = dst_surf->pixels; + const std::uint8_t *src = src_surf->pixels; + std::uint8_t *dst = dst_surf->pixels; // Bytes to skip at the end of a line. const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel; @@ -626,7 +627,7 @@ static bool blit_generic( const RageSurface *src_surf, const RageSurface *dst_su { unsigned int pixel = RageSurfaceUtils::decodepixel( src, src_surf->format->BytesPerPixel ); - uint8_t colors[4]; + std::uint8_t colors[4]; // Convert pixel to the destination RGBA. colors[0] = src_surf->format->palette->colors[pixel].r; colors[1] = src_surf->format->palette->colors[pixel].g; @@ -712,11 +713,11 @@ void RageSurfaceUtils::CorrectBorderPixels( RageSurface *img, int width, int hei { // Duplicate the last column. int offset = img->format->BytesPerPixel * (width-1); - uint8_t *p = (uint8_t *) img->pixels + offset; + std::uint8_t *p = (std::uint8_t *) img->pixels + offset; for( int y = 0; y < height; ++y ) { - uint32_t pixel = decodepixel( p, img->format->BytesPerPixel ); + std::uint32_t pixel = decodepixel( p, img->format->BytesPerPixel ); encodepixel( p+img->format->BytesPerPixel, img->format->BytesPerPixel, pixel ); p += img->pitch; @@ -726,7 +727,7 @@ void RageSurfaceUtils::CorrectBorderPixels( RageSurface *img, int width, int hei if( height < img->h ) { // Duplicate the last row. - uint8_t *srcp = img->pixels; + std::uint8_t *srcp = img->pixels; srcp += img->pitch * (height-1); memcpy( srcp + img->pitch, srcp, img->pitch ); } @@ -864,10 +865,10 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf const unsigned int A = (index & Amask) >> Ashift; // if only one intensity value, always fullbright - const uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L ); + const std::uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L ); // if only one alpha value, always opaque - const uint8_t ScaledA = Avalues == 1 ? 255 : clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L ); + const std::uint8_t ScaledA = Avalues == 1 ? 255 : clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L ); RageSurfaceColor c; c.r = ScaledI; @@ -878,8 +879,8 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf dst_surf->fmt.palette->colors[index] = c; } - const uint8_t *src = src_surf->pixels; - uint8_t *dst = dst_surf->pixels; + const std::uint8_t *src = src_surf->pixels; + std::uint8_t *dst = dst_surf->pixels; int height = src_surf->h; int width = src_surf->w; @@ -895,7 +896,7 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf { unsigned int pixel = decodepixel( src, src_surf->format->BytesPerPixel ); - uint8_t colors[4]; + std::uint8_t colors[4]; GetRGBAV(pixel, src_surf, colors); int Ival = 0; @@ -908,7 +909,7 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf (colors[3] >> Aloss) << Ashift; // Store it. - *dst = uint8_t(pixel); + *dst = std::uint8_t(pixel); src += src_surf->format->BytesPerPixel; dst += dst_surf->format->BytesPerPixel; @@ -938,14 +939,14 @@ RageSurface *RageSurfaceUtils::MakeDummySurface( int height, int width ) * Search the edge for it; if we find it, use that as the color key. */ static bool ImageUsesOffHotPink( const RageSurface *img ) { - uint32_t OffHotPink; + std::uint32_t OffHotPink; if( !img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, OffHotPink ) ) return false; - const uint8_t *p = img->pixels; + const std::uint8_t *p = img->pixels; for( int x = 0; x < img->w; ++x ) { - uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel ); + std::uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel ); if( val == OffHotPink ) return true; p += img->format->BytesPerPixel; @@ -955,7 +956,7 @@ static bool ImageUsesOffHotPink( const RageSurface *img ) p += img->pitch * (img->h-1); for( int i=0; i < img->w; i++ ) { - uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel ); + std::uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel ); if( val == OffHotPink ) return true; p += img->format->BytesPerPixel; @@ -969,7 +970,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img ) { if( img->format->BitsPerPixel == 8 ) { - uint32_t color; + std::uint32_t color; if( img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, color ) ) img->format->palette->colors[ color ].a = 0; if( img->format->MapRGBA( 0xFF, 0, 0xFF, 0xFF, color ) ) @@ -991,7 +992,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img ) { img->format->Amask = 1<format->Aloss = 7; - img->format->Ashift = (uint8_t) i; + img->format->Ashift = (std::uint8_t) i; } } */ @@ -1001,7 +1002,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img ) 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF ); } - uint32_t HotPink; + std::uint32_t HotPink; bool bHaveColorKey; if( ImageUsesOffHotPink(img) ) @@ -1013,11 +1014,11 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img ) for( int y = 0; y < img->h; ++y ) { - uint8_t *row = img->pixels + img->pitch*y; + std::uint8_t *row = img->pixels + img->pitch*y; for( int x = 0; x < img->w; ++x ) { - uint32_t val = decodepixel( row, img->format->BytesPerPixel ); + std::uint32_t val = decodepixel( row, img->format->BytesPerPixel ); if( val == HotPink ) encodepixel( row, img->format->BytesPerPixel, 0 ); diff --git a/src/RageSurfaceUtils.h b/src/RageSurfaceUtils.h index 9eb1c07f33..9005cb64c5 100644 --- a/src/RageSurfaceUtils.h +++ b/src/RageSurfaceUtils.h @@ -3,6 +3,8 @@ #ifndef RAGE_SURFACE_UTILS_H #define RAGE_SURFACE_UTILS_H +#include + struct RageSurfaceColor; struct RageSurfacePalette; struct RageSurfaceFormat; @@ -11,27 +13,27 @@ struct RageSurface; /** @brief Utility functions for the RageSurfaces. */ namespace RageSurfaceUtils { - uint32_t decodepixel( const uint8_t *p, int bpp ); - void encodepixel( uint8_t *p, int bpp, uint32_t pixel ); + std::uint32_t decodepixel( const std::uint8_t *p, int bpp ); + void encodepixel( std::uint8_t *p, int bpp, std::uint32_t pixel ); - void GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt, uint8_t *v ); - void GetRawRGBAV( const uint8_t *p, const RageSurfaceFormat &fmt, uint8_t *v ); - void GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t *v ); - void GetRGBAV( const uint8_t *p, const RageSurface *src, uint8_t *v ); + void GetRawRGBAV( std::uint32_t pixel, const RageSurfaceFormat &fmt, std::uint8_t *v ); + void GetRawRGBAV( const std::uint8_t *p, const RageSurfaceFormat &fmt, std::uint8_t *v ); + void GetRGBAV( std::uint32_t pixel, const RageSurface *src, std::uint8_t *v ); + void GetRGBAV( const std::uint8_t *p, const RageSurface *src, std::uint8_t *v ); - uint32_t SetRawRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v ); - void SetRawRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v ); - uint32_t SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v ); - void SetRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v ); + std::uint32_t SetRawRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v ); + void SetRawRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v ); + std::uint32_t SetRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v ); + void SetRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v ); /* Get the number of bits representing each color channel in fmt. */ - void GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] ); + void GetBitsPerChannel( const RageSurfaceFormat *fmt, std::uint32_t bits[4] ); void CopySurface( const RageSurface *src, RageSurface *dest ); bool ConvertSurface( const RageSurface *src, RageSurface *&dst, - int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A ); + int width, int height, int bpp, std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A ); void ConvertSurface( RageSurface *&image, - int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A ); + int width, int height, int bpp, std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A ); void FixHiddenAlpha( RageSurface *img ); @@ -45,7 +47,7 @@ namespace RageSurfaceUtils * It only needs one bit of alpha. */ enum { TRAIT_BOOL_TRANSPARENCY = 0x0002 }; /* 1alpha */ - void BlitTransform( const RageSurface *src, RageSurface *dst, + void BlitTransform( const RageSurface *src, RageSurface *dst, const float fCoords[8] /* TL, BR, BL, TR */ ); void Blit( const RageSurface *src, RageSurface *dst, int width = -1, int height = -1 ); diff --git a/src/RageSurfaceUtils_Dither.cpp b/src/RageSurfaceUtils_Dither.cpp index b0419f444c..e6f2652243 100644 --- a/src/RageSurfaceUtils_Dither.cpp +++ b/src/RageSurfaceUtils_Dither.cpp @@ -4,6 +4,8 @@ #include "RageSurface.h" #include "RageSurfaceUtils.h" +#include + #define DitherMatDim 4 // Fractions, 0/16 to 15/16: @@ -18,7 +20,7 @@ static const int DitherMat[DitherMatDim][DitherMatDim] = static int DitherMatCalc[DitherMatDim][DitherMatDim]; // conv is the ratio from the input to the output. -static uint8_t DitherPixel(int x, int y, int intensity, int conv) +static std::uint8_t DitherPixel(int x, int y, int intensity, int conv) { // The intensity matrix wraps. This assumes the matrix dims are a power of 2. x &= DitherMatDim-1; @@ -41,7 +43,7 @@ static uint8_t DitherPixel(int x, int y, int intensity, int conv) out_intensity += DitherMatCalc[y][x]; // Truncate, and add e to make sure a value of 14.999998 -> 15. - return uint8_t((out_intensity + 1) >> 16); + return std::uint8_t((out_intensity + 1) >> 16); } void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst ) @@ -59,14 +61,14 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst ) DitherMatCalc[i][j] = DitherMat[i][j] * 65536 / 16; } } - + DitherMatCalc_initted = true; } // We can't dither to paletted surfaces. ASSERT( dst->format->BytesPerPixel > 1 ); - uint32_t src_cbits[4], dst_cbits[4]; + std::uint32_t src_cbits[4], dst_cbits[4]; RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits ); RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits ); @@ -84,18 +86,18 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst ) } // Max alpha value; used when there's no alpha source. - const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1); + const std::uint8_t alpha_max = std::uint8_t((1 << dst_cbits[3]) - 1); // For each row: for( int row = 0; row < src->h; ++row ) { - const uint8_t *srcp = src->pixels + row * src->pitch; - uint8_t *dstp = dst->pixels + row * dst->pitch; + const std::uint8_t *srcp = src->pixels + row * src->pitch; + std::uint8_t *dstp = dst->pixels + row * dst->pitch; // For each pixel: for( int col = 0; col < src->w; ++col ) { - uint8_t colors[4]; + std::uint8_t colors[4]; RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors ); // Note that we don't dither the alpha channel. @@ -115,9 +117,9 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst ) /* Same as DitherPixel, except it doesn't actually dither; * dithering looks bad on the alpha channel. */ int out_intensity = colors[3] * conv[3]; - + // Round: - colors[3] = uint8_t((out_intensity + 32767) >> 16); + colors[3] = std::uint8_t((out_intensity + 32767) >> 16); } // Raw value -> int -> pixel @@ -130,7 +132,7 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst ) } -static uint8_t EDDitherPixel( int x, int y, int intensity, int conv, int32_t &accumError ) +static std::uint8_t EDDitherPixel( int x, int y, int intensity, int conv, std::int32_t &accumError ) { // Convert the number to the destination range. int out_intensity = intensity * conv; @@ -149,7 +151,7 @@ static uint8_t EDDitherPixel( int x, int y, int intensity, int conv, int32_t &ac clamped_intensity &= 0xFF0000; // Truncate. - uint8_t ret = uint8_t(clamped_intensity >> 16); + std::uint8_t ret = std::uint8_t(clamped_intensity >> 16); accumError = out_intensity - clamped_intensity; @@ -170,7 +172,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface // We can't dither to paletted surfaces. ASSERT( dst->format->BytesPerPixel > 1 ); - uint32_t src_cbits[4], dst_cbits[4]; + std::uint32_t src_cbits[4], dst_cbits[4]; RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits ); RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits ); @@ -188,20 +190,20 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface } // Max alpha value; used when there's no alpha source. - const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1); + const std::uint8_t alpha_max = std::uint8_t((1 << dst_cbits[3]) - 1); // For each row: - for(int row = 0; row < src->h; ++row) + for(int row = 0; row < src->h; ++row) { - int32_t accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row + std::int32_t accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row - const uint8_t *srcp = src->pixels + row * src->pitch; - uint8_t *dstp = dst->pixels + row * dst->pitch; + const std::uint8_t *srcp = src->pixels + row * src->pitch; + std::uint8_t *dstp = dst->pixels + row * dst->pitch; // For each pixel in row: for( int col = 0; col < src->w; ++col ) { - uint8_t colors[4]; + std::uint8_t colors[4]; RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors ); for( int c = 0; c < 3; ++c ) @@ -221,7 +223,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface int out_intensity = colors[3] * conv[3]; // Round: - colors[3] = uint8_t((out_intensity + 32767) >> 16); + colors[3] = std::uint8_t((out_intensity + 32767) >> 16); } RageSurfaceUtils::SetRawRGBAV( dstp, dst, colors ); @@ -235,7 +237,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface /* * (c) 2002-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 @@ -245,7 +247,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface * 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 diff --git a/src/RageSurfaceUtils_Palettize.cpp b/src/RageSurfaceUtils_Palettize.cpp index b4a81d186a..407d124f6e 100644 --- a/src/RageSurfaceUtils_Palettize.cpp +++ b/src/RageSurfaceUtils_Palettize.cpp @@ -6,8 +6,10 @@ #include "RageSurfaceUtils.h" #include "RageUtil.h" -typedef uint8_t pixval; -typedef uint8_t apixel[4]; +#include + +typedef std::uint8_t pixval; +typedef std::uint8_t apixel[4]; #define PAM_GETR(p) ((p)[0]) #define PAM_GETG(p) ((p)[1]) @@ -18,7 +20,7 @@ typedef uint8_t apixel[4]; #define PAM_EQUAL(p,q) \ ((p)[0] == (q)[0] && (p)[1] == (q)[1] && (p)[2] == (q)[2] && (p)[3] == (q)[3]) #define PAM_DEPTH(p) \ - PAM_ASSIGN( (p), (uint8_t) table[PAM_GETR(p)], (uint8_t) table[PAM_GETG(p)], (uint8_t) table[PAM_GETB(p)], (uint8_t) table[PAM_GETA(p)] ) + PAM_ASSIGN( (p), (std::uint8_t) table[PAM_GETR(p)], (std::uint8_t) table[PAM_GETG(p)], (std::uint8_t) table[PAM_GETB(p)], (std::uint8_t) table[PAM_GETA(p)] ) struct acolorhist_item { @@ -90,8 +92,8 @@ static bool compare_index_3( const acolorhist_item &ch1, const acolorhist_item & } static acolorhist_item *pam_computeacolorhist( const RageSurface *src, int maxacolors, int* acolorsP ); -static void pam_addtoacolorhash( acolorhash_hash &acht, const uint8_t acolorP[4], int value ); -static int pam_lookupacolor( const acolorhash_hash &acht, const uint8_t acolorP[4] ); +static void pam_addtoacolorhash( acolorhash_hash &acht, const std::uint8_t acolorP[4], int value ); +static int pam_lookupacolor( const acolorhash_hash &acht, const std::uint8_t acolorP[4] ); static void pam_freeacolorhist( acolorhist_item *achv ); struct pixerror_t @@ -132,7 +134,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither int table[256]; for( int c = 0; c <= maxval; ++c ) { - table[c] = ( (uint8_t) c * newmaxval + maxval/2 ) / maxval; + table[c] = ( (std::uint8_t) c * newmaxval + maxval/2 ) / maxval; } for( int row = 0; row < pImg->h; ++row ) { @@ -201,25 +203,25 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither limitcol = -1; } - const uint8_t *pIn = pImg->pixels + row*pImg->pitch; - uint8_t *pOut = pRet->pixels + row*pRet->pitch; + const std::uint8_t *pIn = pImg->pixels + row*pImg->pitch; + std::uint8_t *pOut = pRet->pixels + row*pRet->pitch; pIn += col * 4; pOut += col; do { - int32_t sc[4]; - uint8_t pixel[4] = { pIn[0], pIn[1], pIn[2], pIn[3] }; + std::int32_t sc[4]; + std::uint8_t pixel[4] = { pIn[0], pIn[1], pIn[2], pIn[3] }; if( bDither ) { // Use Floyd-Steinberg errors to adjust actual color. for( int c = 0; c < 4; ++c ) { sc[c] = pixel[c] + thiserr[col + 1].c[c] / FS_SCALE; - sc[c] = clamp( sc[c], 0, (int32_t) maxval ); + sc[c] = clamp( sc[c], 0, (std::int32_t) maxval ); } - PAM_ASSIGN( pixel, (uint8_t)sc[0], (uint8_t)sc[1], (uint8_t)sc[2], (uint8_t)sc[3] ); + PAM_ASSIGN( pixel, (std::uint8_t)sc[0], (std::uint8_t)sc[1], (std::uint8_t)sc[2], (std::uint8_t)sc[3] ); } // Check hash table to see if we have already matched this color. @@ -238,7 +240,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither long dist = 2000000000; for( int i = 0; i < newcolors; ++i ) { - const uint8_t *colors2 = acolormap[i].acolor; + const std::uint8_t *colors2 = acolormap[i].acolor; int newdist = 0; newdist += pSquareTable[ int(pixel[0]) - colors2[0] ]; @@ -281,7 +283,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither } } - *pOut = (uint8_t) ind; + *pOut = (std::uint8_t) ind; if( !fs_direction ) { @@ -478,7 +480,7 @@ static acolorhist_item *mediancut( acolorhist_item *achv, int colors, int sum, i b = std::min( b, (long) maxval ); a = a / lSum; a = std::min( a, (long) maxval ); - PAM_ASSIGN( acolormap[bi].acolor, (uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a ); + PAM_ASSIGN( acolormap[bi].acolor, (std::uint8_t)r, (std::uint8_t)g, (std::uint8_t)b, (std::uint8_t)a ); #endif // REP_AVERAGE_PIXELS } @@ -577,7 +579,7 @@ static acolorhist_item *pam_computeacolorhist( const RageSurface *src, int maxac return achv; } -static void pam_addtoacolorhash( acolorhash_hash &acht, const uint8_t acolorP[4], int value ) +static void pam_addtoacolorhash( acolorhash_hash &acht, const std::uint8_t acolorP[4], int value ) { acolorhist_list achl = (acolorhist_list) malloc( sizeof(struct acolorhist_list_item) ); ASSERT( achl != nullptr ); @@ -590,7 +592,7 @@ static void pam_addtoacolorhash( acolorhash_hash &acht, const uint8_t acolorP[4] } -static int pam_lookupacolor( const acolorhash_hash &acht, const uint8_t acolorP[4] ) +static int pam_lookupacolor( const acolorhash_hash &acht, const std::uint8_t acolorP[4] ) { const int hash = pam_hashapixel( acolorP ); for ( acolorhist_list_item *achl = acht.hash[hash]; achl != nullptr; achl = achl->next ) diff --git a/src/RageSurfaceUtils_Zoom.cpp b/src/RageSurfaceUtils_Zoom.cpp index 8c56e2691f..03b5cbd92b 100644 --- a/src/RageSurfaceUtils_Zoom.cpp +++ b/src/RageSurfaceUtils_Zoom.cpp @@ -5,6 +5,7 @@ #include "RageUtil.h" #include +#include #include /* Coordinate 0x0 represents the exact top-left corner of a bitmap. .5x.5 @@ -14,7 +15,7 @@ * (Look at a grid: map coordinates to the lines, not the squares between the * lines.) */ -static void InitVectors( std::vector &s0, std::vector &s1, std::vector &percent, int src, int dst ) +static void InitVectors( std::vector &s0, std::vector &s1, std::vector &percent, int src, int dst ) { if( src >= dst ) { @@ -51,7 +52,7 @@ static void InitVectors( std::vector &s0, std::vector &s1, std::vector /* sax is somewhere between the centers of both sampled * pixels; find the percentage: */ const float p = (1.0f - (sax - fleft) / xdist) * 16777216.0f; - percent.push_back( uint32_t(p) ); + percent.push_back( std::uint32_t(p) ); } } } @@ -74,7 +75,7 @@ static void InitVectors( std::vector &s0, std::vector &s1, std::vector s1.push_back( clamp(int(sax+1), 0, src-1) ); const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f; - percent.push_back( uint32_t(p) ); + percent.push_back( std::uint32_t(p) ); } } } @@ -84,42 +85,42 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst ) /* For each destination coordinate, two source rows, two source columns * and the percentage of the first row and first column: */ std::vector esx0, esx1, esy0, esy1; - std::vector ex0, ey0; + std::vector ex0, ey0; InitVectors( esx0, esx1, ex0, src->w, dst->w ); InitVectors( esy0, esy1, ey0, src->h, dst->h ); // This is where all of the real work is done. - const uint8_t *sp = (uint8_t *) src->pixels; + const std::uint8_t *sp = (std::uint8_t *) src->pixels; const int height = dst->h; const int width = dst->w; for( int y = 0; y < height; y++ ) { - uint8_t *dp = (uint8_t *) (dst->pixels + dst->pitch*y); + std::uint8_t *dp = (std::uint8_t *) (dst->pixels + dst->pitch*y); /* current source pointer and next source pointer (first and second * rows sampled for this row): */ - const uint8_t *csp = sp + esy0[y] * src->pitch; - const uint8_t *ncsp = sp + esy1[y] * src->pitch; + const std::uint8_t *csp = sp + esy0[y] * src->pitch; + const std::uint8_t *ncsp = sp + esy1[y] * src->pitch; for( int x = 0; x < width; x++ ) { // Grab pointers to the sampled pixels: - const uint8_t *c00 = csp + esx0[x]*4; - const uint8_t *c01 = csp + esx1[x]*4; - const uint8_t *c10 = ncsp + esx0[x]*4; - const uint8_t *c11 = ncsp + esx1[x]*4; + const std::uint8_t *c00 = csp + esx0[x]*4; + const std::uint8_t *c01 = csp + esx1[x]*4; + const std::uint8_t *c10 = ncsp + esx0[x]*4; + const std::uint8_t *c11 = ncsp + esx1[x]*4; for( int c = 0; c < 4; ++c ) { - uint32_t x0 = uint32_t(c00[c]) * ex0[x]; - x0 += uint32_t(c01[c]) * (16777216 - ex0[x]); + std::uint32_t x0 = std::uint32_t(c00[c]) * ex0[x]; + x0 += std::uint32_t(c01[c]) * (16777216 - ex0[x]); x0 >>= 24; - uint32_t x1 = uint32_t(c10[c]) * ex0[x]; - x1 += uint32_t(c11[c]) * (16777216 - ex0[x]); + std::uint32_t x1 = std::uint32_t(c10[c]) * ex0[x]; + x1 += std::uint32_t(c11[c]) * (16777216 - ex0[x]); x1 >>= 24; - const uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24; - dp[c] = uint8_t(res); + const std::uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24; + dp[c] = std::uint8_t(res); } // Advance destination pointer. diff --git a/src/RageSurface_Load_BMP.cpp b/src/RageSurface_Load_BMP.cpp index 156e744eee..28db364c03 100644 --- a/src/RageSurface_Load_BMP.cpp +++ b/src/RageSurface_Load_BMP.cpp @@ -4,6 +4,9 @@ #include "RageUtil.h" #include "RageLog.h" #include "RageSurface.h" + +#include + using namespace FileReading; /* Tested with http://entropymine.com/jason/bmpsuite/. */ @@ -38,10 +41,10 @@ static RageSurfaceUtils::OpenResult LoadBMP( RageFile &f, RageSurface *&img, RSt read_u32_le( f, sError ); /* file size */ read_u32_le( f, sError ); /* unused */ - uint32_t iDataOffset = read_u32_le( f, sError ); - uint32_t iHeaderSize = read_u32_le( f, sError ); + std::uint32_t iDataOffset = read_u32_le( f, sError ); + std::uint32_t iHeaderSize = read_u32_le( f, sError ); - uint32_t iWidth, iHeight, iPlanes, iBPP, iCompression = COMP_BI_RGB, iColors = 0; + std::uint32_t iWidth, iHeight, iPlanes, iBPP, iCompression = COMP_BI_RGB, iColors = 0; if( iHeaderSize == 12 ) { /* OS/2 format */ @@ -154,7 +157,7 @@ static RageSurfaceUtils::OpenResult LoadBMP( RageFile &f, RageSurface *&img, RSt for( int y = (int) iHeight-1; y >= 0; --y ) { - uint8_t *pRow = img->pixels + img->pitch*y; + std::uint8_t *pRow = img->pixels + img->pitch*y; RString buf; f.Read( buf, iFilePitch ); diff --git a/src/RageSurface_Load_JPEG.cpp b/src/RageSurface_Load_JPEG.cpp index c7606d16e3..d8fc80b4a6 100644 --- a/src/RageSurface_Load_JPEG.cpp +++ b/src/RageSurface_Load_JPEG.cpp @@ -6,6 +6,7 @@ #include "RageSurface.h" #include +#include #include extern "C" { @@ -169,7 +170,7 @@ static RageSurface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err for( int i = 0; i < 256; ++i ) { RageSurfaceColor color; - color.r = color.g = color.b = (int8_t) i; + color.r = color.g = color.b = (std::int8_t) i; color.a = 0xFF; img->fmt.palette->colors[i] = color; } diff --git a/src/RageSurface_Load_PNG.cpp b/src/RageSurface_Load_PNG.cpp index dfa5444fb3..a3d62222f4 100644 --- a/src/RageSurface_Load_PNG.cpp +++ b/src/RageSurface_Load_PNG.cpp @@ -1,13 +1,15 @@ #include "global.h" -#include - #include "RageSurface_Load_PNG.h" #include "RageUtil.h" #include "RageLog.h" #include "RageFile.h" #include "RageSurface.h" +#include + +#include + #if defined(_MSC_VER) #if defined(_BINARY_PNG) #pragma comment(lib, "libpng.lib") @@ -142,7 +144,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro /* Fake PNG_COLOR_TYPE_GRAY. */ for( int i = 0; i < 256; ++i ) { - colors[i].r = colors[i].g = colors[i].b = (int8_t) i; + colors[i].r = colors[i].g = colors[i].b = (std::int8_t) i; colors[i].a = 0xFF; } diff --git a/src/RageSurface_Load_XPM.cpp b/src/RageSurface_Load_XPM.cpp index 74886b9120..28d4d1fe91 100644 --- a/src/RageSurface_Load_XPM.cpp +++ b/src/RageSurface_Load_XPM.cpp @@ -6,6 +6,8 @@ #include "RageUtil.h" #include "RageLog.h" #include "RageSurface.h" + +#include #include #define CheckLine() \ @@ -57,9 +59,9 @@ RageSurface *RageSurface_Load_XPM( char * const *xpm, RString &error ) if( sscanf( clr, "%2x%2x%2x", &r, &g, &b ) != 3 ) continue; RageSurfaceColor colorval; - colorval.r = (uint8_t) r; - colorval.g = (uint8_t) g; - colorval.b = (uint8_t) b; + colorval.r = (std::uint8_t) r; + colorval.g = (std::uint8_t) g; + colorval.b = (std::uint8_t) b; colorval.a = 0xFF; colors.push_back( colorval ); @@ -88,9 +90,9 @@ RageSurface *RageSurface_Load_XPM( char * const *xpm, RString &error ) return nullptr; } - int8_t *p = (int8_t *) img->pixels; + std::int8_t *p = (std::int8_t *) img->pixels; p += y * img->pitch; - int32_t *p32 = (int32_t *) p; + std::int32_t *p32 = (std::int32_t *) p; for( int x = 0; x < width; ++x ) { RString color_name = row.substr( x*color_length, color_length ); @@ -105,7 +107,7 @@ RageSurface *RageSurface_Load_XPM( char * const *xpm, RString &error ) if( colors.size() <= 256 ) { - p[x] = (int8_t) it->second; + p[x] = (std::int8_t) it->second; } else { const RageSurfaceColor &color = colors[it->second]; p32[x] = (color.r << 24) + (color.g << 16) + (color.b << 8); diff --git a/src/RageSurface_Save_BMP.cpp b/src/RageSurface_Save_BMP.cpp index e8eb45807a..51150181b7 100644 --- a/src/RageSurface_Save_BMP.cpp +++ b/src/RageSurface_Save_BMP.cpp @@ -5,6 +5,8 @@ #include "RageUtil.h" #include "RageFile.h" +#include + static void WriteBytes( RageFile &f, RString &sError, const void *buf, int size ) { if( sError.size() != 0 ) @@ -15,16 +17,16 @@ static void WriteBytes( RageFile &f, RString &sError, const void *buf, int size sError = f.GetError(); } -static void write_le16( RageFile &f, RString &sError, uint16_t val ) +static void write_le16( RageFile &f, RString &sError, std::uint16_t val ) { val = Swap16LE( val ); - WriteBytes( f, sError, &val, sizeof(uint16_t) ); + WriteBytes( f, sError, &val, sizeof(std::uint16_t) ); } -static void write_le32( RageFile &f, RString &sError, uint32_t val ) +static void write_le32( RageFile &f, RString &sError, std::uint32_t val ) { val = Swap32LE( val ); - WriteBytes( f, sError, &val, sizeof(uint32_t) ); + WriteBytes( f, sError, &val, sizeof(std::uint32_t) ); } bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f ) @@ -51,7 +53,7 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f ) write_le32( f, sError, surface->w ); // width (offset 0x14) write_le32( f, sError, surface->h ); // height (offset 0x18) write_le16( f, sError, 1 ); // planes (offset 0x1A) - write_le16( f, sError, (uint16_t) converted_surface->fmt.BytesPerPixel*8 ); // bpp (offset 0x1C) + write_le16( f, sError, (std::uint16_t) converted_surface->fmt.BytesPerPixel*8 ); // bpp (offset 0x1C) write_le32( f, sError, 0 ); // compression (offset 0x1E) write_le32( f, sError, iDataSize ); // bitmap size (offset 0x22) write_le32( f, sError, 0 ); // horiz resolution (offset 0x26) @@ -61,11 +63,11 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f ) for( int y = converted_surface->h-1; y >= 0; --y ) { - const uint8_t *pRow = converted_surface->pixels + converted_surface->pitch*y; + const std::uint8_t *pRow = converted_surface->pixels + converted_surface->pitch*y; WriteBytes( f, sError, pRow, converted_surface->pitch ); /* Pad the row to the pitch. */ - uint8_t padding[4] = { 0,0,0,0 }; + std::uint8_t padding[4] = { 0,0,0,0 }; WriteBytes( f, sError, padding, iFilePitch-converted_surface->pitch ); } @@ -83,7 +85,7 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f ) /* * (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 @@ -93,7 +95,7 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f ) * 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 diff --git a/src/RageSurface_Save_JPEG.cpp b/src/RageSurface_Save_JPEG.cpp index 7c66571b31..8436425f3d 100644 --- a/src/RageSurface_Save_JPEG.cpp +++ b/src/RageSurface_Save_JPEG.cpp @@ -7,6 +7,7 @@ #include "RageFile.h" #include +#include #undef FAR // fix for VC /** @brief A helper to get the jpeg lib. */ @@ -24,7 +25,7 @@ typedef struct struct jpeg::jpeg_destination_mgr pub; RageFile *f; - uint8_t buffer[OUTPUT_BUFFER_SIZE]; + std::uint8_t buffer[OUTPUT_BUFFER_SIZE]; } my_destination_mgr; diff --git a/src/RageTexture.h b/src/RageTexture.h index 6c553afa2e..e87c1953ef 100644 --- a/src/RageTexture.h +++ b/src/RageTexture.h @@ -6,6 +6,8 @@ #include "RageTypes.h" #include "RageTextureID.h" +#include + struct lua_State; class RageTexture { @@ -15,7 +17,7 @@ public: virtual void Update( float /* fDeltaTime */ ) {} virtual void Reload() {} virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */ - virtual uintptr_t GetTexHandle() const = 0; // accessed by RageDisplay + virtual std::uintptr_t GetTexHandle() const = 0; // accessed by RageDisplay // movie texture/animated texture stuff virtual void SetPosition( float /* fSeconds */ ) {} // seek diff --git a/src/RageTextureManager.cpp b/src/RageTextureManager.cpp index 07061ddfdb..2c1afb16a4 100644 --- a/src/RageTextureManager.cpp +++ b/src/RageTextureManager.cpp @@ -17,7 +17,7 @@ * If a texture is loaded as DEFAULT that was already loaded as VOLATILE, DEFAULT * overrides. */ - + #include "global.h" #include "RageTextureManager.h" #include "RageBitmapTexture.h" @@ -27,6 +27,7 @@ #include "RageDisplay.h" #include "ActorUtil.h" +#include #include RageTextureManager* TEXTUREMAN = nullptr; // global and accessible from anywhere in our program @@ -132,10 +133,10 @@ public: m_iImageWidth = m_iImageHeight = 1; CreateFrameRects(); } - uintptr_t GetTexHandle() const { return m_uTexHandle; } + std::uintptr_t GetTexHandle() const { return m_uTexHandle; } private: - uintptr_t m_uTexHandle; + std::uintptr_t m_uTexHandle; }; // Load and unload textures from disk. @@ -224,7 +225,7 @@ void RageTextureManager::UnloadTexture( RageTexture *t ) /* Delete volatile textures after they've been used at least once. */ if( t->GetPolicy() == RageTextureID::TEX_VOLATILE && t->m_bWasUsed ) bDeleteThis = true; - + if( bDeleteThis ) DeleteTexture( t ); } @@ -281,7 +282,7 @@ void RageTextureManager::GarbageCollect( GCType type ) RageTextureID::TexPolicy policy = t->GetPolicy(); switch( policy ) { - case RageTextureID::TEX_DEFAULT: + case RageTextureID::TEX_DEFAULT: /* If m_bDelayedDelete, wait until delayed_delete. If !m_bDelayedDelete, * it should have been deleted when it reached no references, but we * might have just changed the preference. */ @@ -299,7 +300,7 @@ void RageTextureManager::GarbageCollect( GCType type ) /* This happens when we change themes; free all textures. */ if( type==delayed_delete ) bDeleteThis = true; - + if( bDeleteThis ) DeleteTexture( t ); } @@ -344,7 +345,7 @@ bool RageTextureManager::SetPrefs( RageTextureManagerPrefs prefs ) bNeedReload = true; m_Prefs = prefs; - + ASSERT( m_Prefs.m_iTextureColorDepth==16 || m_Prefs.m_iTextureColorDepth==32 ); ASSERT( m_Prefs.m_iMovieColorDepth==16 || m_Prefs.m_iMovieColorDepth==32 ); return bNeedReload; diff --git a/src/RageTextureRenderTarget.h b/src/RageTextureRenderTarget.h index 088d80df24..1dbd2c9417 100644 --- a/src/RageTextureRenderTarget.h +++ b/src/RageTextureRenderTarget.h @@ -7,6 +7,8 @@ #include "RageTextureID.h" #include "RageDisplay.h" // for RenderTargetParam +#include + class RageTextureRenderTarget: public RageTexture { public: @@ -14,7 +16,7 @@ public: virtual ~RageTextureRenderTarget(); virtual void Invalidate() { m_iTexHandle = 0; /* don't Destroy() */ } virtual void Reload(); - virtual uintptr_t GetTexHandle() const { return m_iTexHandle; } + virtual std::uintptr_t GetTexHandle() const { return m_iTexHandle; } void BeginRenderingTo( bool bPreserveTexture = true ); void FinishRenderingTo(); @@ -26,8 +28,8 @@ private: void Create(); void Destroy(); - uintptr_t m_iTexHandle; - uintptr_t m_iPreviousRenderTarget; + std::uintptr_t m_iTexHandle; + std::uintptr_t m_iPreviousRenderTarget; }; #endif diff --git a/src/RageThreads.cpp b/src/RageThreads.cpp index ea5ff1294d..cd885d476c 100644 --- a/src/RageThreads.cpp +++ b/src/RageThreads.cpp @@ -1,5 +1,5 @@ /* - * If you're going to use threads, remember this: + * If you're going to use threads, remember this: * * Threads suck. * @@ -17,6 +17,7 @@ #include "RageUtil.h" #include +#include #include #include "arch/Threads/Threads.h" @@ -45,7 +46,7 @@ struct ThreadSlot char m_szThreadFormattedOutput[1024]; bool m_bUsed; - uint64_t m_iID; + std::uint64_t m_iID; ThreadImpl *m_pImpl; @@ -153,7 +154,7 @@ static int FindEmptyThreadSlot() g_ThreadSlots[entry].m_bUsed = true; return entry; } - + RageException::Throw( "Out of thread slots!" ); } @@ -183,7 +184,7 @@ static void InitThreads() } -static ThreadSlot *GetThreadSlotFromID( uint64_t iID ) +static ThreadSlot *GetThreadSlotFromID( std::uint64_t iID ) { InitThreads(); @@ -210,7 +211,7 @@ static ThreadSlot *GetUnknownThreadSlot() RageThread::RageThread(): m_pSlot(nullptr), m_sName("unnamed") {} /* Copying a thread does not start the copy. */ -RageThread::RageThread( const RageThread &cpy ): +RageThread::RageThread( const RageThread &cpy ): m_pSlot(nullptr), m_sName(cpy.m_sName) {} RageThread::~RageThread() @@ -240,7 +241,7 @@ void RageThread::Create( int (*fn)(void *), void *data ) int slotno = FindEmptyThreadSlot(); m_pSlot = &g_ThreadSlots[slotno]; - + strcpy( m_pSlot->m_szName, m_sName.c_str() ); if( LOG ) @@ -257,11 +258,11 @@ RageThreadRegister::RageThreadRegister( const RString &sName ) { InitThreads(); LockMut( GetThreadSlotsLock() ); - + int iSlot = FindEmptyThreadSlot(); - + m_pSlot = &g_ThreadSlots[iSlot]; - + strcpy( m_pSlot->m_szName, sName ); sprintf( m_pSlot->m_szThreadFormattedOutput, "Thread: %s", sName.c_str() ); @@ -283,7 +284,7 @@ const char *RageThread::GetCurrentThreadName() return GetThreadNameByID( GetCurrentThreadID() ); } -const char *RageThread::GetThreadNameByID( uint64_t iID ) +const char *RageThread::GetThreadNameByID( std::uint64_t iID ) { ThreadSlot *slot = GetThreadSlotFromID( iID ); if( slot == nullptr ) @@ -292,7 +293,7 @@ const char *RageThread::GetThreadNameByID( uint64_t iID ) return slot->GetThreadName(); } -bool RageThread::EnumThreadIDs( int n, uint64_t &iID ) +bool RageThread::EnumThreadIDs( int n, std::uint64_t &iID ) { if( n >= MAX_THREADS ) return false; @@ -336,7 +337,7 @@ void RageThread::Resume() { void RageThread::HaltAllThreads( bool Kill ) { - const uint64_t ThisThreadID = GetThisThreadId(); + const std::uint64_t ThisThreadID = GetThisThreadId(); for( int entry = 0; entry < MAX_THREADS; ++entry ) { if( !g_ThreadSlots[entry].m_bUsed ) @@ -349,7 +350,7 @@ void RageThread::HaltAllThreads( bool Kill ) void RageThread::ResumeAllThreads() { - const uint64_t ThisThreadID = GetThisThreadId(); + const std::uint64_t ThisThreadID = GetThisThreadId(); for( int entry = 0; entry < MAX_THREADS; ++entry ) { if( !g_ThreadSlots[entry].m_bUsed ) @@ -361,11 +362,11 @@ void RageThread::ResumeAllThreads() } } -uint64_t RageThread::GetCurrentThreadID() +std::uint64_t RageThread::GetCurrentThreadID() { return GetThisThreadId(); } -uint64_t RageThread::GetInvalidThreadID() +std::uint64_t RageThread::GetInvalidThreadID() { return GetInvalidThreadId(); } @@ -386,7 +387,7 @@ void Checkpoints::SetCheckpoint( const char *file, int line, const char *message /* We can't ASSERT here, since that uses checkpoints. */ if( slot == nullptr ) sm_crash( "GetUnknownThreadSlot() returned nullptr" ); - + /* Ignore everything up to and including the first "src/". */ const char *temp = strstr( file, "src/" ); if( temp ) @@ -431,18 +432,18 @@ void Checkpoints::GetLogs( char *pBuf, int iSize, const char *delim ) continue; strcat( pBuf, buf ); strcat( pBuf, delim ); - + for( int line = 1; (buf = GetCheckpointLog(slotno, line)) != nullptr; ++line ) { strcat( pBuf, buf ); strcat( pBuf, delim ); } - } + } } /* * "Safe" mutexes: locking the same mutex more than once from the same thread - * is refcounted and does not deadlock. + * is refcounted and does not deadlock. * * Only actually lock the mutex once; when we do so, remember which thread locked it. * Then, when we lock in the future, only increment a counter, with no locks. @@ -458,7 +459,7 @@ void Checkpoints::GetLogs( char *pBuf, int iSize, const char *delim ) #if 0 static const int MAX_MUTEXES = 256; -/* g_MutexesBefore[n] is a list of mutex IDs which must be locked before n (if at all). +/* g_MutexesBefore[n] is a list of mutex IDs which must be locked before n (if at all). * The array g_MutexesBefore[n] is locked for writing by locking mutex n, so lock that * mutex *before* calling MarkLockedMutex(). */ bool g_MutexesBefore[MAX_MUTEXES][MAX_MUTEXES]; @@ -480,7 +481,7 @@ void RageMutex::MarkLockedMutex() for( unsigned i = 0; i < g_MutexList->size(); ++i ) { const RageMutex *mutex = (*g_MutexList)[i]; - + if( mutex->m_UniqueID == this->m_UniqueID ) continue; @@ -493,20 +494,20 @@ void RageMutex::MarkLockedMutex() { LOG->Warn( "Mutex lock inconsistency: mutex \"%s\" must be locked before \"%s\"", this->GetName().c_str(), mutex->GetName().c_str() ); - + break; } - + /* Optimization: don't add it to the queue if it's already been done. */ if( !g_MutexesBefore[this->m_UniqueID][mutex->m_UniqueID] ) before.push_back( mutex ); } - + while( before.size() ) { const RageMutex *mutex = before.back(); before.pop_back(); - + g_MutexesBefore[this->m_UniqueID][mutex->m_UniqueID] = 1; /* All IDs which must be locked before mutex must also be locked before @@ -525,7 +526,7 @@ static std::set *g_FreeMutexIDs = nullptr; #endif RageMutex::RageMutex( const RString &name ): - m_pMutex( MakeMutex (this ) ), m_sName(name), + m_pMutex( MakeMutex (this ) ), m_sName(name), m_LockedBy(GetInvalidThreadId()), m_LockCnt(0) { @@ -582,7 +583,7 @@ RageMutex::~RageMutex() void RageMutex::Lock() { - uint64_t iThisThreadId = GetThisThreadId(); + std::uint64_t iThisThreadId = GetThisThreadId(); if( m_LockedBy == iThisThreadId ) { ++m_LockCnt; @@ -606,7 +607,7 @@ void RageMutex::Lock() #if defined(CRASH_HANDLER) /* Don't leave GetThreadSlotsLock() locked when we call ForceCrashHandlerDeadlock. */ GetThreadSlotsLock().Lock(); - uint64_t CrashHandle = OtherSlot? OtherSlot->m_iID:0; + std::uint64_t CrashHandle = OtherSlot? OtherSlot->m_iID:0; GetThreadSlotsLock().Unlock(); /* Pass the crash handle of the other thread, so it can backtrace that thread. */ diff --git a/src/RageThreads.h b/src/RageThreads.h index 27cea773c5..7b702d39aa 100644 --- a/src/RageThreads.h +++ b/src/RageThreads.h @@ -1,6 +1,8 @@ #ifndef RAGE_THREADS_H #define RAGE_THREADS_H +#include + struct ThreadSlot; class RageTimer; /** @brief Thread, mutex, semaphore, and event classes. */ @@ -19,17 +21,17 @@ public: void Resume(); /* For crash handlers: kill or suspend all threads (except for - * the running one) immediately. */ + * the running one) immediately. */ static void HaltAllThreads( bool Kill=false ); /* If HaltAllThreads was called (with Kill==false), resume. */ static void ResumeAllThreads(); - static uint64_t GetCurrentThreadID(); + static std::uint64_t GetCurrentThreadID(); static const char *GetCurrentThreadName(); - static const char *GetThreadNameByID( uint64_t iID ); - static bool EnumThreadIDs( int n, uint64_t &iID ); + static const char *GetThreadNameByID( std::uint64_t iID ); + static bool EnumThreadIDs( int n, std::uint64_t &iID ); int Wait(); bool IsCreated() const { return m_pSlot != nullptr; } @@ -41,7 +43,7 @@ public: static bool GetIsShowingDialog() { return s_bIsShowingDialog; } static void SetIsShowingDialog( bool b ) { s_bIsShowingDialog = b; } - static uint64_t GetInvalidThreadID(); + static std::uint64_t GetInvalidThreadID(); private: ThreadSlot *m_pSlot; @@ -49,14 +51,14 @@ private: static bool s_bSystemSupportsTLS; static bool s_bIsShowingDialog; - + // Swallow up warnings. If they must be used, define them. RageThread& operator=(const RageThread& rhs); }; /** * @brief Register a thread created outside of RageThread. - * + * * This gives it a name for RageThread::GetCurrentThreadName, * and allocates a slot for checkpoints. */ class RageThreadRegister @@ -105,8 +107,8 @@ protected: RString m_sName; int m_UniqueID; - - uint64_t m_LockedBy; + + std::uint64_t m_LockedBy; int m_LockCnt; void MarkLockedMutex(); @@ -156,7 +158,7 @@ public: /* * If pTimeout is non-nullptr, the event will be automatically signalled at the given - * time. Note that implementing this timeout is optional; not all archs support it. + * time. Note that implementing this timeout is optional; not all archs support it. * If false is returned, the wait timed out (and the mutex is locked, as if the * event had been signalled). */ @@ -188,7 +190,7 @@ public: private: SemaImpl *m_pSema; RString m_sName; - + // Swallow up warnings. If they must be used, define them. RageSemaphore& operator=(const RageSemaphore& rhs); RageSemaphore(const RageSemaphore& rhs); diff --git a/src/RageTimer.cpp b/src/RageTimer.cpp index 465df8aa2c..dd7a987464 100644 --- a/src/RageTimer.cpp +++ b/src/RageTimer.cpp @@ -28,13 +28,14 @@ #include "arch/ArchHooks/ArchHooks.h" #include +#include #define TIMESTAMP_RESOLUTION 1000000 const RageTimer RageZeroTimer(0,0); -static uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true ); +static std::uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true ); -static uint64_t GetTime( bool /* bAccurate */ ) +static std::uint64_t GetTime( bool /* bAccurate */ ) { return ArchHooks::GetMicrosecondsSinceStart( true ); @@ -43,7 +44,7 @@ static uint64_t GetTime( bool /* bAccurate */ ) #if 0 // if !bAccurate, then don't call ArchHooks to find the current time. Just return the // last calculated time. GetMicrosecondsSinceStart is slow on some archs. - static uint64_t usecs = 0; + static std::uint64_t usecs = 0; if( bAccurate ) usecs = ArchHooks::GetMicrosecondsSinceStart( true ); return usecs; @@ -52,22 +53,22 @@ static uint64_t GetTime( bool /* bAccurate */ ) float RageTimer::GetTimeSinceStart( bool bAccurate ) { - uint64_t usecs = GetTime( bAccurate ); + std::uint64_t usecs = GetTime( bAccurate ); usecs -= g_iStartTime; /* Avoid using doubles for hardware that doesn't support them. * This is writing usecs = high*2^32 + low and doing * usecs/10^6 = high * (2^32/10^6) + low/10^6. */ - return uint32_t(usecs>>32) * 4294.967296f + uint32_t(usecs)/1000000.f; + return std::uint32_t(usecs>>32) * 4294.967296f + std::uint32_t(usecs)/1000000.f; } -uint64_t RageTimer::GetUsecsSinceStart() +std::uint64_t RageTimer::GetUsecsSinceStart() { return GetTime(true) - g_iStartTime; } void RageTimer::Touch() { - uint64_t usecs = GetTime( true ); + std::uint64_t usecs = GetTime( true ); this->m_secs = unsigned(usecs / 1000000); this->m_us = unsigned(usecs % 1000000); diff --git a/src/RageTimer.h b/src/RageTimer.h index 795f2fe825..a642a02579 100644 --- a/src/RageTimer.h +++ b/src/RageTimer.h @@ -3,6 +3,8 @@ #ifndef RAGE_TIMER_H #define RAGE_TIMER_H +#include + class RageTimer { public: @@ -23,7 +25,7 @@ public: /* deprecated: */ static float GetTimeSinceStart( bool bAccurate = true ); // seconds since the program was started static float GetTimeSinceStartFast() { return GetTimeSinceStart(false); } - static uint64_t GetUsecsSinceStart(); + static std::uint64_t GetUsecsSinceStart(); /* Get a timer representing half of the time ago as this one. */ RageTimer Half() const; @@ -53,20 +55,20 @@ private: extern const RageTimer RageZeroTimer; // For profiling how long some chunk of code takes. -Kyz -#define START_TIME(name) uint64_t name##_start_time= RageTimer::GetUsecsSinceStart(); +#define START_TIME(name) std::uint64_t name##_start_time= RageTimer::GetUsecsSinceStart(); #define START_TIME_CALL_COUNT(name) START_TIME(name); ++name##_call_count; -#define END_TIME(name) uint64_t name##_end_time= RageTimer::GetUsecsSinceStart(); LOG->Time(#name " time: %zu to %zu = %zu", name##_start_time, name##_end_time, name##_end_time - name##_start_time); -#define END_TIME_ADD_TO(name) uint64_t name##_end_time= RageTimer::GetUsecsSinceStart(); name##_total += name##_end_time - name##_start_time; +#define END_TIME(name) std::uint64_t name##_end_time= RageTimer::GetUsecsSinceStart(); LOG->Time(#name " time: %zu to %zu = %zu", name##_start_time, name##_end_time, name##_end_time - name##_start_time); +#define END_TIME_ADD_TO(name) std::uint64_t name##_end_time= RageTimer::GetUsecsSinceStart(); name##_total += name##_end_time - name##_start_time; #define END_TIME_CALL_COUNT(name) END_TIME_ADD_TO(name); ++name##_end_count; -#define DECL_TOTAL_TIME(name) extern uint64_t name##_total; -#define DEF_TOTAL_TIME(name) uint64_t name##_total= 0; +#define DECL_TOTAL_TIME(name) extern std::uint64_t name##_total; +#define DEF_TOTAL_TIME(name) std::uint64_t name##_total= 0; #define PRINT_TOTAL_TIME(name) LOG->Time(#name " total time: %zu", name##_total); -#define DECL_TOT_CALL_PAIR(name) extern uint64_t name##_total; extern uint64_t name##_call_count; -#define DEF_TOT_CALL_PAIR(name) uint64_t name##_total= 0; uint64_t name##_call_count= 0; +#define DECL_TOT_CALL_PAIR(name) extern std::uint64_t name##_total; extern std::uint64_t name##_call_count; +#define DEF_TOT_CALL_PAIR(name) std::uint64_t name##_total= 0; std::uint64_t name##_call_count= 0; #define PRINT_TOT_CALL_PAIR(name) LOG->Time(#name " calls: %zu, time: %zu, per: %f", name##_call_count, name##_total, static_cast(name##_total) / name##_call_count); -#define DECL_TOT_CALL_END(name) DECL_TOT_CALL_PAIR(name); extern uint64_t name##_end_count; -#define DEF_TOT_CALL_END(name) DEF_TOT_CALL_PAIR(name); uint64_t name##_end_count= 0; +#define DECL_TOT_CALL_END(name) DECL_TOT_CALL_PAIR(name); extern std::uint64_t name##_end_count; +#define DEF_TOT_CALL_END(name) DEF_TOT_CALL_PAIR(name); std::uint64_t name##_end_count= 0; #define PRINT_TOT_CALL_END(name) LOG->Time(#name " calls: %zu, time: %zu, early end: %zu, per: %f", name##_call_count, name##_total, name##_end_count, static_cast(name##_total) / (name##_call_count - name##_end_count)); #endif diff --git a/src/RageTypes.h b/src/RageTypes.h index fb86290392..486faea5c3 100644 --- a/src/RageTypes.h +++ b/src/RageTypes.h @@ -3,10 +3,11 @@ #ifndef RAGETYPES_H #define RAGETYPES_H -#include - #include "EnumHelper.h" +#include +#include + enum BlendMode { BLEND_NORMAL, @@ -106,25 +107,25 @@ public: RageVector2(): x(0), y(0) {} RageVector2( const float * f ): x(f[0]), y(f[1]) {} RageVector2( float x1, float y1 ): x(x1), y(y1) {} - + // casting operator float* () { return &x; }; operator const float* () const { return &x; }; - + // assignment operators RageVector2& operator += ( const RageVector2& other ) { x+=other.x; y+=other.y; return *this; } RageVector2& operator -= ( const RageVector2& other ) { x-=other.x; y-=other.y; return *this; } RageVector2& operator *= ( float f ) { x*=f; y*=f; return *this; } RageVector2& operator /= ( float f ) { x/=f; y/=f; return *this; } - + // binary operators RageVector2 operator + ( const RageVector2& other ) const { return RageVector2( x+other.x, y+other.y ); } RageVector2 operator - ( const RageVector2& other ) const { return RageVector2( x-other.x, y-other.y ); } RageVector2 operator * ( float f ) const { return RageVector2( x*f, y*f ); } RageVector2 operator / ( float f ) const { return RageVector2( x/f, y/f ); } - + friend RageVector2 operator * ( float f, const RageVector2& other ) { return other*f; } - + float x, y; }; @@ -135,25 +136,25 @@ public: RageVector3(): x(0), y(0), z(0) {} RageVector3( const float * f ): x(f[0]), y(f[1]), z(f[2]) {} RageVector3( float x1, float y1, float z1 ): x(x1), y(y1), z(z1) {} - + // casting operator float* () { return &x; }; operator const float* () const { return &x; }; - + // assignment operators RageVector3& operator += ( const RageVector3& other ) { x+=other.x; y+=other.y; z+=other.z; return *this; } RageVector3& operator -= ( const RageVector3& other ) { x-=other.x; y-=other.y; z-=other.z; return *this; } RageVector3& operator *= ( float f ) { x*=f; y*=f; z*=f; return *this; } RageVector3& operator /= ( float f ) { x/=f; y/=f; z/=f; return *this; } - + // binary operators RageVector3 operator + ( const RageVector3& other ) const { return RageVector3( x+other.x, y+other.y, z+other.z ); } RageVector3 operator - ( const RageVector3& other ) const { return RageVector3( x-other.x, y-other.y, z-other.z ); } RageVector3 operator * ( float f ) const { return RageVector3( x*f, y*f, z*f ); } RageVector3 operator / ( float f ) const { return RageVector3( x/f, y/f, z/f ); } - + friend RageVector3 operator * ( float f, const RageVector3& other ) { return other*f; } - + float x, y, z; }; @@ -164,25 +165,25 @@ public: RageVector4(): x(0), y(0), z(0), w(0) {} RageVector4( const float * f ): x(f[0]), y(f[1]), z(f[2]), w(f[3]) {} RageVector4( float x1, float y1, float z1, float w1 ): x(x1), y(y1), z(z1), w(w1) {} - + // casting operator float* () { return &x; }; operator const float* () const { return &x; }; - + // assignment operators RageVector4& operator += ( const RageVector4& other ) { x+=other.x; y+=other.y; z+=other.z; w+=other.w; return *this; } RageVector4& operator -= ( const RageVector4& other ) { x-=other.x; y-=other.y; z-=other.z; w-=other.w; return *this; } RageVector4& operator *= ( float f ) { x*=f; y*=f; z*=f; w*=f; return *this; } RageVector4& operator /= ( float f ) { x/=f; y/=f; z/=f; w/=f; return *this; } - + // binary operators RageVector4 operator + ( const RageVector4& other ) const { return RageVector4( x+other.x, y+other.y, z+other.z, w+other.w ); } RageVector4 operator - ( const RageVector4& other ) const { return RageVector4( x-other.x, y-other.y, z-other.z, w-other.w ); } RageVector4 operator * ( float f ) const { return RageVector4( x*f, y*f, z*f, w*f ); } RageVector4 operator / ( float f ) const { return RageVector4( x/f, y/f, z/f, w/f ); } - + friend RageVector4 operator * ( float f, const RageVector4& other ) { return other*f; } - + float x, y, z, w; }; @@ -200,11 +201,11 @@ public: a = rv4.w; return *this; } - + // casting operator float* () { return &r; }; operator const float* () const { return &r; }; - + // assignment operators RageColor& operator += ( const RageColor& other ) { r+=other.r; g+=other.g; b+=other.b; a+=other.a; return *this; } RageColor& operator -= ( const RageColor& other ) { r-=other.r; g-=other.g; b-=other.b; a-=other.a; return *this; } @@ -213,7 +214,7 @@ public: /* Divide is rarely useful: you can always use multiplication, and you don't have to * worry about div/0. */ // RageColor& operator /= ( float f ) { r/=f; g/=f; b/=f; a/=f; return *this; } - + // binary operators RageColor operator + ( const RageColor& other ) const { return RageColor( r+other.r, g+other.g, b+other.b, a+other.a ); } RageColor operator - ( const RageColor& other ) const { return RageColor( r-other.r, g-other.g, b-other.b, a-other.a ); } @@ -221,12 +222,12 @@ public: RageColor operator * ( float f ) const { return RageColor( r*f, g*f, b*f, a*f ); } // Divide is useful for using with the SCALE macro RageColor operator / ( float f ) const { return RageColor( r/f, g/f, b/f, a/f ); } - + friend RageColor operator * ( float f, const RageColor& other ) { return other*f; } // What is this for? Did I add this? -Chris - + bool operator == ( const RageColor& other ) const { return r==other.r && g==other.g && b==other.b && a==other.a; } bool operator != ( const RageColor& other ) const { return !operator==(other); } - + bool FromString( const RString &str ) { int result = sscanf( str, "%f,%f,%f,%f", &r, &g, &b, &a ); @@ -237,7 +238,7 @@ public: } if( result == 4 ) return true; - + unsigned int ir=255, ib=255, ig=255, ia=255; result = sscanf( str, "#%2x%2x%2x%2x", &ir, &ig, &ib, &ia ); if( result >= 3 ) @@ -249,7 +250,7 @@ public: a = 1; return true; } - + r=1; b=1; g=1; a=1; return false; } @@ -315,12 +316,12 @@ inline unsigned char FTOC(float a) * r, g, b, a order, independent of endianness, so storing them this * way avoids endianness problems. Don't try to manipulate this; only * manip RageColors. */ -/* Perhaps the math in RageColor could be moved to RageVColor. We don't need the +/* Perhaps the math in RageColor could be moved to RageVColor. We don't need the * precision of a float for our calculations anyway. -Chris */ class RageVColor { public: - uint8_t b,g,r,a; // specific ordering required by Direct3D + std::uint8_t b,g,r,a; // specific ordering required by Direct3D RageVColor(): b(0), g(0), r(0), a(0) { } RageVColor(const RageColor &rc): b(0), g(0), r(0), a(0) { *this = rc; } @@ -339,12 +340,12 @@ namespace StepMania public: Rect(): left(0), top(0), right(0), bottom(0) {} Rect(T l, T t, T r, T b): left(l), top(t), right(r), bottom(b) {} - + T GetWidth() const { return right-left; }; T GetHeight() const { return bottom-top; }; T GetCenterX() const { return (left+right)/2; }; T GetCenterY() const { return (top+bottom)/2; }; - + bool operator==( const Rect &other ) const { #define COMPARE( x ) if( x != other.x ) return false @@ -356,14 +357,14 @@ public: return true; } bool operator!=( const Rect &other ) const { return !operator==(other); } - + T left, top, right, bottom; }; } typedef StepMania::Rect RectI; typedef StepMania::Rect RectF; -/* Structure for our custom vertex type. Note that these data structes +/* Structure for our custom vertex type. Note that these data structes * have the same layout that D3D expects. */ struct RageSpriteVertex // has color { @@ -390,7 +391,7 @@ struct RageModelVertex // doesn't have color. Relies on material color RageVector3 p; // position RageVector3 n; // normal RageVector2 t; // texture coordinates - int8_t bone; + std::int8_t bone; RageVector2 TextureMatrixScale; // usually 1,1 }; diff --git a/src/RageUtil.cpp b/src/RageUtil.cpp index c6aedb5916..e081de5471 100644 --- a/src/RageUtil.cpp +++ b/src/RageUtil.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -194,7 +195,7 @@ bool HexToBinary( const RString &s, unsigned char *stringOut ) break; RString sByte = s.substr( i*2, 2 ); - uint8_t val = 0; + std::uint8_t val = 0; if( sscanf( sByte, "%hhx", &val ) != 1 ) return false; stringOut[i] = val; diff --git a/src/RageUtil.h b/src/RageUtil.h index 21d7464434..a28f61f606 100644 --- a/src/RageUtil.h +++ b/src/RageUtil.h @@ -8,10 +8,11 @@ #include #include #include +#include #include #include -#include #include +#include class RageFileDriver; @@ -215,7 +216,7 @@ namespace Endian #define Swap24 ArchSwap24 #define Swap16 ArchSwap16 #else -inline uint32_t Swap32( uint32_t n ) +inline std::uint32_t Swap32( std::uint32_t n ) { return (n >> 24) | ((n >> 8) & 0x0000FF00) | @@ -223,23 +224,23 @@ inline uint32_t Swap32( uint32_t n ) (n << 24); } -inline uint32_t Swap24( uint32_t n ) +inline std::uint32_t Swap24( std::uint32_t n ) { return Swap32( n ) >> 8; // xx223344 -> 443322xx -> 00443322 } -inline uint16_t Swap16( uint16_t n ) +inline std::uint16_t Swap16( std::uint16_t n ) { return (n >> 8) | (n << 8); } #endif -inline uint32_t Swap32LE( uint32_t n ) { return Endian::little ? n : Swap32( n ); } -inline uint32_t Swap24LE( uint32_t n ) { return Endian::little ? n : Swap24( n ); } -inline uint16_t Swap16LE( uint16_t n ) { return Endian::little ? n : Swap16( n ); } -inline uint32_t Swap32BE( uint32_t n ) { return Endian::big ? n : Swap32( n ); } -inline uint32_t Swap24BE( uint32_t n ) { return Endian::big ? n : Swap24( n ); } -inline uint16_t Swap16BE( uint16_t n ) { return Endian::big ? n : Swap16( n ); } +inline std::uint32_t Swap32LE( std::uint32_t n ) { return Endian::little ? n : Swap32( n ); } +inline std::uint32_t Swap24LE( std::uint32_t n ) { return Endian::little ? n : Swap24( n ); } +inline std::uint16_t Swap16LE( std::uint16_t n ) { return Endian::little ? n : Swap16( n ); } +inline std::uint32_t Swap32BE( std::uint32_t n ) { return Endian::big ? n : Swap32( n ); } +inline std::uint32_t Swap24BE( std::uint32_t n ) { return Endian::big ? n : Swap24( n ); } +inline std::uint16_t Swap16BE( std::uint16_t n ) { return Endian::big ? n : Swap16( n ); } class MersenneTwister : public std::mt19937 { diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 2279fd65c2..c42430fb0d 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -21,6 +21,7 @@ #include "NoteDataWithScoring.h" #include +#include static RString PercentScoreWeightName( std::size_t i ) { return "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i ); } static RString GradeWeightName( std::size_t i ) { return "GradeWeight" + ScoreEventToString( (ScoreEvent)i ); } @@ -200,7 +201,7 @@ void ScoreKeeperNormal::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, GAMESTATE->SetProcessedTimingData(nullptr); } -static int GetScore(int p, int Z, int64_t S, int n) +static int GetScore(int p, int Z, std::int64_t S, int n) { /* There's a problem with the scoring system described below. Z/S is truncated * to an int. However, in some cases we can end up with very small base scores. @@ -218,7 +219,7 @@ static int GetScore(int p, int Z, int64_t S, int n) return p * (Z / S) * n; #elif 1 // This doesn't round down Z/S. - return int(int64_t(p) * n * Z / S); + return int(std::int64_t(p) * n * Z / S); #else // This also doesn't round down Z/S. Use this if you don't have 64-bit ints. return int(p * n * (float(Z) / S)); @@ -279,8 +280,8 @@ void ScoreKeeperNormal::AddScoreInternal( TapNoteScore score ) m_iTapNotesHit++; - const int64_t N = uint64_t(m_iNumTapsAndHolds); - const int64_t sum = (N * (N + 1)) / 2; + const std::int64_t N = std::uint64_t(m_iNumTapsAndHolds); + const std::int64_t sum = (N * (N + 1)) / 2; const int Z = m_iMaxPossiblePoints/10; // Don't use a multiplier if the player has failed diff --git a/src/arch/ArchHooks/ArchHooks.h b/src/arch/ArchHooks/ArchHooks.h index d49b8421d4..61d4913a41 100644 --- a/src/arch/ArchHooks/ArchHooks.h +++ b/src/arch/ArchHooks/ArchHooks.h @@ -1,6 +1,7 @@ #ifndef ARCH_HOOKS_H #define ARCH_HOOKS_H +#include #include 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; diff --git a/src/arch/ArchHooks/ArchHooksUtil.cpp b/src/arch/ArchHooks/ArchHooksUtil.cpp index 4c8ca9ec5e..fe1ac43483 100644 --- a/src/arch/ArchHooks/ArchHooksUtil.cpp +++ b/src/arch/ArchHooks/ArchHooksUtil.cpp @@ -1,6 +1,8 @@ #include "global.h" #include "ArchHooks.h" +#include + /* * 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 diff --git a/src/arch/ArchHooks/ArchHooks_MacOSX.mm b/src/arch/ArchHooks/ArchHooks_MacOSX.mm index 81b4de6f09..89f52288eb 100644 --- a/src/arch/ArchHooks/ArchHooks_MacOSX.mm +++ b/src/arch/ArchHooks/ArchHooks_MacOSX.mm @@ -7,6 +7,7 @@ #include "ProductInfo.h" #include +#include #include #include @@ -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" diff --git a/src/arch/ArchHooks/ArchHooks_Unix.cpp b/src/arch/ArchHooks/ArchHooks_Unix.cpp index 82b69e2750..34e4f9fc15 100644 --- a/src/arch/ArchHooks/ArchHooks_Unix.cpp +++ b/src/arch/ArchHooks/ArchHooks_Unix.cpp @@ -11,6 +11,9 @@ #include "archutils/Common/PthreadHelpers.h" #include "archutils/Unix/EmergencyShutdown.h" #include "archutils/Unix/AssertionHandler.h" + +#include + #if defined(HAVE_UNISTD_H) #include #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 diff --git a/src/arch/ArchHooks/ArchHooks_Unix.h b/src/arch/ArchHooks/ArchHooks_Unix.h index fc1962f874..6c0e61fa2b 100644 --- a/src/arch/ArchHooks/ArchHooks_Unix.h +++ b/src/arch/ArchHooks/ArchHooks_Unix.h @@ -2,6 +2,9 @@ #define ARCH_HOOKS_UNIX_H #include "ArchHooks.h" + +#include + 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 diff --git a/src/arch/ArchHooks/ArchHooks_Win32.cpp b/src/arch/ArchHooks/ArchHooks_Win32.cpp index dbb7281e44..b0518b4b25 100644 --- a/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -14,11 +14,13 @@ #include "VersionHelpers.h" +#include + 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 diff --git a/src/arch/ArchHooks/ArchHooks_Win32Static.cpp b/src/arch/ArchHooks/ArchHooks_Win32Static.cpp index e180868821..e1b9bef145 100644 --- a/src/arch/ArchHooks/ArchHooks_Win32Static.cpp +++ b/src/arch/ArchHooks/ArchHooks_Win32Static.cpp @@ -6,6 +6,8 @@ #include "ProductInfo.h" #include "RageFileManager.h" +#include + // for timeGetTime #include #include @@ -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 diff --git a/src/arch/InputHandler/InputHandler_Linux_Event.cpp b/src/arch/InputHandler/InputHandler_Linux_Event.cpp index 332d627fbe..0326631525 100644 --- a/src/arch/InputHandler/InputHandler_Linux_Event.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_Event.cpp @@ -13,7 +13,8 @@ #include #endif -#include +#include +#include #include #include #include @@ -69,7 +70,7 @@ struct EventDevice static std::vector 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::vectorm_Dev, pDev->m_sName) ); } - + m_bDevicesChanged = false; } @@ -443,7 +444,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector #include +#include #include #include @@ -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); } diff --git a/src/arch/InputHandler/InputHandler_Win32_ddrio.cpp b/src/arch/InputHandler/InputHandler_Win32_ddrio.cpp index 18dc61eede..e0f7ed0def 100644 --- a/src/arch/InputHandler/InputHandler_Win32_ddrio.cpp +++ b/src/arch/InputHandler/InputHandler_Win32_ddrio.cpp @@ -4,12 +4,14 @@ #include "RageLog.h" #include "RageUtil.h" #include "RageInputDevice.h" -#include -#include #include "PrefsManager.h" +#include +#include +#include + 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 diff --git a/src/arch/InputHandler/InputHandler_Win32_ddrio.h b/src/arch/InputHandler/InputHandler_Win32_ddrio.h index df8b27a7a5..3f2e166ba7 100644 --- a/src/arch/InputHandler/InputHandler_Win32_ddrio.h +++ b/src/arch/InputHandler/InputHandler_Win32_ddrio.h @@ -5,9 +5,11 @@ #include "RageThreads.h" #include "arch/Lights/LightsDriver_Export.h" +#include + 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); diff --git a/src/arch/Lights/LightsDriver_LinuxPacDrive.cpp b/src/arch/Lights/LightsDriver_LinuxPacDrive.cpp index aba91e462e..4bbc264c6f 100644 --- a/src/arch/Lights/LightsDriver_LinuxPacDrive.cpp +++ b/src/arch/Lights/LightsDriver_LinuxPacDrive.cpp @@ -5,6 +5,8 @@ #include "RageLog.h" #include "LightsDriver_LinuxPacDrive.h" +#include + extern "C" { #include } @@ -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, diff --git a/src/arch/Lights/LightsDriver_LinuxPacDrive.h b/src/arch/Lights/LightsDriver_LinuxPacDrive.h index 243c615e9e..c470bd1796 100644 --- a/src/arch/Lights/LightsDriver_LinuxPacDrive.h +++ b/src/arch/Lights/LightsDriver_LinuxPacDrive.h @@ -3,6 +3,8 @@ #include "LightsDriver.h" +#include + extern "C" { #include } @@ -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; diff --git a/src/arch/Lights/LightsDriver_Linux_Leds.h b/src/arch/Lights/LightsDriver_Linux_Leds.h index 1d379e245d..f4772d427f 100644 --- a/src/arch/Lights/LightsDriver_Linux_Leds.h +++ b/src/arch/Lights/LightsDriver_Linux_Leds.h @@ -5,11 +5,13 @@ #include "arch/Lights/LightsDriver.h" +#include + 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 */ diff --git a/src/arch/Lights/LightsDriver_Linux_stac.cpp b/src/arch/Lights/LightsDriver_Linux_stac.cpp index f5e187f623..3fcd26a9f1 100644 --- a/src/arch/Lights/LightsDriver_Linux_stac.cpp +++ b/src/arch/Lights/LightsDriver_Linux_stac.cpp @@ -1,5 +1,13 @@ #include "global.h" -#include +#include "LightsDriver_Linux_stac.h" +#include "GameState.h" +#include "Game.h" +#include "RageLog.h" + +#include +#include +#include + #if defined(HAVE_UNISTD_H) #include #endif @@ -10,12 +18,6 @@ #include #endif -#include -#include "LightsDriver_Linux_stac.h" -#include "GameState.h" -#include "Game.h" -#include "RageLog.h" - #include #include #include @@ -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) diff --git a/src/arch/Lights/LightsDriver_Linux_stac.h b/src/arch/Lights/LightsDriver_Linux_stac.h index a6dc1f9d4a..3b43daa164 100644 --- a/src/arch/Lights/LightsDriver_Linux_stac.h +++ b/src/arch/Lights/LightsDriver_Linux_stac.h @@ -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 + //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. - */ \ No newline at end of file + */ diff --git a/src/arch/Lights/LightsDriver_PacDrive.h b/src/arch/Lights/LightsDriver_PacDrive.h index 3ddf290200..55c48829d6 100644 --- a/src/arch/Lights/LightsDriver_PacDrive.h +++ b/src/arch/Lights/LightsDriver_PacDrive.h @@ -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 -*/ \ No newline at end of file +*/ diff --git a/src/arch/Lights/LightsDriver_SextetStream.cpp b/src/arch/Lights/LightsDriver_SextetStream.cpp index 5be1fd9883..9e1b1c7ae8 100644 --- a/src/arch/Lights/LightsDriver_SextetStream.cpp +++ b/src/arch/Lights/LightsDriver_SextetStream.cpp @@ -5,6 +5,7 @@ #include "RageUtil.h" #include "SextetUtils.h" +#include #include // 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); diff --git a/src/arch/Lights/LightsDriver_Win32Serial.cpp b/src/arch/Lights/LightsDriver_Win32Serial.cpp index 3f06a5b6d3..ce4ea0ea1e 100644 --- a/src/arch/Lights/LightsDriver_Win32Serial.cpp +++ b/src/arch/Lights/LightsDriver_Win32Serial.cpp @@ -3,6 +3,8 @@ #include "windows.h" #include "RageUtil.h" +#include + REGISTER_LIGHTS_DRIVER_CLASS(Win32Serial); static Preference 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); diff --git a/src/arch/Lights/LightsDriver_Win32Serial.h b/src/arch/Lights/LightsDriver_Win32Serial.h index 427a4ec8ce..a8ba0b9ad5 100644 --- a/src/arch/Lights/LightsDriver_Win32Serial.h +++ b/src/arch/Lights/LightsDriver_Win32Serial.h @@ -11,10 +11,12 @@ #include "LightsDriver.h" #include "SextetUtils.h" +#include + 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(); diff --git a/src/arch/Lights/SextetUtils.h b/src/arch/Lights/SextetUtils.h index 8671bc84d9..0b3ca1e84d 100644 --- a/src/arch/Lights/SextetUtils.h +++ b/src/arch/Lights/SextetUtils.h @@ -4,6 +4,7 @@ #include "LightsDriver.h" #include +#include /* * 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; diff --git a/src/arch/LoadingWindow/LoadingWindow_Gtk.cpp b/src/arch/LoadingWindow/LoadingWindow_Gtk.cpp index 546be7e1f9..aec3915277 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Gtk.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Gtk.cpp @@ -5,6 +5,8 @@ #include "RageSurface_Load.h" #include "LoadingWindow_Gtk.h" +#include + #include 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 diff --git a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.h b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.h index a8585d6349..e97c64db7f 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.h +++ b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.h @@ -3,10 +3,13 @@ #include "LowLevelWindow.h" #include "RageDisplay.h" + +#include + #include 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 diff --git a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm index e2b85a306f..b84be8e743 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm +++ b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm @@ -7,6 +7,7 @@ #import "arch/ArchHooks/ArchHooks.h" #include +#include #import #import @@ -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(m_iTexHandle); } + std::uintptr_t GetTexture() const { return static_cast(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; } diff --git a/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp b/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp index 06517027af..16a6196747 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp +++ b/src/arch/LowLevelWindow/LowLevelWindow_Win32.cpp @@ -11,6 +11,8 @@ #include "RageDisplay_OGL_Helpers.h" #include "RageDisplay_OGL.h" +#include + #include 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(m_texHandle); } + std::uintptr_t GetTexture() const { return static_cast(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 diff --git a/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp b/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp index 5d6fbb5c05..0b46584db5 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp +++ b/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp @@ -13,7 +13,9 @@ using namespace RageDisplay_Legacy_Helpers; using namespace X11Helper; #include +#include #include + #include #define GLX_GLXEXT_PROTOTYPES #include // 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(scrRes->noutput) && targetOut == None; ++i) { + for (unsigned int i = 0; i < static_cast(scrRes->noutput) && targetOut == None; ++i) { XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]); std::string outName = std::string(outInfo->name, static_cast (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(scrRes->noutput); ++i) { + for (unsigned int i = 0; i < static_cast(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(tgtOutInfo->ncrtc); ++i) + for (unsigned int i = 0; i < static_cast(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(p.width) && modeHeight == static_cast(p.height)) { + if (p.width >= 0 && p.height >= 0 && modeWidth == static_cast(p.width) && modeHeight == static_cast(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(nsizes); ++szIdx) { + for (unsigned int szIdx = 0, mode_idx = 0; nsizes >= 0 && szIdx < static_cast(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(nrates); ++rIdx, ++mode_idx) { + for (unsigned int rIdx = 0; nrates >=0 && rIdx < static_cast(nrates); ++rIdx, ++mode_idx) { DisplayMode m = {static_cast (size.width), static_cast (size.height), static_cast (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(scrRes->noutput); ++outIdx) + for (unsigned int outIdx = 0; outIdx < static_cast(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 outputSupported; DisplayMode outputCurMode{}; RectI outBounds; - for (unsigned int modeIdx = 0; modeIdx < static_cast(outInfo->nmode); ++modeIdx) + for (unsigned int modeIdx = 0; modeIdx < static_cast(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(m_iTexHandle); } + std::uintptr_t GetTexture() const { return static_cast(m_iTexHandle); } void StartRenderingTo(); void FinishRenderingTo(); diff --git a/src/arch/MemoryCard/MemoryCardDriverThreaded_MacOSX.cpp b/src/arch/MemoryCard/MemoryCardDriverThreaded_MacOSX.cpp index e8c7fe10de..3c4721f836 100644 --- a/src/arch/MemoryCard/MemoryCardDriverThreaded_MacOSX.cpp +++ b/src/arch/MemoryCard/MemoryCardDriverThreaded_MacOSX.cpp @@ -4,6 +4,7 @@ #include "RageLog.h" #include +#include #include #include @@ -204,7 +205,7 @@ void MemoryCardDriverThreaded_MacOSX::GetUSBStorageDevices( std::vectorTrace( "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") ); diff --git a/src/arch/MovieTexture/MovieTexture_DShow.cpp b/src/arch/MovieTexture/MovieTexture_DShow.cpp index 6356b3d9f9..32c4529ce9 100644 --- a/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -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 + #include /* 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 pFSrcPinOut; // Source Filter Output Pin + CComPtr 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 diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 7d5cd8dcbc..54d32d88d8 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -9,6 +9,7 @@ #include #include +#include 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 ) diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.h b/src/arch/MovieTexture/MovieTexture_FFMpeg.h index 82d0f85a36..7c7e839551 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.h +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.h @@ -4,6 +4,9 @@ #define RAGE_MOVIE_TEXTURE_FFMPEG_H #include "MovieTexture_Generic.h" + +#include + 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; diff --git a/src/arch/MovieTexture/MovieTexture_Generic.cpp b/src/arch/MovieTexture/MovieTexture_Generic.cpp index 93526d72bb..232eeec9e3 100644 --- a/src/arch/MovieTexture/MovieTexture_Generic.cpp +++ b/src/arch/MovieTexture/MovieTexture_Generic.cpp @@ -10,6 +10,7 @@ #include "Sprite.h" #include +#include #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(); diff --git a/src/arch/MovieTexture/MovieTexture_Generic.h b/src/arch/MovieTexture/MovieTexture_Generic.h index 8d0537b1f6..e60a60afce 100644 --- a/src/arch/MovieTexture/MovieTexture_Generic.h +++ b/src/arch/MovieTexture/MovieTexture_Generic.h @@ -3,6 +3,8 @@ #include "MovieTexture.h" +#include + 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 diff --git a/src/arch/MovieTexture/MovieTexture_Null.cpp b/src/arch/MovieTexture/MovieTexture_Null.cpp index 6ff52fcc4d..de063d5f75 100644 --- a/src/arch/MovieTexture/MovieTexture_Null.cpp +++ b/src/arch/MovieTexture/MovieTexture_Null.cpp @@ -6,12 +6,14 @@ #include "MovieTexture_Null.h" #include "RageSurface.h" +#include + 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 diff --git a/src/arch/Sound/ALSA9Helpers.cpp b/src/arch/Sound/ALSA9Helpers.cpp index 2519c54b78..3e87e58967 100644 --- a/src/arch/Sound/ALSA9Helpers.cpp +++ b/src/arch/Sound/ALSA9Helpers.cpp @@ -5,6 +5,7 @@ #include "ALSA9Dynamic.h" #include "PrefsManager.h" +#include #include #include @@ -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 diff --git a/src/arch/Sound/ALSA9Helpers.h b/src/arch/Sound/ALSA9Helpers.h index 061c638a35..e59d8a2c84 100644 --- a/src/arch/Sound/ALSA9Helpers.h +++ b/src/arch/Sound/ALSA9Helpers.h @@ -1,6 +1,8 @@ #ifndef ALSA9_HELPERS_H #define ALSA9_HELPERS_H +#include + #define ALSA_PCM_NEW_HW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API #include @@ -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 diff --git a/src/arch/Sound/DSoundHelpers.cpp b/src/arch/Sound/DSoundHelpers.cpp index c14a6744de..84a4a9ac31 100644 --- a/src/arch/Sound/DSoundHelpers.cpp +++ b/src/arch/Sound/DSoundHelpers.cpp @@ -6,6 +6,7 @@ #include "archutils/Win32/GetFileInformation.h" #include +#include #if defined(_WINDOWS) #include @@ -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. */ diff --git a/src/arch/Sound/DSoundHelpers.h b/src/arch/Sound/DSoundHelpers.h index de0956955d..a92c3e6480 100644 --- a/src/arch/Sound/DSoundHelpers.h +++ b/src/arch/Sound/DSoundHelpers.h @@ -1,6 +1,8 @@ #ifndef DSOUND_HELPERS #define DSOUND_HELPERS 1 +#include + #if defined(_WINDOWS) #include #include @@ -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 diff --git a/src/arch/Sound/RageSoundDriver.h b/src/arch/Sound/RageSoundDriver.h index 3b4efe73d4..461e583f95 100644 --- a/src/arch/Sound/RageSoundDriver.h +++ b/src/arch/Sound/RageSoundDriver.h @@ -7,6 +7,8 @@ #include "RageTimer.h" #include "RageUtil_CircularBuffer.h" +#include + 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 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 diff --git a/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp b/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp index aedf9f75ef..ce4afc9cfb 100644 --- a/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp +++ b/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp @@ -11,6 +11,7 @@ #include "archutils/Unix/GetSysInfo.h" +#include #include #include @@ -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 diff --git a/src/arch/Sound/RageSoundDriver_ALSA9_Software.h b/src/arch/Sound/RageSoundDriver_ALSA9_Software.h index b4eeb41219..81a1efad85 100644 --- a/src/arch/Sound/RageSoundDriver_ALSA9_Software.h +++ b/src/arch/Sound/RageSoundDriver_ALSA9_Software.h @@ -4,9 +4,10 @@ #include "RageSound.h" #include "RageThreads.h" #include "RageSoundDriver.h" - #include "ALSA9Helpers.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_AU.h b/src/arch/Sound/RageSoundDriver_AU.h index 993dbae3fd..286b14818a 100644 --- a/src/arch/Sound/RageSoundDriver_AU.h +++ b/src/arch/Sound/RageSoundDriver_AU.h @@ -3,6 +3,9 @@ #include "RageSoundDriver.h" #include "RageThreads.h" + +#include + #include 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 diff --git a/src/arch/Sound/RageSoundDriver_AU.mm b/src/arch/Sound/RageSoundDriver_AU.mm index 9776d92996..3dfa0e9b60 100644 --- a/src/arch/Sound/RageSoundDriver_AU.mm +++ b/src/arch/Sound/RageSoundDriver_AU.mm @@ -3,6 +3,9 @@ #include "RageLog.h" #include "PrefsManager.h" #include "archutils/Darwin/DarwinThreadHelpers.h" + +#include + #include #include #include @@ -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 diff --git a/src/arch/Sound/RageSoundDriver_DSound_Software.cpp b/src/arch/Sound/RageSoundDriver_DSound_Software.cpp index ffdc822b8d..3ace157c65 100644 --- a/src/arch/Sound/RageSoundDriver_DSound_Software.cpp +++ b/src/arch/Sound/RageSoundDriver_DSound_Software.cpp @@ -8,6 +8,8 @@ #include "PrefsManager.h" #include "archutils/Win32/ErrorStrings.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_DSound_Software.h b/src/arch/Sound/RageSoundDriver_DSound_Software.h index 68462f88e5..190a1f6fdf 100644 --- a/src/arch/Sound/RageSoundDriver_DSound_Software.h +++ b/src/arch/Sound/RageSoundDriver_DSound_Software.h @@ -5,6 +5,8 @@ #include "RageThreads.h" #include "RageSoundDriver.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_Generic_Software.cpp b/src/arch/Sound/RageSoundDriver_Generic_Software.cpp index 9ceed3265e..ac95775739 100644 --- a/src/arch/Sound/RageSoundDriver_Generic_Software.cpp +++ b/src/arch/Sound/RageSoundDriver_Generic_Software.cpp @@ -8,6 +8,7 @@ #include "RageSoundReader.h" #include +#include 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(); diff --git a/src/arch/Sound/RageSoundDriver_JACK.cpp b/src/arch/Sound/RageSoundDriver_JACK.cpp index af5565f4e9..595c9ccb69 100644 --- a/src/arch/Sound/RageSoundDriver_JACK.cpp +++ b/src/arch/Sound/RageSoundDriver_JACK.cpp @@ -5,6 +5,8 @@ #include "PrefsManager.h" #include "ProductInfo.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_JACK.h b/src/arch/Sound/RageSoundDriver_JACK.h index f871044401..b7fe3fb687 100644 --- a/src/arch/Sound/RageSoundDriver_JACK.h +++ b/src/arch/Sound/RageSoundDriver_JACK.h @@ -2,6 +2,9 @@ #define RAGE_SOUND_JACK #include "RageSoundDriver.h" + +#include + #include #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 diff --git a/src/arch/Sound/RageSoundDriver_Null.cpp b/src/arch/Sound/RageSoundDriver_Null.cpp index ea01de7891..c73ac3adba 100644 --- a/src/arch/Sound/RageSoundDriver_Null.cpp +++ b/src/arch/Sound/RageSoundDriver_Null.cpp @@ -4,6 +4,8 @@ #include "RageUtil.h" #include "PrefsManager.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_Null.h b/src/arch/Sound/RageSoundDriver_Null.h index eed50d25f0..d5d35143b3 100644 --- a/src/arch/Sound/RageSoundDriver_Null.h +++ b/src/arch/Sound/RageSoundDriver_Null.h @@ -3,16 +3,18 @@ #include "RageSoundDriver.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_OSS.cpp b/src/arch/Sound/RageSoundDriver_OSS.cpp index d37f76cd4a..9f89d88866 100644 --- a/src/arch/Sound/RageSoundDriver_OSS.cpp +++ b/src/arch/Sound/RageSoundDriver_OSS.cpp @@ -5,14 +5,16 @@ #include "RageSound.h" #include "RageSoundManager.h" +#include +#include +#include + #if defined(HAVE_UNISTD_H) #include #endif #if defined(HAVE_FCNTL_H) #include #endif -#include -#include #include #include #include @@ -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 diff --git a/src/arch/Sound/RageSoundDriver_OSS.h b/src/arch/Sound/RageSoundDriver_OSS.h index 82a72f054d..f1e61c4889 100644 --- a/src/arch/Sound/RageSoundDriver_OSS.h +++ b/src/arch/Sound/RageSoundDriver_OSS.h @@ -5,6 +5,8 @@ #include "RageThreads.h" #include "RageTimer.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_PulseAudio.cpp b/src/arch/Sound/RageSoundDriver_PulseAudio.cpp index bb42c60287..93897a90e6 100644 --- a/src/arch/Sound/RageSoundDriver_PulseAudio.cpp +++ b/src/arch/Sound/RageSoundDriver_PulseAudio.cpp @@ -13,6 +13,7 @@ #include #include +#include /* 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 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 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) { diff --git a/src/arch/Sound/RageSoundDriver_PulseAudio.h b/src/arch/Sound/RageSoundDriver_PulseAudio.h index a13e4f7932..af7952db98 100644 --- a/src/arch/Sound/RageSoundDriver_PulseAudio.h +++ b/src/arch/Sound/RageSoundDriver_PulseAudio.h @@ -6,6 +6,7 @@ #include "RageSoundDriver.h" #include +#include #include @@ -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; diff --git a/src/arch/Sound/RageSoundDriver_WDMKS.cpp b/src/arch/Sound/RageSoundDriver_WDMKS.cpp index adcbb97921..2a998739cc 100644 --- a/src/arch/Sound/RageSoundDriver_WDMKS.cpp +++ b/src/arch/Sound/RageSoundDriver_WDMKS.cpp @@ -7,6 +7,7 @@ #include "archutils/Win32/ErrorStrings.h" #include +#include #define _INC_MMREG #define _NTRTL_ /* Turn off default definition of DEFINE_GUIDEX */ @@ -1022,7 +1023,7 @@ bool WinWdmStream::SubmitPacket( int iPacket, RString &sError ) #include 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; diff --git a/src/arch/Sound/RageSoundDriver_WDMKS.h b/src/arch/Sound/RageSoundDriver_WDMKS.h index 6ee3ef4130..2f3ffa6564 100644 --- a/src/arch/Sound/RageSoundDriver_WDMKS.h +++ b/src/arch/Sound/RageSoundDriver_WDMKS.h @@ -3,6 +3,9 @@ #include "RageSoundDriver.h" #include "RageThreads.h" + +#include + #include 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 diff --git a/src/arch/Sound/RageSoundDriver_WaveOut.cpp b/src/arch/Sound/RageSoundDriver_WaveOut.cpp index a38420e9be..db849aa367 100644 --- a/src/arch/Sound/RageSoundDriver_WaveOut.cpp +++ b/src/arch/Sound/RageSoundDriver_WaveOut.cpp @@ -13,6 +13,8 @@ #include "PrefsManager.h" #include "archutils/Win32/ErrorStrings.h" +#include + 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 diff --git a/src/arch/Sound/RageSoundDriver_WaveOut.h b/src/arch/Sound/RageSoundDriver_WaveOut.h index df43d37a27..745b39f2ad 100644 --- a/src/arch/Sound/RageSoundDriver_WaveOut.h +++ b/src/arch/Sound/RageSoundDriver_WaveOut.h @@ -3,6 +3,9 @@ #include "RageSoundDriver.h" #include "RageThreads.h" + +#include + #include #include @@ -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 diff --git a/src/arch/Threads/Threads.h b/src/arch/Threads/Threads.h index 734940732f..561d178445 100644 --- a/src/arch/Threads/Threads.h +++ b/src/arch/Threads/Threads.h @@ -1,6 +1,8 @@ #ifndef THREADS_H #define THREADS_H +#include + /* 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 diff --git a/src/arch/Threads/Threads_Pthreads.cpp b/src/arch/Threads/Threads_Pthreads.cpp index 55c93877d9..c8c54cd7ea 100644 --- a/src/arch/Threads/Threads_Pthreads.cpp +++ b/src/arch/Threads/Threads_Pthreads.cpp @@ -5,8 +5,9 @@ #include "RageThreads.h" #include "RageUtil.h" +#include #include -#include +#include #include #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; } diff --git a/src/arch/Threads/Threads_Pthreads.h b/src/arch/Threads/Threads_Pthreads.h index f0efec8a26..daab622c16 100644 --- a/src/arch/Threads/Threads_Pthreads.h +++ b/src/arch/Threads/Threads_Pthreads.h @@ -3,6 +3,8 @@ #include "Threads.h" +#include + #include #include @@ -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(); }; diff --git a/src/arch/Threads/Threads_Win32.cpp b/src/arch/Threads/Threads_Win32.cpp index 4d6dbedcc4..08140a2796 100644 --- a/src/arch/Threads/Threads_Win32.cpp +++ b/src/arch/Threads/Threads_Win32.cpp @@ -5,6 +5,8 @@ #include "RageTimer.h" #include "archutils/Win32/ErrorStrings.h" +#include + 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 diff --git a/src/arch/Threads/Threads_Win32.h b/src/arch/Threads/Threads_Win32.h index 9b932cd3e5..47de510b56 100644 --- a/src/arch/Threads/Threads_Win32.h +++ b/src/arch/Threads/Threads_Win32.h @@ -1,6 +1,8 @@ #ifndef THREADS_WIN32_H #define THREADS_WIN32_H +#include + #include "Threads.h" #if defined(_WINDOWS) # include @@ -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 diff --git a/src/archutils/Common/PthreadHelpers.cpp b/src/archutils/Common/PthreadHelpers.cpp index 05eec07045..72556887b3 100644 --- a/src/archutils/Common/PthreadHelpers.cpp +++ b/src/archutils/Common/PthreadHelpers.cpp @@ -9,15 +9,17 @@ #include "archutils/Unix/RunningUnderValgrind.h" #endif +#include +#include +#include + #if defined(LINUX) #if defined(HAVE_UNISTD_H) #include #endif -#include #if defined(HAVE_FCNTL_H) #include #endif -#include #include #include #include @@ -87,7 +89,7 @@ static int waittid( int ThreadID, int *status, int options ) return ret; bSupportsWall = false; } - + /* XXX: on 2.2, we need to use __WCLONE only if ThreadID isn't the main thread; * perhaps wait and retry without it if errno == ECHILD? */ int ret; @@ -125,7 +127,7 @@ static int PtraceDetach( int ThreadID ) /* Get this thread's ID (this may be a TID or a PID). */ -static uint64_t GetCurrentThreadIdInternal() +static std::uint64_t GetCurrentThreadIdInternal() { /* If we're under Valgrind, neither the PID nor the TID is associated with the * thread. Return the pthread ID. This can't be used to kill threads, etc., @@ -133,7 +135,7 @@ static uint64_t GetCurrentThreadIdInternal() * usable, unique ID, then mutexes won't work. */ if( RunningUnderValgrind() ) return (int) pthread_self(); - + InitializePidThreadHelpers(); // for g_bUsingNPTL /* Don't keep calling gettid() if it's not supported; it'll make valgrind spam us. */ @@ -155,14 +157,14 @@ static uint64_t GetCurrentThreadIdInternal() return getpid(); } -uint64_t GetCurrentThreadId() +std::uint64_t GetCurrentThreadId() { #if defined(HAVE_TLS) /* This is called each time we lock a mutex, and gettid() is a little slow, so * cache the result if we support TLS. */ if( RageThread::GetSupportsTLS() ) { - static thread_local uint64_t cached_tid = 0; + static thread_local std::uint64_t cached_tid = 0; static thread_local bool cached = false; if( !cached ) { @@ -176,7 +178,7 @@ uint64_t GetCurrentThreadId() return GetCurrentThreadIdInternal(); } -int SuspendThread( uint64_t ThreadID ) +int SuspendThread( std::uint64_t ThreadID ) { /* * Linux: We can't simply kill(SIGSTOP) (or tkill), since that will stop all processes @@ -187,7 +189,7 @@ int SuspendThread( uint64_t ThreadID ) // kill( ThreadID, SIGSTOP ); } -int ResumeThread( uint64_t ThreadID ) +int ResumeThread( std::uint64_t ThreadID ) { return PtraceDetach( int(ThreadID) ); // kill( ThreadID, SIGSTOP ); @@ -203,7 +205,7 @@ int ResumeThread( uint64_t ThreadID ) * This call leaves the given thread suspended, so the returned context doesn't become invalid. * ResumeThread() can be used to resume a thread after this call. */ #if defined(CRASH_HANDLER) -bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx ) +bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx ) { /* Can't GetThreadBacktraceContext the current thread. */ ASSERT( ThreadID != GetCurrentThreadId() ); @@ -264,17 +266,17 @@ RString ThreadsVersion() return "(unknown)"; } -uint64_t GetCurrentThreadId() +std::uint64_t GetCurrentThreadId() { - return uint64_t( pthread_self() ); + return std::uint64_t( pthread_self() ); } -int SuspendThread( uint64_t id ) +int SuspendThread( std::uint64_t id ) { return pthread_kill( pthread_t(id), SIGSTOP ); } -int ResumeThread( uint64_t id ) +int ResumeThread( std::uint64_t id ) { return pthread_kill( pthread_t(id), SIGCONT ); } @@ -283,7 +285,7 @@ int ResumeThread( uint64_t id ) /* * (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 @@ -293,7 +295,7 @@ int ResumeThread( uint64_t id ) * 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 diff --git a/src/archutils/Common/PthreadHelpers.h b/src/archutils/Common/PthreadHelpers.h index 3ed725e4fb..e473b041d2 100644 --- a/src/archutils/Common/PthreadHelpers.h +++ b/src/archutils/Common/PthreadHelpers.h @@ -1,31 +1,30 @@ #ifndef PID_THREAD_HELPERS_H #define PID_THREAD_HELPERS_H -#if defined(HAVE_STDINT_H) -#include -#endif #include "global.h" +#include + RString ThreadsVersion(); /* Get the current thread's ThreadID. */ -uint64_t GetCurrentThreadId(); +std::uint64_t GetCurrentThreadId(); /* Return true if NPTL libraries are in use, false if linuxthreads. */ bool UsingNPTL(); -int SuspendThread( uint64_t ThreadID ); -int ResumeThread( uint64_t ThreadID ); +int SuspendThread( std::uint64_t ThreadID ); +int ResumeThread( std::uint64_t ThreadID ); struct BacktraceContext; -int GetThreadContext( uint64_t ThreadID, BacktraceContext *ctx ); - +int GetThreadContext( std::uint64_t ThreadID, BacktraceContext *ctx ); + #endif /* * (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 @@ -35,7 +34,7 @@ int GetThreadContext( uint64_t ThreadID, BacktraceContext *ctx ); * 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 diff --git a/src/archutils/Common/gcc_byte_swaps.h b/src/archutils/Common/gcc_byte_swaps.h index a9006240b6..1cef37098a 100644 --- a/src/archutils/Common/gcc_byte_swaps.h +++ b/src/archutils/Common/gcc_byte_swaps.h @@ -3,11 +3,9 @@ #if defined(CPU_X86) -#if defined(HAVE_STDINT_H) -#include -#endif +#include -inline uint32_t ArchSwap32( uint32_t n ) +inline std::uint32_t ArchSwap32( std::uint32_t n ) { asm( "xchg %b0, %h0\n" @@ -17,7 +15,7 @@ inline uint32_t ArchSwap32( uint32_t n ) return n; } -inline uint32_t ArchSwap24( uint32_t n ) +inline std::uint32_t ArchSwap24( std::uint32_t n ) { asm( "xchg %b0, %h0\n" @@ -28,7 +26,7 @@ inline uint32_t ArchSwap24( uint32_t n ) return n; } -inline uint16_t ArchSwap16( uint16_t n ) +inline std::uint16_t ArchSwap16( std::uint16_t n ) { asm( "xchg %b0, %h0\n": @@ -43,7 +41,7 @@ inline uint16_t ArchSwap16( uint16_t n ) /* * (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 @@ -53,7 +51,7 @@ inline uint16_t ArchSwap16( uint16_t n ) * 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 diff --git a/src/archutils/Darwin/DarwinThreadHelpers.cpp b/src/archutils/Darwin/DarwinThreadHelpers.cpp index 4880b07594..61a0e52ec3 100644 --- a/src/archutils/Darwin/DarwinThreadHelpers.cpp +++ b/src/archutils/Darwin/DarwinThreadHelpers.cpp @@ -6,23 +6,24 @@ #include "Backtrace.h" #include +#include -bool SuspendThread( uint64_t threadHandle ) +bool SuspendThread( std::uint64_t threadHandle ) { return !thread_suspend( thread_act_t(threadHandle) ); } -bool ResumeThread( uint64_t threadHandle ) +bool ResumeThread( std::uint64_t threadHandle ) { return !thread_resume( thread_act_t(threadHandle) ); } -uint64_t GetCurrentThreadId() +std::uint64_t GetCurrentThreadId() { return mach_thread_self(); } -bool GetThreadBacktraceContext( uint64_t iID, BacktraceContext *ctx ) +bool GetThreadBacktraceContext( std::uint64_t iID, BacktraceContext *ctx ) { /* Can't GetThreadBacktraceContext the current thread. */ ASSERT( iID != GetCurrentThreadId() ); diff --git a/src/archutils/Darwin/DarwinThreadHelpers.h b/src/archutils/Darwin/DarwinThreadHelpers.h index 84b8b5f168..5c241c5e5a 100644 --- a/src/archutils/Darwin/DarwinThreadHelpers.h +++ b/src/archutils/Darwin/DarwinThreadHelpers.h @@ -1,20 +1,22 @@ #ifndef DARWIN_THREAD_HELPERS_H #define DARWIN_THREAD_HELPERS_H +#include + /** * @brief Attempt to suspend the specified thread. * @param threadHandle the thread to suspend. * @return true if the thread is suspended, false otherwise. */ -bool SuspendThread( uint64_t threadHandle ); +bool SuspendThread( std::uint64_t threadHandle ); /** * @brief Attempt to resume the specified thread. * @param threadHandle the thread to resume. * @return true if the thread is resumed, false otherwise. */ -bool ResumeThread( uint64_t threadHandle ); +bool ResumeThread( std::uint64_t threadHandle ); /** * @brief Retrieve the current thread ID. * @return the current thread ID. */ -uint64_t GetCurrentThreadId(); +std::uint64_t GetCurrentThreadId(); /** * @brief Set the precedence for the thread. * @@ -30,7 +32,7 @@ RString SetThreadPrecedence( float prec ); * @author Steve Checkoway (c) 2004-2006 * @section LICENSE * 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 @@ -40,7 +42,7 @@ RString SetThreadPrecedence( float prec ); * 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 diff --git a/src/archutils/Darwin/HIDDevice.h b/src/archutils/Darwin/HIDDevice.h index 2874ec9c9c..2b2cb27334 100644 --- a/src/archutils/Darwin/HIDDevice.h +++ b/src/archutils/Darwin/HIDDevice.h @@ -1,6 +1,15 @@ #ifndef HIDDEVICE_H #define HIDDEVICE_H +#include "RageLog.h" +#include "RageInputDevice.h" + +#include +#include +#include +#include +#include + #include #include #include @@ -9,13 +18,6 @@ #include #include #include -#include -#include -#include -#include - -#include "RageLog.h" -#include "RageInputDevice.h" /* A few helper functions. */ @@ -48,11 +50,11 @@ namespace __gnu_cxx { #ifndef __LP64__ template<> - struct hash : private hash + struct hash : private hash { std::size_t operator()( const IOHIDElementCookie& cookie ) const { - return hash::operator()( uintptr_t(cookie) ); + return hash::operator()( std::uintptr_t(cookie) ); } }; #endif diff --git a/src/archutils/Darwin/JoystickDevice.cpp b/src/archutils/Darwin/JoystickDevice.cpp index a52d6aa045..0804a8fb9e 100644 --- a/src/archutils/Darwin/JoystickDevice.cpp +++ b/src/archutils/Darwin/JoystickDevice.cpp @@ -2,6 +2,8 @@ #include "JoystickDevice.h" #include "RageLog.h" +#include + Joystick::Joystick() : id( InputDevice_Invalid ), x_axis( 0 ), y_axis( 0 ), z_axis( 0 ), x_rot( 0 ), y_rot( 0 ), z_rot( 0 ), hat( 0 ), @@ -43,10 +45,10 @@ void JoystickDevice::AddElement( int usagePage, int usage, IOHIDElementCookie co { int iMin = 0; int iMax = 0; - + IntValue( CFDictionaryGetValue(properties, CFSTR(kIOHIDElementMinKey)), iMin ); IntValue( CFDictionaryGetValue(properties, CFSTR(kIOHIDElementMaxKey)), iMax ); - + switch( usage ) { case kHIDUsage_GD_X: @@ -142,7 +144,7 @@ bool JoystickDevice::InitDevice( int vid, int pid ) if( vid != 0x0507 || pid != 0x0011 ) return true; // It's a Para controller, so try to power it on. - uint8_t powerOn = 1; + std::uint8_t powerOn = 1; IOReturn ret = SetReport( kIOHIDReportTypeFeature, 0, &powerOn, 1, 10 ); if( ret ) @@ -267,7 +269,7 @@ void JoystickDevice::GetDevicesAndDescriptions( std::vector& vD /* * (c) 2005-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 @@ -277,7 +279,7 @@ void JoystickDevice::GetDevicesAndDescriptions( std::vector& vD * 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 diff --git a/src/archutils/Darwin/PumpDevice.cpp b/src/archutils/Darwin/PumpDevice.cpp index d43bf57e05..6b7c851f57 100644 --- a/src/archutils/Darwin/PumpDevice.cpp +++ b/src/archutils/Darwin/PumpDevice.cpp @@ -1,6 +1,8 @@ #include "global.h" #include "PumpDevice.h" +#include + void PumpDevice::Open() { AddElementToQueue( IOHIDElementCookie(2) ); @@ -17,8 +19,8 @@ void PumpDevice::GetButtonPresses( std::vector& vPresses, IOHIDElem DeviceButton db2 = DeviceButton_Invalid; bool pressed1 = !(value & 0x1); bool pressed2 = !(value & 0x2); - - switch( uintptr_t(cookie) ) + + switch( std::uintptr_t(cookie) ) { case 2: db2 = JOY_BUTTON_1; // bit 9 @@ -66,7 +68,7 @@ void PumpDevice::GetDevicesAndDescriptions( std::vector& vDevic /* * (c) 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 @@ -76,7 +78,7 @@ void PumpDevice::GetDevicesAndDescriptions( std::vector& vDevic * 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 diff --git a/src/archutils/Darwin/VectorHelper.cpp b/src/archutils/Darwin/VectorHelper.cpp index 73929f11fc..c188f67569 100644 --- a/src/archutils/Darwin/VectorHelper.cpp +++ b/src/archutils/Darwin/VectorHelper.cpp @@ -1,15 +1,16 @@ #include "VectorHelper.h" #include +#include +#include + #if defined(USE_VEC) #if defined(__VEC__) #include -#include - bool Vector::CheckForVector() { - int32_t result = 0; + std::int32_t result = 0; std::size_t size = 4; return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result; @@ -32,7 +33,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size ) vFloat store = (vFloat)(0.0f); // If dest is misaligned, pull the first loop iteration out. - if( intptr_t(dest) & 0xF ) + if( std::intptr_t(dest) & 0xF ) { vFloat load2Src = vec_ld( 15, src ); vFloat load2Dest = vec_ld( 15, dest ); @@ -43,7 +44,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size ) load1Dest = vec_add( load1Dest, load1Src ); store = vec_perm( load1Dest, load1Dest, storeMask ); - while( (intptr_t(dest) + index) & 0xC ) + while( (std::intptr_t(dest) + index) & 0xC ) { vec_ste( store, index, dest ); index += 4; @@ -191,7 +192,7 @@ bool Vector::CheckForVector() void Vector::FastSoundWrite( float *dest, const float *src, unsigned size ) { - while( (intptr_t(dest) & 0xF) && size ) + while( (std::intptr_t(dest) & 0xF) && size ) { // Misaligned stores are slow. *(dest++) += *(src++); @@ -199,7 +200,7 @@ void Vector::FastSoundWrite( float *dest, const float *src, unsigned size ) } // Misaligned loads are slower so specialize to aligned loads when possible. - if( intptr_t(src) & 0xF ) + if( std::intptr_t(src) & 0xF ) { while( size >= 8 ) { diff --git a/src/archutils/Unix/Backtrace.cpp b/src/archutils/Unix/Backtrace.cpp index b93c45c306..01a5b9c2d2 100644 --- a/src/archutils/Unix/Backtrace.cpp +++ b/src/archutils/Unix/Backtrace.cpp @@ -2,18 +2,19 @@ #include "Backtrace.h" #include "RageUtil.h" -#if defined(HAVE_UNISTD_H) -#include -#endif +#include #include +#include #include #include #include #include -#include #if defined(HAVE_FCNTL_H) #include #endif +#if defined(HAVE_UNISTD_H) +#include +#endif #if defined(BACKTRACE_METHOD_X86_LINUX) #include "archutils/Common/PthreadHelpers.h" @@ -38,9 +39,9 @@ static const char *itoa(unsigned n) return p; } -static intptr_t xtoi( const char *hex ) +static std::intptr_t xtoi( const char *hex ) { - intptr_t ret = 0; + std::intptr_t ret = 0; for(;;) { int val = -1; @@ -501,7 +502,7 @@ static bool PointsToValidCall( vm_address_t start, const void *ptr ) /* We're reading buf backwards, between buf[-7] and buf[-1]. Find out how * far we can read. */ - const int len = std::min(intptr_t(ptr) - start, 7); + const int len = std::min(std::intptr_t(ptr) - start, 7); // Permissible CALL sequences that we care about: // @@ -598,7 +599,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c // Make sure this is on the stack if( !GetRegionInfo(self, frame, start, protection) || protection != PROT_RW ) break; - if( (start != g_StackPointer && start != stackPointer) || uintptr_t(frame)-uintptr_t(start) < sizeof(Frame) ) + if( (start != g_StackPointer && start != stackPointer) || std::uintptr_t(frame)-std::uintptr_t(start) < sizeof(Frame) ) break; /* The stack pointer is always 16 byte aligned _before_ the call. Thus a valid frame @@ -616,7 +617,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c * Therefore, frame + 8 should be on a 16 byte boundary, the frame link should be * at a higher address, the link should be on the stack and it should be RW. The * return address should be EXE and point to a valid call (well, just after). */ - if( (((uintptr_t)frame+8) & 0xF) != 0 ||// boundary + if( (((std::uintptr_t)frame+8) & 0xF) != 0 ||// boundary frame->link <= frame || // the frame link goes up !GetRegionInfo(self, frame->link, start, protection) || (start != g_StackPointer && start != stackPointer) || // the link is on the stack @@ -628,7 +629,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c /* This is not a valid frame but we might be in code compiled with * -fomit-frame-pointer so look at each address on the stack that is * 4 bytes below a 16 byte boundary. */ - if( (((uintptr_t)frame+4) & 0xF) == 0 ) + if( (((std::uintptr_t)frame+4) & 0xF) == 0 ) { void *p = *(void **)frame; if( GetRegionInfo(self, p, start, protection) && @@ -638,7 +639,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c buf[i++] = p; } } - frame = (Frame *)(intptr_t(frame)+4); + frame = (Frame *)(std::intptr_t(frame)+4); continue; } // Valid. diff --git a/src/archutils/Unix/Backtrace.h b/src/archutils/Unix/Backtrace.h index b01d892c55..42853dc339 100644 --- a/src/archutils/Unix/Backtrace.h +++ b/src/archutils/Unix/Backtrace.h @@ -2,6 +2,7 @@ #define BACKTRACE_H #include +#include /* This API works like backtrace_pointers(), to retrieve a stack trace. */ @@ -40,7 +41,7 @@ void GetBacktrace( const void **buf, std::size_t size, const BacktraceContext *c /* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may * not be the current thread. True is returned on success, false on failure. */ -bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx ); +bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx ); /* Set up a BacktraceContext to get a backtrace after receiving a signal, given * a ucontext_t (see sigaction(2)). (This interface is UNIX-specific.) */ diff --git a/src/archutils/Unix/BacktraceNames.cpp b/src/archutils/Unix/BacktraceNames.cpp index 9fa4851131..5ef61b2ba5 100644 --- a/src/archutils/Unix/BacktraceNames.cpp +++ b/src/archutils/Unix/BacktraceNames.cpp @@ -3,15 +3,16 @@ #include "global.h" #include "BacktraceNames.h" +#include +#include #include +#include #include #include -#include +#include #if defined(HAVE_UNISTD_H) #include #endif -#include -#include #include "RageUtil.h" @@ -100,7 +101,7 @@ RString BacktraceNames::Format() const #include void BacktraceNames::FromAddr( void * const p ) { - Address = (intptr_t) p; + Address = (std::intptr_t) p; /* * When calling a function that doesn't return, gcc will truncate a function. @@ -225,7 +226,7 @@ static const char *osx_find_link_edit( const struct mach_header *header ) void BacktraceNames::FromAddr( void * const p ) { - Address = (intptr_t) p; + Address = (std::intptr_t) p; /* Find the image with the given pointer. */ int index = osx_find_image( p ); @@ -297,7 +298,7 @@ void BacktraceNames::FromAddr( void * const p ) #include void BacktraceNames::FromAddr( void * const p ) { - Address = (intptr_t) p; + Address = (std::intptr_t) p; char **foo = backtrace_symbols(&p, 1); if( foo == nullptr ) @@ -345,7 +346,7 @@ void BacktraceNames::FromString( RString s ) #warning Undefined BACKTRACE_LOOKUP_METHOD_* void BacktraceNames::FromAddr( void * const p ) { - Address = intptr_t(p); + Address = std::intptr_t(p); Offset = 0; Symbol = ""; File = ""; diff --git a/src/archutils/Unix/BacktraceNames.h b/src/archutils/Unix/BacktraceNames.h index 4ab2824d50..896c90a0b0 100644 --- a/src/archutils/Unix/BacktraceNames.h +++ b/src/archutils/Unix/BacktraceNames.h @@ -1,10 +1,12 @@ #ifndef BACKTRACE_NAMES_H #define BACKTRACE_NAMES_H +#include + struct BacktraceNames { RString Symbol, File; - intptr_t Address; + std::intptr_t Address; int Offset; void FromAddr( void * const p ); void FromString( RString str ); diff --git a/src/archutils/Unix/CrashHandler.cpp b/src/archutils/Unix/CrashHandler.cpp index dd829ff49e..052a515837 100644 --- a/src/archutils/Unix/CrashHandler.cpp +++ b/src/archutils/Unix/CrashHandler.cpp @@ -1,8 +1,10 @@ #include "global.h" +#include +#include +#include #include #include -#include #if defined(HAVE_UNISTD_H) #include #endif @@ -12,7 +14,6 @@ #if defined(HAVE_FCNTL_H) #include #endif -#include #include "RageLog.h" /* for RageLog::GetAdditionalLog, etc, only */ #include "RageThreads.h" @@ -24,7 +25,7 @@ #include "CrashHandler.h" #include "CrashHandlerInternal.h" -extern uint64_t GetInvalidThreadId(); +extern std::uint64_t GetInvalidThreadId(); extern const char *g_pCrashHandlerArgv0; static void safe_print( int fd, ... ) @@ -314,7 +315,7 @@ static void RunCrashHandler( const CrashData *crash ) static void BacktraceAllThreads( CrashData& crash ) { int iCnt = 1; - uint64_t iID; + std::uint64_t iID; for( int i = 0; RageThread::EnumThreadIDs(i, iID); ++i ) { @@ -347,7 +348,7 @@ void CrashHandler::ForceCrash( const char *reason ) RunCrashHandler( &crash ); } -void CrashHandler::ForceDeadlock( RString reason, uint64_t iID ) +void CrashHandler::ForceDeadlock( RString reason, std::uint64_t iID ) { CrashData crash; memset( &crash, 0, sizeof(crash) ); diff --git a/src/archutils/Unix/CrashHandler.h b/src/archutils/Unix/CrashHandler.h index 2f80db5904..c89cf6c3af 100644 --- a/src/archutils/Unix/CrashHandler.h +++ b/src/archutils/Unix/CrashHandler.h @@ -2,6 +2,8 @@ #define CRASH_HANDLER_H #include +#include + #include namespace CrashHandler @@ -10,7 +12,7 @@ namespace CrashHandler void InitializeCrashHandler(); void CrashSignalHandler( int signal, siginfo_t *si, const ucontext_t *uc ); void ForceCrash( const char *reason ); - void ForceDeadlock( RString reason, uint64_t CrashHandle ); + void ForceDeadlock( RString reason, std::uint64_t CrashHandle ); } #endif @@ -18,7 +20,7 @@ namespace CrashHandler /* * (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 @@ -28,7 +30,7 @@ namespace CrashHandler * 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 diff --git a/src/archutils/Unix/X11Helper.cpp b/src/archutils/Unix/X11Helper.cpp index 763fb27c5a..8de5cd51dd 100644 --- a/src/archutils/Unix/X11Helper.cpp +++ b/src/archutils/Unix/X11Helper.cpp @@ -5,6 +5,8 @@ #include "Preference.h" #include "PrefsManager.h" // XXX: only used for m_bShowMouseCursor -aj +#include + #include Display *X11Helper::Dpy = nullptr; @@ -204,8 +206,8 @@ bool X11Helper::SetWMFullscreenMonitors( const DisplaySpec &target ) { auto mon = std::find_if( screens, end, [&]( XineramaScreenInfo &screen ) { return screen.x_org == target.currentBounds().left && screen.y_org == target.currentBounds().top - && screen.width >= 0 && static_cast(screen.width) == target.currentMode()->width - && screen.height >= 0 && static_cast(screen.height) == target.currentMode()->height; + && screen.width >= 0 && static_cast(screen.width) == target.currentMode()->width + && screen.height >= 0 && static_cast(screen.height) == target.currentMode()->height; } ); if (mon != end) { diff --git a/src/archutils/Unix/arch_setup.h b/src/archutils/Unix/arch_setup.h index 3fe6f905c1..69afb2073d 100644 --- a/src/archutils/Unix/arch_setup.h +++ b/src/archutils/Unix/arch_setup.h @@ -9,10 +9,6 @@ #include #endif -#if defined(HAVE_STDINT_H) /* need to define int64_t if so */ -#include -#endif - #ifdef HAVE_SYS_PARAM_H #include #endif diff --git a/src/archutils/Win32/Crash.cpp b/src/archutils/Win32/Crash.cpp index 92b101847b..a3457ab1f8 100644 --- a/src/archutils/Win32/Crash.cpp +++ b/src/archutils/Win32/Crash.cpp @@ -4,6 +4,7 @@ //#include #include +#include #include #include "global.h" @@ -580,7 +581,7 @@ static void debug_crash() /* Get a stack trace of the current thread and the specified thread. * If iID == GetInvalidThreadId(), then output a stack trace for every thread. */ -void CrashHandler::ForceDeadlock( RString reason, uint64_t iID ) +void CrashHandler::ForceDeadlock( RString reason, std::uint64_t iID ) { strncpy( g_CrashInfo.m_CrashReason, reason, sizeof(g_CrashInfo.m_CrashReason) ); g_CrashInfo.m_CrashReason[ sizeof(g_CrashInfo.m_CrashReason)-1 ] = 0; @@ -607,7 +608,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID ) context.ContextFlags = CONTEXT_FULL; if( !GetThreadContext( hThread, &context ) ) wsprintf( g_CrashInfo.m_CrashReason + strlen(g_CrashInfo.m_CrashReason), - "; GetThreadContext(%Ix) failed", reinterpret_cast(hThread) ); + "; GetThreadContext(%Ix) failed", reinterpret_cast(hThread) ); else { static const void *BacktracePointers[BACKTRACE_MAX_SIZE]; diff --git a/src/archutils/Win32/Crash.h b/src/archutils/Win32/Crash.h index 102b49cb43..f0553512ae 100644 --- a/src/archutils/Win32/Crash.h +++ b/src/archutils/Win32/Crash.h @@ -2,6 +2,7 @@ #define CRASH_H #include +#include #include /** @brief Win32 crash handling. */ @@ -12,7 +13,7 @@ namespace CrashHandler void do_backtrace( const void **buf, std::size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext ); void SymLookup( const void *ptr, char *buf ); void ForceCrash( const char *reason ); - void ForceDeadlock( RString reason, uint64_t iID ); + void ForceDeadlock( RString reason, std::uint64_t iID ); /* Inform the crash handler of a foreground window that may be fullscreen. * If set, the crash handler will attempt to hide the window or reset the diff --git a/src/archutils/Win32/CrashHandlerChild.cpp b/src/archutils/Win32/CrashHandlerChild.cpp index bac50f47cd..85f091fa94 100644 --- a/src/archutils/Win32/CrashHandlerChild.cpp +++ b/src/archutils/Win32/CrashHandlerChild.cpp @@ -1,9 +1,11 @@ #include "global.h" #include "CrashHandlerInternal.h" #include "Crash.h" -#include +#include #include +#include + #include #include #include "archutils/Win32/ddk/dbghelp.h" @@ -53,10 +55,10 @@ namespace VDDebugInfo int nBuildNumber; const unsigned char *pRVAHeap; - uintptr_t nFirstRVA; + std::uintptr_t nFirstRVA; const char *pFuncNameHeap; - const uintptr_t (*pSegments)[2]; + const std::uintptr_t (*pSegments)[2]; int nSegments; char sFilename[1024]; RString sError; @@ -110,10 +112,10 @@ namespace VDDebugInfo src += 2 * (sizeof(int) + sizeof(std::size_t)); pctx->nBuildNumber = *pVer; - pctx->pRVAHeap = reinterpret_cast(src + sizeof(uintptr_t)); - pctx->nFirstRVA = *reinterpret_cast(src); + pctx->pRVAHeap = reinterpret_cast(src + sizeof(std::uintptr_t)); + pctx->nFirstRVA = *reinterpret_cast(src); pctx->pFuncNameHeap = reinterpret_cast(src + *pRVASize); - pctx->pSegments = reinterpret_cast(src + *pRVASize + *pFNamSize); + pctx->pSegments = reinterpret_cast(src + *pRVASize + *pFNamSize); pctx->nSegments = *pSegCnt; return true; @@ -167,7 +169,7 @@ namespace VDDebugInfo return false; } - static bool PointerIsInAnySegment( const Context *pctx, uintptr_t rva ) + static bool PointerIsInAnySegment( const Context *pctx, std::uintptr_t rva ) { for( int i=0; inSegments; ++i ) { @@ -186,7 +188,7 @@ namespace VDDebugInfo return heap; } - intptr_t VDDebugInfoLookupRVA( const Context *pctx, uintptr_t rva, char *buf, int buflen ) + std::intptr_t VDDebugInfoLookupRVA( const Context *pctx, std::uintptr_t rva, char *buf, int buflen ) { if( !PointerIsInAnySegment(pctx, rva) ) return -1; @@ -198,13 +200,13 @@ namespace VDDebugInfo // Linearly unpack RVA deltas and find lower_bound rva -= pctx->nFirstRVA; - if( static_cast(rva) < 0 ) + if( static_cast(rva) < 0 ) return -1; while( pr < pr_limit ) { unsigned char c; - uintptr_t diff = 0; + std::uintptr_t diff = 0; do { @@ -215,7 +217,7 @@ namespace VDDebugInfo rva -= diff; - if (static_cast(rva) < 0) { + if (static_cast(rva) < 0) { rva += diff; break; } @@ -234,7 +236,7 @@ namespace VDDebugInfo strncpy( buf, fn_name, buflen ); buf[buflen-1] = 0; - return static_cast(rva); + return static_cast(rva); } } @@ -287,7 +289,7 @@ namespace SymbolLookup return true; } - SYMBOL_INFO *GetSym( uintptr_t ptr, DWORD64 &disp ) + SYMBOL_INFO *GetSym( std::uintptr_t ptr, DWORD64 &disp ) { InitDbghelp(); @@ -367,12 +369,12 @@ namespace SymbolLookup VirtualQueryEx( g_hParent, ptr, &meminfo, sizeof meminfo ); char tmp[512]; - intptr_t iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, reinterpret_cast(ptr), tmp, sizeof(tmp)); + std::intptr_t iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, reinterpret_cast(ptr), tmp, sizeof(tmp)); if( iAddress >= 0 ) { - wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]", reinterpret_cast(ptr), Demangle(tmp), + wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]", reinterpret_cast(ptr), Demangle(tmp), pctx->nFirstRVA, - reinterpret_cast(ptr) - pctx->nFirstRVA - iAddress, + reinterpret_cast(ptr) - pctx->nFirstRVA - iAddress, iAddress ); return; } @@ -380,21 +382,21 @@ namespace SymbolLookup RString sName = CrashChildGetModuleBaseName( (HMODULE)meminfo.AllocationBase ); DWORD64 disp; - SYMBOL_INFO *pSymbol = GetSym( reinterpret_cast(ptr), disp ); + SYMBOL_INFO *pSymbol = GetSym( reinterpret_cast(ptr), disp ); if( pSymbol ) { wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s!%s [%" ADDRESS_ZEROS "Ix+%Ix+%Ix]", - reinterpret_cast(ptr), sName.c_str(), pSymbol->Name, - reinterpret_cast(meminfo.AllocationBase), - static_cast(pSymbol->Address) - reinterpret_cast(meminfo.AllocationBase), + reinterpret_cast(ptr), sName.c_str(), pSymbol->Name, + reinterpret_cast(meminfo.AllocationBase), + static_cast(pSymbol->Address) - reinterpret_cast(meminfo.AllocationBase), static_cast(disp)); return; } wsprintf( buf, "%" ADDRESS_ZEROS "Ix: %s!%" ADDRESS_ZEROS "Ix", - reinterpret_cast(ptr), sName.c_str(), - reinterpret_cast(meminfo.AllocationBase) ); + reinterpret_cast(ptr), sName.c_str(), + reinterpret_cast(meminfo.AllocationBase) ); } } diff --git a/src/archutils/Win32/CrashHandlerNetworking.cpp b/src/archutils/Win32/CrashHandlerNetworking.cpp index 15b5cdb947..fa84744ab0 100644 --- a/src/archutils/Win32/CrashHandlerNetworking.cpp +++ b/src/archutils/Win32/CrashHandlerNetworking.cpp @@ -7,6 +7,7 @@ #include "RageUtil.h" #include +#include #if defined(WINDOWS) #include @@ -396,7 +397,7 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType sockaddr_in addr; addr.sin_addr.s_addr = *(DWORD *)pHost->h_addr_list[0]; addr.sin_family = PF_INET; - addr.sin_port = htons( (uint16_t) iPort ); + addr.sin_port = htons( (std::uint16_t) iPort ); m_Mutex.Lock(); m_Socket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP ); diff --git a/src/archutils/Win32/GetFileInformation.cpp b/src/archutils/Win32/GetFileInformation.cpp index ce69c915ff..f37e6c9200 100644 --- a/src/archutils/Win32/GetFileInformation.cpp +++ b/src/archutils/Win32/GetFileInformation.cpp @@ -3,6 +3,8 @@ #include "RageUtil.h" #include "archutils/Win32/ErrorStrings.h" + +#include #include #include #include @@ -87,7 +89,7 @@ RString FindSystemFile( RString sFile ) /* Get the full path of the process running in iProcessID. On error, false is * returned and an error message is placed in sName. */ -bool GetProcessFileName( uint32_t iProcessID, RString &sName ) +bool GetProcessFileName( std::uint32_t iProcessID, RString &sName ) { /* This method works in everything except for NT4, and only uses * kernel32.lib functions. */ @@ -173,7 +175,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName ) /* * (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 @@ -183,7 +185,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName ) * 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 diff --git a/src/archutils/Win32/GetFileInformation.h b/src/archutils/Win32/GetFileInformation.h index 920da1eee2..6f318d8858 100644 --- a/src/archutils/Win32/GetFileInformation.h +++ b/src/archutils/Win32/GetFileInformation.h @@ -3,16 +3,18 @@ #ifndef GET_FILE_INFORMATION_H #define GET_FILE_INFORMATION_H +#include + bool GetFileVersion( RString fsFile, RString &sOut ); RString FindSystemFile( RString sFile ); -bool GetProcessFileName( uint32_t iProcessID, RString &sName ); +bool GetProcessFileName( std::uint32_t iProcessID, RString &sName ); #endif /* * (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 @@ -22,7 +24,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName ); * 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 diff --git a/src/archutils/Win32/GotoURL.cpp b/src/archutils/Win32/GotoURL.cpp index 1208d57824..5af5ab8651 100644 --- a/src/archutils/Win32/GotoURL.cpp +++ b/src/archutils/Win32/GotoURL.cpp @@ -1,5 +1,8 @@ #include "global.h" #include "GotoURL.h" + +#include + #include #include @@ -25,7 +28,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata ) bool GotoURL( RString sUrl ) { // First try ShellExecute() - intptr_t iRet = reinterpret_cast(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT )); + std::intptr_t iRet = reinterpret_cast(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT )); // If it failed, get the .htm regkey and lookup the program if( iRet > 32 ) diff --git a/src/archutils/Win32/WindowIcon.cpp b/src/archutils/Win32/WindowIcon.cpp index fcaff50846..8e37e46993 100644 --- a/src/archutils/Win32/WindowIcon.cpp +++ b/src/archutils/Win32/WindowIcon.cpp @@ -7,6 +7,8 @@ #include "RageSurface_Load.h" #include "archutils/Win32/ErrorStrings.h" +#include + #include HICON IconFromSurface( const RageSurface *pSrcImg ) @@ -45,8 +47,8 @@ HICON IconFromSurface( const RageSurface *pSrcImg ) pBitmap->biCompression = BI_RGB; pBitmap->biSizeImage = pImg->h * pImg->pitch; - uint8_t *pImage = ((uint8_t *) pBitmap) + iSize; - uint8_t *pMask = pImage + pImg->h * pImg->pitch; + std::uint8_t *pImage = ((std::uint8_t *) pBitmap) + iSize; + std::uint8_t *pMask = pImage + pImg->h * pImg->pitch; memcpy( pImage, pImg->pixels, pImg->h * pImg->pitch ); @@ -54,8 +56,8 @@ HICON IconFromSurface( const RageSurface *pSrcImg ) for( int y = 0; y < pImg->h; ++y ) { int bit = 0x80; - uint32_t *pRow = (uint32_t *) (pImage + y*pImg->pitch); - uint8_t *pMaskRow = pMask + y*iMaskPitch; + std::uint32_t *pRow = (std::uint32_t *) (pImage + y*pImg->pitch); + std::uint8_t *pMaskRow = pMask + y*iMaskPitch; for( int x = 0; x < pImg->w; ++x ) { if( !(pRow[x] & pImg->fmt.Mask[3]) ) @@ -107,7 +109,7 @@ HICON IconFromFile( const RString &sIconFile ) /* * (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 @@ -117,7 +119,7 @@ HICON IconFromFile( const RString &sIconFile ) * 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 diff --git a/src/archutils/Win32/arch_setup.h b/src/archutils/Win32/arch_setup.h index a0b3463071..f5095a9351 100644 --- a/src/archutils/Win32/arch_setup.h +++ b/src/archutils/Win32/arch_setup.h @@ -72,19 +72,6 @@ struct tm *my_gmtime_r( const time_t *timep, struct tm *result ); void my_usleep( unsigned long usec ); #define usleep my_usleep -// Missing stdint types: -typedef signed char int8_t; -typedef signed short int16_t; -typedef int int32_t; -typedef __int64 int64_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; - #undef min #undef max #define NOMINMAX // make sure Windows doesn't try to define this diff --git a/src/archutils/Win32/mapconv.cpp b/src/archutils/Win32/mapconv.cpp index 881992b9e0..3bb5347780 100644 --- a/src/archutils/Win32/mapconv.cpp +++ b/src/archutils/Win32/mapconv.cpp @@ -16,7 +16,7 @@ #define MAX_GROUPS (64) struct RVAEnt { - uintptr_t rva; + std::uintptr_t rva; char *line; }; @@ -25,10 +25,10 @@ std::vector rvabuf; char fnambuf[MAX_FNAMBUF]; char *fnamptr = fnambuf; -uintptr_t segbuf[MAX_SEGMENTS][2]; +std::uintptr_t segbuf[MAX_SEGMENTS][2]; int segcnt = 0; -uint16_t seggrp[MAX_SEGMENTS]; -uintptr_t grpstart[MAX_GROUPS]; +std::uint16_t seggrp[MAX_SEGMENTS]; +std::uintptr_t grpstart[MAX_GROUPS]; char line[8192]; long codeseg_flags = 0; @@ -94,7 +94,7 @@ void RemoveAnonymousNamespaces( char *p ) } -void parsename(uintptr_t rva, char *func_name) { +void parsename(std::uintptr_t rva, char *func_name) { RemoveAnonymousNamespaces( func_name ); fnamptr = strtack(fnamptr, func_name, fnambuf+MAX_FNAMBUF); @@ -140,9 +140,9 @@ int main(int argc, char **argv) { // printf("Reading in segment list.\n"); while (readline()) { - uint16_t grp; - uint32_t start; - uint32_t len; + std::uint16_t grp; + std::uint32_t start; + std::uint32_t len; if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %" SCNx32, &grp, &start, &len) != 3) break; @@ -152,8 +152,8 @@ int main(int argc, char **argv) { codeseg_flags |= 1 << grp; - segbuf[segcnt][0] = static_cast(start); - segbuf[segcnt][1] = static_cast(len); + segbuf[segcnt][0] = static_cast(start); + segbuf[segcnt][1] = static_cast(len); seggrp[segcnt] = grp; ++segcnt; } @@ -169,9 +169,9 @@ int main(int argc, char **argv) { // printf("Found public symbol list.\n"); while (readline()) { - uint16_t grp; - uint32_t start; - uintptr_t rva; + std::uint16_t grp; + std::uint32_t start; + std::uintptr_t rva; char symname[2048]; if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4) @@ -199,9 +199,9 @@ int main(int argc, char **argv) { readline(); while (readline()) { - uint16_t grp; - uint32_t start; - uintptr_t rva; + std::uint16_t grp; + std::uint32_t start; + std::uintptr_t rva; char symname[4096]; if (sscanf(line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4) @@ -225,15 +225,15 @@ int main(int argc, char **argv) { // printf("Processing RVA entries...\n"); for (std::size_t i = 0; i < rvabuf.size(); ++i) { - uint16_t grp; - uint32_t start; - uintptr_t rva; + std::uint16_t grp; + std::uint32_t start; + std::uintptr_t rva; char symname[4096]; if (sscanf(rvabuf[i].line, "%" SCNx16 ":%" SCNx32 " %s %" SCNxPTR, &grp, &start, symname, &rva) != 4) break; - grpstart[grp] = rva - static_cast(start); + grpstart[grp] = rva - static_cast(start); parsename(rva, symname); } @@ -253,8 +253,8 @@ int main(int argc, char **argv) { */ std::vector::iterator itRVA = rvabuf.begin(), itRVAEnd = rvabuf.end(); std::vector rvaout; - uintptr_t firstrva = (*itRVA++).rva; - uintptr_t lastrva = firstrva; + std::uintptr_t firstrva = (*itRVA++).rva; + std::uintptr_t lastrva = firstrva; for(; itRVA != itRVAEnd; ++itRVA) { std::ptrdiff_t rvadiff = (*itRVA).rva - lastrva; @@ -303,7 +303,7 @@ int main(int argc, char **argv) { fwrite(&firstrva, sizeof firstrva, 1, fo); fwrite(&rvaout[0], rvaout.size(), 1, fo); fwrite(fnambuf, fnamptr - fnambuf, 1, fo); - fwrite(segbuf, segcnt * 2 * sizeof(uintptr_t), 1, fo); + fwrite(segbuf, segcnt * 2 * sizeof(std::uintptr_t), 1, fo); // really all done diff --git a/src/config.in.hpp b/src/config.in.hpp index 0cfe96dbd0..5d176ee6be 100644 --- a/src/config.in.hpp +++ b/src/config.in.hpp @@ -9,12 +9,6 @@ /* Defined to 1 if is found. */ #cmakedefine HAVE_DIRENT_H 1 -/* Defined to 1 if is found. */ -#cmakedefine HAVE_INTTYPES_H 1 - -/* Defined to 1 if is found. */ -#cmakedefine HAVE_STDINT_H 1 - /* Defined to 1 if is found. */ #cmakedefine HAVE_ENDIAN_H 1 diff --git a/src/global.h b/src/global.h index 287dc3291b..8572d3df83 100644 --- a/src/global.h +++ b/src/global.h @@ -30,10 +30,6 @@ /* And vector: */ #include -#if defined(HAVE_STDINT_H) /* need to define int64_t if so */ -#include -#endif - /* Branch optimizations: */ #if defined(__GNUC__) #define likely(x) (__builtin_expect(!!(x), 1)) diff --git a/src/tests/test_audio_readers.cpp b/src/tests/test_audio_readers.cpp index 91c632606e..1fe7d6e44f 100644 --- a/src/tests/test_audio_readers.cpp +++ b/src/tests/test_audio_readers.cpp @@ -9,6 +9,7 @@ #include "test_misc.h" #include #include +#include #include #include #include @@ -45,7 +46,7 @@ void dump_bin( const char *fn, const char *buf, int size ) close( fd ); } -void dump( const char *fn, const int16_t *buf, int samples ) +void dump( const char *fn, const std::int16_t *buf, int samples ) { FILE *f = fopen( fn, "w+"); ASSERT( f ); @@ -71,7 +72,7 @@ void dump( const char *buf, int size ) printf("\n\n"); } -void dump( const int16_t *buf, int samples ) +void dump( const std::int16_t *buf, int samples ) { for( int i = 0; i < samples; ++i ) printf( "0x%04hx,", buf[i] ); @@ -85,11 +86,11 @@ void dump( const float *buf, int samples ) printf( "\n" ); } -bool compare( const float *m1, const int16_t *m2, int iSamples ) +bool compare( const float *m1, const std::int16_t *m2, int iSamples ) { for( int i = 0; i < iSamples; ++i ) { - int16_t iSample1 = std::lrint(m1[i]*32768); + std::int16_t iSample1 = std::lrint(m1[i]*32768); if( iSample1 != m2[i] ) return false; } @@ -98,7 +99,7 @@ bool compare( const float *m1, const int16_t *m2, int iSamples ) } -void compare_buffers( const int16_t *expect, const int16_t *got, int frames, +void compare_buffers( const std::int16_t *expect, const std::int16_t *got, int frames, int &NumInaccurateSamplesAtStart, int &NumInaccurateSamples ) { @@ -124,7 +125,7 @@ void compare_buffers( const int16_t *expect, const int16_t *got, int frames, } -bool compare_buffers( const int16_t *expect, const int16_t *got, int frames, int channels ) +bool compare_buffers( const std::int16_t *expect, const std::int16_t *got, int frames, int channels ) { /* * Compare each channel separately. Try to figure out if @@ -164,8 +165,8 @@ bool test_read( RageSoundReader *snd, float *expected_data, int frames ) int got = snd->Read( buf, frames ); ASSERT( got == frames ); - //compare_buffers( (const int16_t *) expected_data, - // (const int16_t *) buf, + //compare_buffers( (const std::int16_t *) expected_data, + // (const std::int16_t *) buf, // bytes/2, // 2 ); @@ -257,7 +258,7 @@ const int TestDataSize = 2; /* Find "haystack" in "needle". Start looking at "expect" and move outward; find * the closest. */ void *xmemsearch( const float *haystack, std::size_t iHaystackSamples, - const int16_t *needle, std::size_t iNeedleSamples, + const std::int16_t *needle, std::size_t iNeedleSamples, int expect ) { if( !iNeedleSamples ) @@ -300,10 +301,10 @@ struct TestFile int SilentFrames; /* The first two frames (four samples): */ - int16_t initial[TestDataSize*2]; + std::int16_t initial[TestDataSize*2]; /* Frames of data half a second in: */ - int16_t later[TestDataSize*2]; + std::int16_t later[TestDataSize*2]; }; const int channels = 2; @@ -377,7 +378,7 @@ bool RunTests( RageSoundReader *snd, const TestFile &tf ) dump( LaterData, 16 ); /* See if we can find the half second data. */ - float *p = (float *) xmemsearch( sdata, one_second_bytes, tf.later, sizeof(tf.later), LaterOffsetSamples*sizeof(int16_t) ); + float *p = (float *) xmemsearch( sdata, one_second_bytes, tf.later, sizeof(tf.later), LaterOffsetSamples*sizeof(std::int16_t) ); if( p ) { int SamplesOff = p-sdata; @@ -386,7 +387,7 @@ bool RunTests( RageSoundReader *snd, const TestFile &tf ) FramesOff, LaterOffsetFrames, FramesOff-LaterOffsetFrames ); } // else -// dump( "foo", sdata, one_second/sizeof(int16_t) ); +// dump( "foo", sdata, one_second/sizeof(std::int16_t) ); } } diff --git a/src/tests/test_threads.cpp b/src/tests/test_threads.cpp index 9154654da8..e47db54fa7 100644 --- a/src/tests/test_threads.cpp +++ b/src/tests/test_threads.cpp @@ -6,11 +6,12 @@ #include "archutils/Unix/BacktraceNames.h" #include "test_misc.h" +#include #include #include "archutils/Common/PthreadHelpers.h" /* These are volatile, so writes to them aren't optimized. */ -volatile uint64_t g_ThreadId = (uint64_t) -1; +volatile std::uint64_t g_ThreadId = (std::uint64_t) -1; volatile int g_Counter = 0; volatile bool g_Finish = false; @@ -30,11 +31,11 @@ int TestSuspendThread( void *p ) return 0; } -void test_suspend_threadid( uint64_t ThreadId ) +void test_suspend_threadid( std::uint64_t ThreadId ) { /* Wait for g_Counter to increment a bit. */ usleep( 100000 ); - + /* Stop the thread. */ SuspendThread( ThreadId ); @@ -73,21 +74,21 @@ void test_suspend_threadid( uint64_t ThreadId ) void test_suspend_secondary_thread() { ASSERT( !g_Finish ); - ASSERT( g_ThreadId == (uint64_t) -1 ); + ASSERT( g_ThreadId == (std::uint64_t) -1 ); RageThread testing; testing.SetName( "TestSuspend" ); testing.Create( TestSuspendThread, NULL ); - while( g_ThreadId == (uint64_t) -1 ) + while( g_ThreadId == (std::uint64_t) -1 ) ; test_suspend_threadid( g_ThreadId ); - + g_Finish = true; testing.Wait(); g_Finish = false; - g_ThreadId = (uint64_t) -1; + g_ThreadId = (std::uint64_t) -1; } int TestSuspendMainThread( void *p ) @@ -96,7 +97,7 @@ int TestSuspendMainThread( void *p ) printf("Test thread started\n"); - ASSERT( g_ThreadId != (uint64_t) -1 ); + ASSERT( g_ThreadId != (std::uint64_t) -1 ); test_suspend_threadid( g_ThreadId ); g_Finish = true; @@ -107,7 +108,7 @@ int TestSuspendMainThread( void *p ) void test_suspend_main_thread() { ASSERT( !g_Finish ); - ASSERT( g_ThreadId == (uint64_t) -1 ); + ASSERT( g_ThreadId == (std::uint64_t) -1 ); g_ThreadId = GetCurrentThreadId(); @@ -119,7 +120,7 @@ void test_suspend_main_thread() testing.Wait(); g_Finish = false; - g_ThreadId = (uint64_t) -1; + g_ThreadId = (std::uint64_t) -1; } /* Run a second function, so we have two symbols to search for. */ @@ -143,7 +144,7 @@ bool test_thread_backtrace( int ThreadId, const void *expect1, const void *expec BacktraceContext ctx; int ret = GetThreadBacktraceContext( ThreadId, &ctx ); ASSERT( ret ); - + const void *BacktracePointers[1024]; GetBacktrace( BacktracePointers, 1024, &ctx ); @@ -177,9 +178,9 @@ void test_backtracing_secondary_thread() testing.SetName( "TestBacktrace" ); testing.Create( TestBacktraceThread, NULL ); - while( g_ThreadId == (uint64_t) -1 ) + while( g_ThreadId == (std::uint64_t) -1 ) ; - + if( !test_thread_backtrace( g_ThreadId, (void *) TestBacktraceThread, (void *) TestBacktraceThreadLoop ) ) { printf( "test_backtracing_secondary_thread failed\n" ); @@ -189,16 +190,16 @@ void test_backtracing_secondary_thread() g_Finish = true; testing.Wait(); g_Finish = false; - g_ThreadId = (uint64_t) -1; + g_ThreadId = (std::uint64_t) -1; } int TestBacktraceMainThread( void *p ) { printf("Test thread started\n"); - while( g_ThreadId == (uint64_t) -1 ) + while( g_ThreadId == (std::uint64_t) -1 ) ; - + if( !test_thread_backtrace( g_ThreadId, (void *) TestBacktraceThread, (void *) TestBacktraceThreadLoop ) ) { printf( "test_backtracing_main_thread failed\n" ); @@ -213,7 +214,7 @@ int TestBacktraceMainThread( void *p ) void test_backtracing_main_thread() { ASSERT( !g_Finish ); - ASSERT( g_ThreadId == (uint64_t) -1 ); + ASSERT( g_ThreadId == (std::uint64_t) -1 ); RageThread testing; testing.SetName( "TestBacktrace" ); @@ -223,7 +224,7 @@ void test_backtracing_main_thread() testing.Wait(); g_Finish = false; - g_ThreadId = (uint64_t) -1; + g_ThreadId = (std::uint64_t) -1; } static RageMutex g_Mutex("test"); @@ -247,13 +248,13 @@ int TestLocksThread( void *p ) void test_locks() { ASSERT( !g_Finish ); - ASSERT( g_ThreadId == (uint64_t) -1 ); + ASSERT( g_ThreadId == (std::uint64_t) -1 ); RageThread testing; testing.SetName( "TestLocks" ); testing.Create( TestLocksThread, NULL ); - while( g_ThreadId == (uint64_t) -1 ) + while( g_ThreadId == (std::uint64_t) -1 ) ; /* Stop the thread. */ @@ -276,7 +277,7 @@ void test_locks() g_Finish = true; testing.Wait(); g_Finish = false; - g_ThreadId = (uint64_t) -1; + g_ThreadId = (std::uint64_t) -1; } void go() @@ -284,7 +285,7 @@ void go() /* Test the main thread suspending a secondary thread, and vice versa. */ test_suspend_secondary_thread(); test_suspend_main_thread(); - + /* Test the main thread backtracing a secondary thread, and vice versa. */ test_backtracing_secondary_thread(); test_backtracing_main_thread(); diff --git a/src/tests/test_vector.cpp b/src/tests/test_vector.cpp index 9a6c66025a..3b3573dd4e 100644 --- a/src/tests/test_vector.cpp +++ b/src/tests/test_vector.cpp @@ -1,9 +1,10 @@ #define _XOPEN_SOURCE 600 -#include -#include #include #include #include +#include +#include +#include #include #include @@ -36,7 +37,7 @@ static void ScalarWrite( float *pDestBuf, const float *pSrcBuf, std::size_t iSiz } #if 0 -static void ScalarRead( int16_t *pDestBuf, const int32_t *pSrcBuf, unsigned iSize ) +static void ScalarRead( std::int16_t *pDestBuf, const std::int32_t *pSrcBuf, unsigned iSize ) { for( unsigned iPos = 0; iPos < iSize; ++iPos ) pDestBuf[iPos] = std::max( -32768, std::min(pSrcBuf[iPos]/256, 32767) ); @@ -197,7 +198,7 @@ static bool CheckMisalignedBothWrite() return ret; } -static bool cmp( const int16_t *p1, const int16_t *p2, std::size_t size ) +static bool cmp( const std::int16_t *p1, const std::int16_t *p2, std::size_t size ) { return !memcmp( p1, p2, size * 2 ); } @@ -216,7 +217,7 @@ template static bool CheckAlignedRead() { const std::size_t size = 1024; - int32_t *pSrcBuf = NEW( int32_t, size ); + std::int32_t *pSrcBuf = NEW( std::int32_t, size ); T *pDestBuf = NEW( T, size ); T *pRefBuf = NEW( T, size ); bool ret = true; @@ -245,7 +246,7 @@ template static bool CheckMisalignedRead() { const std::size_t size = 1024; - int32_t *pSrcBuf = NEW( int32_t, size ); + std::int32_t *pSrcBuf = NEW( std::int32_t, size ); T *pDestBuf = NEW( T, size ); T *pRefBuf = NEW( T, size ); bool ret = true; @@ -303,7 +304,7 @@ int main() return 1; } #if 0 - if( !CheckAlignedRead() ) + if( !CheckAlignedRead() ) { fputs( "Failed aligned read.\n", stderr ); return 1; @@ -313,7 +314,7 @@ int main() fputs( "Failed aligned float read.\n", stderr ); return 1; } - if( !CheckMisalignedRead() ) + if( !CheckMisalignedRead() ) { fputs( "Failed misaligned read.\n", stderr ); return 1;