Game Kit: rewrite PushGameSound and WindowScreen headers

Part of #1576

Change-Id: Iafdc88bcf13e9c07fa148cb7980b54f5ee98be50
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2086
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Raheem Idowu
2020-01-11 02:26:06 +00:00
committed by waddlesplash
parent ef046e3b14
commit e8faedae57
2 changed files with 143 additions and 169 deletions
+65 -72
View File
@@ -1,9 +1,6 @@
/* /*
* Copyright 2001-2002, Haiku Inc. All Rights Reserved. * Copyright 2020, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
* Author:
* Christopher ML Zumwalt May ([email protected])
*/ */
#ifndef _PUSHGAMESOUND_H #ifndef _PUSHGAMESOUND_H
#define _PUSHGAMESOUND_H #define _PUSHGAMESOUND_H
@@ -11,96 +8,92 @@
#include <StreamingGameSound.h> #include <StreamingGameSound.h>
class BList; class BList;
class BPushGameSound : public BStreamingGameSound { class BPushGameSound : public BStreamingGameSound {
public: public:
BPushGameSound(size_t inBufferFrameCount, BPushGameSound(size_t inBufferFrameCount,
const gs_audio_format* format, const gs_audio_format* format,
size_t inBufferCount = 2, size_t inBufferCount = 2,
BGameSoundDevice* device = NULL); BGameSoundDevice* device = NULL);
virtual ~BPushGameSound();
virtual ~BPushGameSound(); enum lock_status {
lock_failed = -1,
lock_ok = 0,
lock_ok_frames_dropped
};
enum lock_status { virtual lock_status LockNextPage(void** _pagePtr, size_t* _pageSize);
lock_failed = -1, // not yet time to do more virtual status_t UnlockPage(void* pagePtr);
lock_ok = 0, // do more
lock_ok_frames_dropped // you may have missed some buffers
};
virtual lock_status LockNextPage(void** _pagePtr, virtual lock_status LockForCyclic(void** _basePtr, size_t* _size);
size_t* _pageSize); virtual status_t UnlockCyclic();
virtual status_t UnlockPage(void* pagePtr); virtual size_t CurrentPosition();
virtual lock_status LockForCyclic(void** _basePtr, size_t* _size); virtual BGameSound* Clone() const;
virtual status_t UnlockCyclic();
virtual size_t CurrentPosition();
virtual BGameSound* Clone() const; virtual status_t Perform(int32 selector, void* data);
virtual status_t Perform(int32 selector, void* data);
protected: protected:
BPushGameSound(BGameSoundDevice* device); BPushGameSound(BGameSoundDevice* device);
virtual status_t SetParameters(size_t bufferFrameCount, virtual status_t SetParameters(size_t bufferFrameCount,
const gs_audio_format* format, const gs_audio_format* format, size_t bufferCount);
size_t bufferCount);
virtual status_t SetStreamHook(void (*hook)(void* inCookie, virtual status_t SetStreamHook(void (*hook)(void* inCookie,
void* buffer, size_t byteCount, void* buffer, size_t byteCount,
BStreamingGameSound* me), BStreamingGameSound* me),
void* cookie); void* cookie);
virtual void FillBuffer(void* buffer, size_t byteCount); virtual void FillBuffer(void* buffer, size_t byteCount);
private: private:
BPushGameSound(); BPushGameSound();
BPushGameSound(const BPushGameSound& other); BPushGameSound(const BPushGameSound& other);
BPushGameSound& operator=(const BPushGameSound& other); BPushGameSound& operator=(const BPushGameSound& other);
// not implemented
bool BytesReady(size_t* bytes); bool BytesReady(size_t* bytes);
virtual status_t _Reserved_BPushGameSound_0(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_0(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_1(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_1(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_2(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_2(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_3(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_3(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_4(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_4(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_5(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_5(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_6(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_6(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_7(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_7(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_8(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_8(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_9(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_9(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_10(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_10(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_11(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_11(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_12(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_12(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_13(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_13(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_14(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_14(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_15(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_15(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_16(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_16(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_17(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_17(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_18(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_18(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_19(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_19(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_20(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_20(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_21(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_21(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_22(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_22(int32 arg, ...);
virtual status_t _Reserved_BPushGameSound_23(int32 arg, ...); virtual status_t _Reserved_BPushGameSound_23(int32 arg, ...);
private: private:
sem_id fLock; sem_id fLock;
BList* fPageLocked; BList* fPageLocked;
size_t fLockPos;
size_t fLockPos; size_t fPlayPos;
size_t fPlayPos; char* fBuffer;
char* fBuffer; size_t fPageSize;
size_t fPageSize; int32 fPageCount;
int32 fPageCount; size_t fBufferSize;
size_t fBufferSize;
uint32 _reserved[12]; uint32 _reserved[12];
}; };
#endif
#endif // _PUSH_GAME_SOUND_H
+76 -95
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Copyright 2020, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _WINDOW_SCREEN_H #ifndef _WINDOW_SCREEN_H
#define _WINDOW_SCREEN_H #define _WINDOW_SCREEN_H
@@ -15,8 +15,6 @@
void set_mouse_position(int32 x, int32 y); void set_mouse_position(int32 x, int32 y);
// Controls the mouse cursor position on screen
enum { enum {
B_ENABLE_VIEW_DRAWING = 0x0001, B_ENABLE_VIEW_DRAWING = 0x0001,
@@ -24,109 +22,92 @@ enum {
}; };
class BWindowScreen : public BWindow { class BWindowScreen : public BWindow {
public: public:
BWindowScreen(const char* title, uint32 space, BWindowScreen(const char* title, uint32 space,
status_t* _error, bool debugMode = false); status_t* _error, bool debugMode = false);
BWindowScreen(const char* title, uint32 space, BWindowScreen(const char* title, uint32 space,
uint32 attributes, status_t* _error); uint32 attributes, status_t* _error);
virtual ~BWindowScreen(); virtual ~BWindowScreen();
virtual void Quit(); virtual void Quit();
virtual void ScreenConnected(bool active); virtual void ScreenConnected(bool active);
void Disconnect(); void Disconnect();
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);
virtual void WorkspaceActivated(int32 workspace, bool active); virtual void WorkspaceActivated(int32 workspace, bool active);
virtual void ScreenChanged(BRect screenSize, color_space depth); virtual void ScreenChanged(BRect screenSize, color_space depth);
virtual void Hide(); virtual void Hide();
virtual void Show(); virtual void Show();
void SetColorList(rgb_color* list, int32 firstIndex = 0, void SetColorList(rgb_color* list, int32 firstIndex = 0,
int32 lastIndex = 255); int32 lastIndex = 255);
status_t SetSpace(uint32 space); status_t SetSpace(uint32 space);
bool CanControlFrameBuffer(); bool CanControlFrameBuffer();
status_t SetFrameBuffer(int32 width, int32 height); status_t SetFrameBuffer(int32 width, int32 height);
status_t MoveDisplayArea(int32 x, int32 y); status_t MoveDisplayArea(int32 x, int32 y);
rgb_color* ColorList();
frame_buffer_info* FrameBufferInfo();
graphics_card_hook CardHookAt(int32 index);
graphics_card_info* CardInfo();
void RegisterThread(thread_id thread);
virtual void SuspensionHook(bool active);
void Suspend(char* label);
rgb_color* ColorList(); private:
frame_buffer_info* FrameBufferInfo(); virtual status_t Perform(perform_code d, void* arg);
graphics_card_hook CardHookAt(int32 index); virtual void _ReservedWindowScreen1();
graphics_card_info* CardInfo(); virtual void _ReservedWindowScreen2();
virtual void _ReservedWindowScreen3();
virtual void _ReservedWindowScreen4();
status_t _InitData(uint32 space, uint32 attributes);
void _DisposeData();
status_t _LockScreen(bool lock);
status_t _Activate();
status_t _Deactivate();
status_t _SetupAccelerantHooks();
void _ResetAccelerantHooks();
status_t _GetCardInfo();
void _Suspend();
void _Resume();
status_t _GetModeFromSpace(uint32 space, display_mode* mode);
status_t _InitClone();
status_t _AssertDisplayMode(display_mode* mode);
void RegisterThread(thread_id thread); private:
virtual void SuspensionHook(bool active); uint16 _reserved0;
void Suspend(char* label); bool _reserved1;
bool fWorkState;
bool fWindowState;
bool fActivateState;
int32 fLockState;
int32 fWorkspaceIndex;
private: display_mode* fOriginalDisplayMode;
virtual status_t Perform(perform_code d, void* arg); display_mode* fDisplayMode;
sem_id fDebugSem;
image_id fAddonImage;
uint32 fAttributes;
#if 0 rgb_color fPalette[256];
void* IOBase();
// deprecated API, always returns NULL
#endif
virtual void _ReservedWindowScreen1(); graphics_card_info fCardInfo;
virtual void _ReservedWindowScreen2(); frame_buffer_info fFrameBufferInfo;
virtual void _ReservedWindowScreen3();
virtual void _ReservedWindowScreen4();
// not implemented: char* fDebugFrameBuffer;
BWindowScreen(); bool fDebugState;
BWindowScreen(BWindowScreen& other); bool fDebugFirst;
BWindowScreen &operator=(BWindowScreen& other); int32 fDebugWorkspace;
int32 fDebugThreadCount;
thread_id* fDebugThreads;
uint32 fModeCount;
display_mode* fModeList;
status_t _InitData(uint32 space, uint32 attributes); GetAccelerantHook fGetAccelerantHook;
void _DisposeData(); wait_engine_idle fWaitEngineIdle;
status_t _LockScreen(bool lock); uint32 _reserved[163];
status_t _Activate();
status_t _Deactivate();
status_t _SetupAccelerantHooks();
void _ResetAccelerantHooks();
status_t _GetCardInfo();
void _Suspend();
void _Resume();
status_t _GetModeFromSpace(uint32 space, display_mode* mode);
status_t _InitClone();
status_t _AssertDisplayMode(display_mode* mode);
uint16 _reserved0;
bool _reserved1;
bool fWorkState;
bool fWindowState;
bool fActivateState;
int32 fLockState;
int32 fWorkspaceIndex;
display_mode* fOriginalDisplayMode;
display_mode* fDisplayMode;
sem_id fDebugSem;
image_id fAddonImage;
uint32 fAttributes;
rgb_color fPalette[256];
graphics_card_info fCardInfo;
frame_buffer_info fFrameBufferInfo;
char* fDebugFrameBuffer;
bool fDebugState;
bool fDebugFirst;
int32 fDebugWorkspace;
int32 fDebugThreadCount;
thread_id* fDebugThreads;
uint32 fModeCount;
display_mode* fModeList;
GetAccelerantHook fGetAccelerantHook;
wait_engine_idle fWaitEngineIdle;
uint32 _reserved[163];
}; };
#endif // _WINDOW_SCREEN_H #endif