commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3794 - gnuradio/branches/developers/jcorgan/cppwrap/g


From: jcorgan
Subject: [Commit-gnuradio] r3794 - gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++
Date: Sun, 15 Oct 2006 20:54:58 -0600 (MDT)

Author: jcorgan
Date: 2006-10-15 20:54:58 -0600 (Sun, 15 Oct 2006)
New Revision: 3794

Modified:
   
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/dialtone.cc
   
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.cc
   
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.h
   
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.cc
   
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.h
Log:
I hear dialtone!


Modified: 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/dialtone.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/dialtone.cc  
    2006-10-15 23:11:37 UTC (rev 3793)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/dialtone.cc  
    2006-10-16 02:54:58 UTC (rev 3794)
@@ -20,26 +20,26 @@
  */
 
 #include <gnuradio/gr_sig_source_f.h>
-//#include <gnuradio/audio_alsa_sink.h>
-#include <gnuradio/gr_null_sink.h>
+#include <gnuradio/audio_alsa_sink.h>
+//#include <gnuradio/gr_null_sink.h>
 #include <gr_flow_graph.h>
 
 int main()
 {
     gr_sig_source_f_sptr src0, src1;
-    gr_block_sptr sink0, sink1;
-//  audio_alsa_sink_sptr sink;
+//  gr_block_sptr sink0, sink1;
+    audio_alsa_sink_sptr sink;
     gr_flow_graph_sptr fg;
     
     src0 = gr_make_sig_source_f(48000, GR_SIN_WAVE, 350, 0.5);
     src1 = gr_make_sig_source_f(48000, GR_SIN_WAVE, 440, 0.5);
-//  sink = audio_alsa_make_sink(48000);
-    sink0 = gr_make_null_sink(sizeof(float));
-    sink1 = gr_make_null_sink(sizeof(float));
+    sink = audio_alsa_make_sink(48000);
+//  sink0 = gr_make_null_sink(sizeof(float));
+//  sink1 = gr_make_null_sink(sizeof(float));
     
     fg = gr_make_flow_graph();
-    fg->connect(src0, 0, sink0, 0);
-    fg->connect(src1, 0, sink1, 0);
+    fg->connect(src0, 0, sink, 0);
+    fg->connect(src1, 0, sink, 1);
 
     fg->run();
     

Modified: 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.cc
 2006-10-15 23:11:37 UTC (rev 3793)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.cc
 2006-10-16 02:54:58 UTC (rev 3794)
@@ -307,8 +307,6 @@
 
     d_scheduler = gr_make_scheduler(shared_from_this());
     d_scheduler->start();
-    
-    printf("If this were a real program, something interesting would have just 
happened.\n");
 }
 
 void gr_flow_graph::stop()
@@ -354,7 +352,6 @@
            nodes.erase(find(nodes.begin(), nodes.end(), *block_iter));
     }
 
-    printf("Flow graph has %i subgraphs.\n", result.size());
     return result;
 }
 

Modified: 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.h
  2006-10-15 23:11:37 UTC (rev 3793)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_flow_graph.h
  2006-10-16 02:54:58 UTC (rev 3794)
@@ -43,6 +43,7 @@
 typedef std::vector<gr_block_sptr> gr_block_vector_t;
 typedef std::vector<gr_block_sptr>::iterator gr_block_vector_iterator_t;
 typedef std::vector<gr_block_vector_t> gr_block_vector_vector_t;
+typedef std::vector<gr_block_vector_t>::iterator 
gr_block_vector_vector_iterator_t; // :-)
 
 // Flow graph endpoints, edges
 typedef std::pair<gr_block_sptr, int> gr_endpoint_t;

Modified: 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.cc
  2006-10-15 23:11:37 UTC (rev 3793)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.cc
  2006-10-16 02:54:58 UTC (rev 3794)
@@ -22,6 +22,33 @@
 #include <gr_scheduler.h>
 #include <gr_flow_graph.h>
 
+gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t graph)
+{
+    return gr_scheduler_thread_sptr(new gr_scheduler_thread(graph));
+}
+
+gr_scheduler_thread::gr_scheduler_thread(gr_block_vector_t graph) :
+    d_sts(gr_make_single_threaded_scheduler(graph))
+{
+    // NOP
+}
+
+gr_scheduler_thread::~gr_scheduler_thread()
+{
+    // NOP
+}
+
+void gr_scheduler_thread::run(void *arg)
+{
+    printf("Running thread...\n");
+    d_sts->run();
+}
+
+void gr_scheduler_thread::stop()
+{
+    d_sts->stop();
+}
+
 gr_scheduler_sptr gr_make_scheduler(gr_flow_graph_sptr fg)
 {
     return gr_scheduler_sptr(new gr_scheduler(fg));
@@ -29,7 +56,12 @@
 
 gr_scheduler::gr_scheduler(gr_flow_graph_sptr fg)
 {
-    d_graphs = fg->calc_partitions();
+    gr_block_vector_vector_t graphs = fg->calc_partitions();
+    printf("Flowgraph has %i sub-graphs.\n", graphs.size());
+
+    gr_block_vector_vector_iterator_t graph_iter;
+    for (graph_iter = graphs.begin(); graph_iter != graphs.end(); graph_iter++)
+       d_threads.push_back(gr_make_scheduler_thread(*graph_iter));    
 }
 
 gr_scheduler::~gr_scheduler()
@@ -39,6 +71,11 @@
 
 void gr_scheduler::start()
 {
+    printf("There are %i threads to run.\n", d_threads.size());
+
+    gr_scheduler_thread_vector_iterator_t thread_iter;
+    for (thread_iter = d_threads.begin(); thread_iter != d_threads.end(); 
thread_iter++)
+       (*thread_iter)->start();
 }
 
 void gr_scheduler::stop()
@@ -47,4 +84,18 @@
 
 void gr_scheduler::wait()
 {
+    // Untile join() exception is solved below
+    while(1);
+    
+/*    
+    gr_scheduler_thread_vector_iterator_t thread_iter;
+    for (thread_iter = d_threads.begin(); thread_iter != d_threads.end(); 
thread_iter++) {
+       while(1) {
+           printf("thread state is %i\n", (*thread_iter)->state());
+           (*thread_iter)->join(NULL);
+           if (!(*thread_iter)->state() == omni_thread::STATE_TERMINATED)
+               break;
+       }
+    }
+*/
 }

Modified: 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.h
===================================================================
--- 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.h
   2006-10-15 23:11:37 UTC (rev 3793)
+++ 
gnuradio/branches/developers/jcorgan/cppwrap/gnuradio-examples/c++/gr_scheduler.h
   2006-10-16 02:54:58 UTC (rev 3794)
@@ -23,17 +23,42 @@
 #define INCLUDED_GR_SCHEDULER_H
 
 #include <gr_flow_graph.h>
+#include <omnithread.h>
+#include <gr_single_threaded_scheduler.h>
+
 #include <vector>
 #include <boost/shared_ptr.hpp>
 
+class gr_scheduler_thread;
+typedef boost::shared_ptr<gr_scheduler_thread> gr_scheduler_thread_sptr;
+typedef std::vector<gr_scheduler_thread_sptr> gr_scheduler_thread_vector_t;
+typedef std::vector<gr_scheduler_thread_sptr>::iterator 
gr_scheduler_thread_vector_iterator_t;
+
+gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t graph);
+
+class gr_scheduler_thread : public omni_thread
+{
+private:
+    gr_scheduler_thread(gr_block_vector_t graph);
+    friend gr_scheduler_thread_sptr gr_make_scheduler_thread(gr_block_vector_t 
graph);
+
+    gr_single_threaded_scheduler_sptr d_sts;    
+
+public:
+    ~gr_scheduler_thread();
+    virtual void run(void *arg);
+    void stop();
+};
+
 class gr_scheduler;
 typedef boost::shared_ptr<gr_scheduler> gr_scheduler_sptr;
 gr_scheduler_sptr gr_make_scheduler(gr_flow_graph_sptr fg);
 
+
 class gr_scheduler
 {
 private:
-    gr_block_vector_vector_t d_graphs;
+    gr_scheduler_thread_vector_t d_threads;
 
     gr_scheduler(gr_flow_graph_sptr fg);
     friend gr_scheduler_sptr gr_make_scheduler(gr_flow_graph_sptr fg);





reply via email to

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