-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make AudioDriverOpenSL
's input callback thread-safe
#92969
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,15 +56,26 @@ class AudioDriver { | |
SafeNumeric<uint64_t> prof_time; | ||
#endif | ||
|
||
public: | ||
struct SizePosition { | ||
unsigned int size; | ||
unsigned int position; | ||
|
||
SizePosition(unsigned int p_size = 0, unsigned int p_position = 0) noexcept : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
size(p_size), position(p_position) {} | ||
}; | ||
Comment on lines
+60
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a whole class to fit it in one |
||
|
||
protected: | ||
Vector<int32_t> input_buffer; | ||
unsigned int input_position = 0; | ||
unsigned int input_size = 0; | ||
LocalVector<int32_t> input_buffer; | ||
std::atomic<SizePosition> input_read; | ||
SizePosition input_write; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
void audio_server_process(int p_frames, int32_t *p_buffer, bool p_update_mix_time = true); | ||
void update_mix_time(int p_frames); | ||
|
||
void input_buffer_init(int driver_buffer_frames); | ||
void input_buffer_write(int32_t sample); | ||
void input_buffer_end_write(); | ||
|
||
int _get_configured_mix_rate(); | ||
|
||
|
@@ -111,6 +122,9 @@ class AudioDriver { | |
virtual Error input_start() { return FAILED; } | ||
virtual Error input_stop() { return FAILED; } | ||
|
||
virtual void input_lock() { lock(); } | ||
virtual void input_unlock() { unlock(); } | ||
|
||
virtual PackedStringArray get_input_device_list(); | ||
virtual String get_input_device() { return "Default"; } | ||
virtual void set_input_device(const String &p_name) {} | ||
|
@@ -120,9 +134,8 @@ class AudioDriver { | |
SpeakerMode get_speaker_mode_by_total_channels(int p_channels) const; | ||
int get_total_channels_by_speaker_mode(SpeakerMode) const; | ||
|
||
Vector<int32_t> get_input_buffer() { return input_buffer; } | ||
unsigned int get_input_position() { return input_position; } | ||
unsigned int get_input_size() { return input_size; } | ||
const LocalVector<int32_t> &get_input_buffer() { return input_buffer; } | ||
SizePosition get_input_size_position() { return input_read; } | ||
|
||
#ifdef DEBUG_ENABLED | ||
uint64_t get_profiling_time() const { return prof_time.get(); } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (active)
is not necessary and could create issues(?), no otherAudioDriver
checks for it