summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorJohnathan Corgan2010-04-26 22:13:34 -0700
committerJohnathan Corgan2010-04-26 22:13:34 -0700
commita178f23be75489c1507060a8b0e9e59cd358dfba (patch)
treea4cfa45867f51df5fdc0e1851c6688d7346f34ad /gnuradio-core/src/lib
parent665d7a850eeb46bfc6388a98e4a4107648cb6add (diff)
downloadgnuradio-a178f23be75489c1507060a8b0e9e59cd358dfba.tar.gz
gnuradio-a178f23be75489c1507060a8b0e9e59cd358dfba.tar.bz2
gnuradio-a178f23be75489c1507060a8b0e9e59cd358dfba.zip
Convert gr-audio-portaudio to Boost via gruel
Remove omnithread dependency in build for gr-audio-portaudio Remove unused debugging utility class in gnuradio-core (gri_logger)
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/io/Makefile.am2
-rw-r--r--gnuradio-core/src/lib/io/gri_logger.cc178
-rw-r--r--gnuradio-core/src/lib/io/gri_logger.h59
3 files changed, 0 insertions, 239 deletions
diff --git a/gnuradio-core/src/lib/io/Makefile.am b/gnuradio-core/src/lib/io/Makefile.am
index 9eacd137d..c52554645 100644
--- a/gnuradio-core/src/lib/io/Makefile.am
+++ b/gnuradio-core/src/lib/io/Makefile.am
@@ -39,7 +39,6 @@ libio_la_SOURCES = \
gr_oscope_guts.cc \
gr_oscope_sink_f.cc \
gr_oscope_sink_x.cc \
- gri_logger.cc \
i2c.cc \
i2c_bitbang.cc \
i2c_bbio.cc \
@@ -72,7 +71,6 @@ grinclude_HEADERS = \
gr_oscope_sink_f.h \
gr_oscope_sink_x.h \
gr_trigger_mode.h \
- gri_logger.h \
i2c.h \
i2c_bitbang.h \
i2c_bbio.h \
diff --git a/gnuradio-core/src/lib/io/gri_logger.cc b/gnuradio-core/src/lib/io/gri_logger.cc
deleted file mode 100644
index 473a7c5ed..000000000
--- a/gnuradio-core/src/lib/io/gri_logger.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006,2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if 0 // This needs reimplementation with boost threads and synchronization
-
-#include <gri_logger.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdexcept>
-#include <boost/weak_ptr.hpp>
-#include <string.h>
-
-
-/*
- * This class creates the thread that reads from the ringbuffer and
- * and writes to the file. This is opaque to the user.
- */
-class gri_log_poster : public omni_thread
-{
- FILE *d_fp;
- gr_buffer_sptr d_writer;
- gr_buffer_reader_sptr d_reader;
- omni_semaphore d_ringbuffer_ready;
- volatile bool d_time_to_die;
- volatile bool d_writer_overrun;
-
- virtual void* run_undetached(void * arg);
-
-public:
- gri_log_poster(const char *filename);
- ~gri_log_poster();
-
- void kill() { d_time_to_die = true; post(); }
- gr_buffer_sptr writer() const { return d_writer; }
- void post() { d_ringbuffer_ready.post(); }
- void note_writer_overrun() { d_writer_overrun = true; }
-};
-
-gri_log_poster::gri_log_poster(const char *filename)
- : omni_thread(),
- d_ringbuffer_ready(1, 1), // binary semaphore
- d_time_to_die(false),
- d_writer_overrun(false)
-{
- if ((d_fp = fopen(filename, "w")) == 0){
- perror (filename);
- throw std::runtime_error("can't open file");
- }
-
- // Create a 1MB buffer.
- d_writer = gr_make_buffer(1 * 1024 * 1024, sizeof(unsigned char));
- d_reader = gr_buffer_add_reader(d_writer, 0);
-
- start_undetached(); // start the thread
-}
-
-gri_log_poster::~gri_log_poster()
-{
- if (d_fp != 0){
- fclose(d_fp);
- d_fp = 0;
- }
-}
-
-/*
- * This is the body of the logging thread.
- */
-void *
-gri_log_poster::run_undetached(void *arg)
-{
- int nbytes;
-
- //fprintf(stderr, "Enter: run_undetached!\n");
-
- while (!d_time_to_die){
- while ((nbytes = d_reader->items_available()) > 0){
- fwrite(d_reader->read_pointer(), 1, nbytes, d_fp);
- d_reader->update_read_pointer(nbytes);
- }
- fflush(d_fp);
- d_ringbuffer_ready.wait();
-
- if (d_writer_overrun){
- fputs(">>>>> gri_logger: writer overrun. Info lost <<<<<\n", d_fp);
- d_writer_overrun = false;
- }
- }
-
- // fprintf(stderr, "Exit: run_undetached!\n");
- return 0;
-}
-
-// ------------------------------------------------------------------------
-
-static boost::weak_ptr<gri_logger> s_singleton; // weak pointer IQ test ;-)
-static omni_mutex s_singleton_mutex;
-
-gri_logger_sptr
-gri_logger::singleton()
-{
- omni_mutex_lock l(s_singleton_mutex);
- gri_logger_sptr r;
-
- if (r = s_singleton.lock())
- return r;
-
- r = gri_logger_sptr(new gri_logger("gri_logger.log"));
- s_singleton = r;
- return r;
-}
-
-
-gri_logger::gri_logger(const char *filename)
-{
- d_poster = new gri_log_poster(filename);
-}
-
-gri_logger::~gri_logger()
-{
- d_poster->kill();
- d_poster->join(NULL);
-}
-
-void
-gri_logger::write(const void *buf, size_t count)
-{
- omni_mutex_lock l(d_write_mutex);
- gr_buffer_sptr writer = d_poster->writer();
-
- // either write it all, or drop it on the ground
- if (count <= (size_t) writer->space_available()){
- memcpy(writer->write_pointer(), buf, count);
- writer->update_write_pointer(count);
- d_poster->post();
- }
- else {
- d_poster->note_writer_overrun();
- }
-}
-
-void
-gri_logger::printf(const char *format, ...)
-{
- va_list ap;
- char buf[4096];
- int n;
-
- va_start(ap, format);
- n = vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
- if (n > -1 && n < (ssize_t) sizeof(buf))
- write(buf, n);
-}
-
-#endif
diff --git a/gnuradio-core/src/lib/io/gri_logger.h b/gnuradio-core/src/lib/io/gri_logger.h
deleted file mode 100644
index 0a1414540..000000000
--- a/gnuradio-core/src/lib/io/gri_logger.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006,2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef INCLUDED_GRI_LOGGER_H
-#define INCLUDED_GRI_LOGGER_H
-
-#if 0 // This needs reimplementation with boost threads and synchronization
-
-#include <stddef.h>
-#include <gnuradio/omnithread.h>
-#include <gr_buffer.h>
-
-class gri_log_poster;
-class gri_logger;
-typedef boost::shared_ptr<gri_logger> gri_logger_sptr;
-
-
-/*!
- * \brief non-blocking logging to a file.
- *
- * In reality, this may block, but only for a bounded time.
- * Trust me, it's safe to use from portaudio and JACK callbacks.
- */
-class gri_logger
-{
- gri_log_poster *d_poster;
- omni_mutex d_write_mutex;
-
-public:
- static gri_logger_sptr singleton();
-
- gri_logger(const char *filename);
- ~gri_logger();
-
- void write(const void *buf, size_t count);
- void printf(const char *format, ...);
-};
-
-#endif
-
-#endif /* INCLUDED_GRI_LOGGER_H */