summaryrefslogtreecommitdiff
path: root/platform/osx/audio_driver_osx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/osx/audio_driver_osx.cpp')
-rw-r--r--platform/osx/audio_driver_osx.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index 8f28e8ff63..638ac7e504 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -101,7 +101,16 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
AudioBuffer *abuf;
AudioDriverOSX* ad = (AudioDriverOSX*)inRefCon;
- if (!ad->active) {
+ bool mix = true;
+
+ if (!ad->active)
+ mix = false;
+ else if (ad->mutex) {
+ mix = ad->mutex->try_lock() == OK;
+ };
+
+
+ if (!mix) {
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {
abuf = &ioData->mBuffers[i];
zeromem(abuf->mData, abuf->mDataByteSize);
@@ -120,9 +129,9 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
while (frames_left) {
int frames = MIN(frames_left, ad->buffer_frames);
- ad->lock();
+ //ad->lock();
ad->audio_server_process(frames, ad->samples_in);
- ad->unlock();
+ //ad->unlock();
for(int i = 0; i < frames * ad->channels; i++) {
@@ -134,6 +143,9 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
};
};
+ if (ad->mutex)
+ ad->mutex->unlock();
+
return 0;
};
@@ -149,12 +161,27 @@ AudioDriverSW::OutputFormat AudioDriverOSX::get_output_format() const {
return OUTPUT_STEREO;
};
-void AudioDriverOSX::lock() {};
-void AudioDriverOSX::unlock() {};
+void AudioDriverOSX::lock() {
+ if (active && mutex)
+ mutex->lock();
+};
+void AudioDriverOSX::unlock() {
+ if (active && mutex)
+ mutex->unlock();
+};
void AudioDriverOSX::finish() {
memdelete_arr(samples_in);
};
+AudioDriverOSX::AudioDriverOSX() {
+
+ mutex=Mutex::create();//NULL;
+};
+
+AudioDriverOSX::~AudioDriverOSX() {
+
+};
+
#endif