prep for toxav multithreading

This commit is contained in:
2024-10-05 11:17:44 +02:00
parent 09c8bbfcc6
commit 3475f0751f
4 changed files with 257 additions and 109 deletions

View File

@ -55,6 +55,16 @@ namespace /*toxav*/ Events {
int32_t vstride;
};
// event fired on a/av thread every iterate
struct IterateAudio {
//float time_delta;
};
// event fired on v/av thread every iterate
struct IterateVideo {
//float time_delta;
};
} // Event
enum class ToxAV_Event : uint32_t {
@ -65,6 +75,9 @@ enum class ToxAV_Event : uint32_t {
friend_audio_frame,
friend_video_frame,
iterate_audio,
iterate_video,
MAX
};
@ -79,11 +92,15 @@ struct ToxAVEventI {
virtual bool onEvent(const Events::FriendVideoBitrate&) { return false; }
virtual bool onEvent(const Events::FriendAudioFrame&) { return false; }
virtual bool onEvent(const Events::FriendVideoFrame&) { return false; }
virtual bool onEvent(const Events::IterateAudio&) { return false; }
virtual bool onEvent(const Events::IterateVideo&) { return false; }
};
using ToxAVEventProviderI = EventProviderI<ToxAVEventI>;
// TODO: seperate out implementation from interface
struct ToxAVI : public ToxAVEventProviderI {
// tox and toxav internally are mutex protected
// BUT only if "experimental_thread_safety" is enabled
Tox* _tox = nullptr;
ToxAV* _tox_av = nullptr;