summaryrefslogtreecommitdiff
path: root/gr-audio-osx/src/audio_osx_source.cc
diff options
context:
space:
mode:
authorMichael Dickens2010-04-19 09:29:43 -0600
committerMichael Dickens2010-04-19 09:29:43 -0600
commit3e8c1915a289088aa801427defc18a165ba43cd1 (patch)
treec78516d995f1fe3efdc001b2c30d172272e6a962 /gr-audio-osx/src/audio_osx_source.cc
parent7389f7a46fbad90dc1ae2c8232f770b03c27a38f (diff)
downloadgnuradio-3e8c1915a289088aa801427defc18a165ba43cd1.tar.gz
gnuradio-3e8c1915a289088aa801427defc18a165ba43cd1.tar.bz2
gnuradio-3e8c1915a289088aa801427defc18a165ba43cd1.zip
Initial changes to remove mld_thread and instead use gruel:: namespace classes
Diffstat (limited to 'gr-audio-osx/src/audio_osx_source.cc')
-rw-r--r--gr-audio-osx/src/audio_osx_source.cc49
1 files changed, 19 insertions, 30 deletions
diff --git a/gr-audio-osx/src/audio_osx_source.cc b/gr-audio-osx/src/audio_osx_source.cc
index 61838745b..538cfd8f6 100644
--- a/gr-audio-osx/src/audio_osx_source.cc
+++ b/gr-audio-osx/src/audio_osx_source.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio.
*
@@ -24,8 +24,6 @@
#include "config.h"
#endif
-#define _USE_OMNI_THREADS_
-
#include <audio_osx_source.h>
#include <gr_io_signature.h>
#include <stdexcept>
@@ -446,11 +444,15 @@ audio_osx_source::audio_osx_source (int sample_rate,
// create the stuff to regulate I/O
- d_cond_data = new mld_condition ();
+ d_cond_data = new gruel::condition_variable ();
if (d_cond_data == NULL)
- CheckErrorAndThrow (errno, "new mld_condition (data)",
+ CheckErrorAndThrow (errno, "new condition (data)",
+ "audio_osx_source::audio_osx_source");
+
+ d_internal = new gruel::mutex ();
+ if (d_internal == NULL)
+ CheckErrorAndThrow (errno, "new mutex (internal)",
"audio_osx_source::audio_osx_source");
- d_internal = d_cond_data->mutex ();
// initialize the AU for input
@@ -600,6 +602,9 @@ audio_osx_source::~audio_osx_source ()
// close and delete the control stuff
delete d_cond_data;
+ d_cond_data = 0;
+ delete d_internal;
+ d_internal = 0;
}
audio_osx_source_sptr
@@ -654,7 +659,7 @@ audio_osx_source::work
gr_vector_void_star &output_items)
{
// acquire control to do processing here only
- d_internal->lock ();
+ gruel::scoped_lock l (*d_internal);
#if _OSX_AU_DEBUG_
std::cerr << "work1: SC = " << d_queueSampleCount
@@ -677,14 +682,12 @@ audio_osx_source::work
while (d_queueSampleCount == 0) {
// release control so-as to allow data to be retrieved;
// block until there is data to return
- d_cond_data->wait ();
- // the condition's signal() was called; acquire control to
+ d_cond_data->wait (l);
+ // the condition's 'notify' was called; acquire control to
// keep thread safe
}
} else {
// no data & not blocking; return nothing
- // release control so-as to allow data to be retrieved
- d_internal->unlock ();
return (0);
}
}
@@ -718,15 +721,8 @@ audio_osx_source::work
#if _OSX_AU_DEBUG_
std::cerr << "work2: SC = " << d_queueSampleCount
- << ", act#OI = " << actual_noutput_items << std::endl;
-#endif
-
- // release control to allow for other processing parts to run
-
- d_internal->unlock ();
-
-#if _OSX_AU_DEBUG_
- std::cerr << "work3: Returning." << std::endl;
+ << ", act#OI = " << actual_noutput_items << std::endl
+ << "Returning." << std::endl;
#endif
return (actual_noutput_items);
@@ -782,7 +778,7 @@ audio_osx_source::AUInputCallback (void* inRefCon,
OSStatus err = noErr;
audio_osx_source* This = static_cast<audio_osx_source*>(inRefCon);
- This->d_internal->lock ();
+ gruel::scoped_lock l (*This->d_internal);
#if _OSX_AU_DEBUG_
std::cerr << "cb0: in#F = " << inNumberFrames
@@ -911,17 +907,10 @@ audio_osx_source::AUInputCallback (void* inRefCon,
#endif
// signal that data is available, if appropraite
- This->d_cond_data->signal ();
-
-#if _OSX_AU_DEBUG_
- std::cerr << "cb5: releasing internal mutex." << std::endl;
-#endif
-
-// release control to allow for other processing parts to run
- This->d_internal->unlock ();
+ This->d_cond_data->notify_one ();
#if _OSX_AU_DEBUG_
- std::cerr << "cb6: returning." << std::endl;
+ std::cerr << "cb5: returning." << std::endl;
#endif
return (err);