all repos — mgba @ 0065b62633ab133442538a96155fbead02eed130

mGBA Game Boy Advance Emulator

include/mgba/core/sync.h (view raw)

 1/* Copyright (c) 2013-2016 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef M_CORE_SYNC_H
 7#define M_CORE_SYNC_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba-util/threading.h>
14
15struct mCoreSync {
16	int videoFramePending;
17	bool videoFrameWait;
18	Mutex videoFrameMutex;
19	Condition videoFrameAvailableCond;
20	Condition videoFrameRequiredCond;
21
22	bool audioWait;
23	Condition audioRequiredCond;
24	Mutex audioBufferMutex;
25
26	float fpsTarget;
27};
28
29void mCoreSyncPostFrame(struct mCoreSync* sync);
30void mCoreSyncForceFrame(struct mCoreSync* sync);
31bool mCoreSyncWaitFrameStart(struct mCoreSync* sync);
32void mCoreSyncWaitFrameEnd(struct mCoreSync* sync);
33void mCoreSyncSetVideoSync(struct mCoreSync* sync, bool wait);
34
35struct blip_t;
36bool mCoreSyncProduceAudio(struct mCoreSync* sync, const struct blip_t*, size_t samples);
37void mCoreSyncLockAudio(struct mCoreSync* sync);
38void mCoreSyncUnlockAudio(struct mCoreSync* sync);
39void mCoreSyncConsumeAudio(struct mCoreSync* sync);
40
41CXX_GUARD_END
42
43#endif