commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4164 - gnuradio/branches/developers/brickle/jack/gr-a


From: brickle
Subject: [Commit-gnuradio] r4164 - gnuradio/branches/developers/brickle/jack/gr-audio-jack/src
Date: Wed, 20 Dec 2006 13:17:43 -0700 (MST)

Author: brickle
Date: 2006-12-20 13:17:43 -0700 (Wed, 20 Dec 2006)
New Revision: 4164

Modified:
   gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.cc
   gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.h
   
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.cc
   
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.h
Log:
Corrected some member names, chipping away at source work function.


Modified: 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.cc
===================================================================
--- 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.cc   
    2006-12-20 19:52:04 UTC (rev 4163)
+++ 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.cc   
    2006-12-20 20:17:43 UTC (rev 4164)
@@ -101,21 +101,21 @@
 //------------------------------------------------------------------------
 
 int
-audio_jack_mgr::audio_jack_mgr_sample_rate()
+audio_jack_mgr::sample_rate()
 {
   return d_sample_rate;
 }
 
 int
-audio_jack_mgr::audio_jack_mgr_buffer_size()
+audio_jack_mgr::buffer_size()
 {
   return d_buffer_size;
 }
 
 int
-audio_jack_mgr::audio_jack_mgr_register_source(const std::string name,
-                                              jack_ringbuffer_t *rb_ptr,
-                                              omni_semaphore *sem_ptr)
+audio_jack_mgr::register_source(const std::string name,
+                               jack_ringbuffer_t *rb_ptr,
+                               omni_semaphore *sem_ptr)
 {
   int i;
 
@@ -141,7 +141,7 @@
 }
 
 bool
-audio_jack_mgr::audio_jack_mgr_unregister_source(int id)
+audio_jack_mgr::unregister_source(int id)
 {
   if (id < 0 || id >= JACK_MAX_PORTS) {
     std::cerr << "audio_jack_mgr: trying to unregister source id out of 
range\n";
@@ -162,9 +162,9 @@
 }
 
 int
-audio_jack_mgr::audio_jack_mgr_register_sink(const std::string name,
-                                            jack_ringbuffer_t *rb_ptr,
-                                            omni_semaphore *sem_ptr)
+audio_jack_mgr::register_sink(const std::string name,
+                             jack_ringbuffer_t *rb_ptr,
+                             omni_semaphore *sem_ptr)
 {
   int i;
 
@@ -191,7 +191,7 @@
 }
 
 bool
-audio_jack_mgr::audio_jack_mgr_unregister_sink(int id)
+audio_jack_mgr::unregister_sink(int id)
 {
   if (id < 0 || id >= JACK_MAX_PORTS) {
     std::cerr << "audio_jack_mgr: trying to unregister sink id out of range\n";

Modified: 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.h
===================================================================
--- 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.h    
    2006-12-20 19:52:04 UTC (rev 4163)
+++ 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_mgr.h    
    2006-12-20 20:17:43 UTC (rev 4164)
@@ -64,24 +64,24 @@
   ~audio_jack_mgr ();
 
   int
-  audio_jack_mgr_sample_rate();
+  sample_rate();
 
   int
-  audio_jack_mgr_buffer_size();
+  buffer_size();
 
   int
-  audio_jack_mgr_register_source(const std::string name,
-                                jack_ringbuffer_t *rb_ptr,
-                                omni_semaphore *sem_ptr);
+  register_source(const std::string name,
+                 jack_ringbuffer_t *rb_ptr,
+                 omni_semaphore *sem_ptr);
   bool
-  audio_jack_mgr_unregister_source(int id);
+  unregister_source(int id);
 
   int
-  audio_jack_mgr_register_sink(const std::string name,
-                              jack_ringbuffer_t *rb_ptr,
-                              omni_semaphore *sem_ptr);
+  register_sink(const std::string name,
+               jack_ringbuffer_t *rb_ptr,
+               omni_semaphore *sem_ptr);
   bool
-  audio_jack_mgr_unregister_sink(int id);
+  unregister_sink(int id);
 
   /*!
    * \brief return single instance, create if required

Modified: 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.cc
===================================================================
--- 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.cc
    2006-12-20 19:52:04 UTC (rev 4163)
+++ 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.cc
    2006-12-20 20:17:43 UTC (rev 4164)
@@ -62,10 +62,8 @@
     d_ok_to_block(ok_to_block),
     d_ringbuffer_ready(1, 1)
 {
-  d_jack_sample_rate =
-    audio_jack_mgr::singleton()->audio_jack_mgr_sample_rate();
-  d_jack_buffer_size =
-    audio_jack_mgr::singleton()->audio_jack_mgr_buffer_size();
+  d_jack_sample_rate = audio_jack_mgr::singleton()->sample_rate();
+  d_jack_buffer_size = audio_jack_mgr::singleton()->buffer_size();
 
   d_ringbuffer =
     jack_ringbuffer_create(N_BUFFERS * d_jack_buffer_size * sizeof(sample_t));
@@ -73,16 +71,12 @@
     bail("jack_ringbuffer_create failed", 0);
 
   d_id_from_mgr =
-    audio_jack_mgr::audio_jack_mgr_register_source(name,
-                                                  d_ringbuffer,
-                                                  &d_ringbuffer_ready);
+    audio_jack_mgr::singleton()->register_source(name,
+                                                d_ringbuffer,
+                                                &d_ringbuffer_ready);
 
-  d_jack_input_port = jack_port_register (d_jack_client, "in", 
-                                         JACK_DEFAULT_AUDIO_TYPE,
-                                         JackPortIsInput, 0);
-
   set_output_multiple(d_jack_buffer_size);
-  set_output_signature(gr_make_io_signature (1, 1, sizeof (sample_t)));
+  set_output_signature(gr_make_io_signature (1, 1, sizeof(sample_t)));
 }
 
 
@@ -94,7 +88,7 @@
 
 audio_jack_source::~audio_jack_source()
 {
-  audio_jack_mgr::audio_jack_mgr_unregister_source(d_id_from_manager);
+  audio_jack_mgr::singleton()->unregister_source(d_id_from_manager);
   jack_ringbuffer_free (d_ringbuffer);
 }
 
@@ -103,54 +97,28 @@
                             gr_vector_const_void_star &input_items,
                             gr_vector_void_star &output_items)
 {
-  float **out = (float **) &output_items[0];
-  const unsigned nchan = d_input_parameters.channelCount; // # of channels == 
samples/frame
+  float *out = (float *) output_items[0];
+  int k = 0;
 
-  int k;
-  for (k = 0; k < noutput_items; ){
+  while (k < noutput_items) {
+    int nframes = jack_ringbuffer_read_space(d_ringbuffer) / sizeof(sample_t);
 
-    int nframes = d_reader->items_available() / nchan; // # of frames in 
ringbuffer
-    if (nframes == 0){         // no data right now...
-      if (k > 0)               // If we've produced anything so far, return 
that
+    if (nframes == 0) {        // no data right now...
+      if (k > 0)       // If we've produced anything so far, return that
        return k;
-
-      if (d_ok_to_block){
+      if (d_ok_to_block) {
        d_ringbuffer_ready.wait();      // block here, then try again
        continue;
       }
-
-      assert(k == 0);
-
-      // There's no data and we're not allowed to block.
-      // (A USRP is most likely controlling the pacing through the pipeline.)
-      // This is an underun.  The scheduler wouldn't have called us if it
-      // had anything better to do.  Thus we really need to produce some amount
-      // of "fill".
-      //
-      // There are lots of options for comfort noise, etc.
-      // FIXME We'll fill with zeros for now.  Yes, it will "click"...
-
-      // Fill with some frames of zeros
-      int nf = std::min(noutput_items - k, (int) 
d_portaudio_buffer_size_frames);
-      for (int i = 0; i < nf; i++){
-       for (unsigned int c = 0; c < nchan; c++){
-         out[c][k + i] = 0;
-       }
-      }
-      k += nf;
+      int nf = std::min(noutput_items - k, d_jack_buffer_size);
+      while (nf-- > 0)
+       out[k++] = 0;
       return k;
     }
 
     // We can read the smaller of the request and what's in the buffer.
     int nf = std::min(noutput_items - k, nframes);
-
-    const float *p = (const float *) d_reader->read_pointer();
-    for (int i = 0; i < nf; i++){
-      for (unsigned int c = 0; c < nchan; c++){
-       out[c][k + i] = *p++;
-      }
-    }
-    d_reader->update_read_pointer(nf * nchan);
+    jack_ringbuffer_read(d_ringbuffer, (char *) out, nf * sizeof(sample));
     k += nf;
   }
 

Modified: 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.h
===================================================================
--- 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.h 
    2006-12-20 19:52:04 UTC (rev 4163)
+++ 
gnuradio/branches/developers/brickle/jack/gr-audio-jack/src/audio_jack_source.h 
    2006-12-20 20:17:43 UTC (rev 4164)
@@ -80,10 +80,6 @@
 
   int                  d_id_from_mgr;
 
-  // random stats
-
-  int                  d_noverruns;            // count of overruns
-
   void output_error_msg (const char *msg, int err);
   void bail (const char *msg, int err) throw (std::runtime_error);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]