]> git.sesse.net Git - nageru/commitdiff
Rename Resampler to ResamplingQueue, to avoid conflicts with zita-resampler.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 22:46:19 +0000 (23:46 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 22:46:19 +0000 (23:46 +0100)
Makefile
mixer.cpp
mixer.h
resampling_queue.cpp [moved from resampler.cpp with 94% similarity]
resampling_queue.h [moved from resampler.h with 94% similarity]

index 9cd5240fb12b95579326cf924b51e21b9a2b8399..91ebdde2610ca730d3b486f39506fccbdb1aa243 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ OBJS=glwidget.o main.o mainwindow.o vumeter.o lrameter.o vu_common.o
 OBJS += glwidget.moc.o mainwindow.moc.o vumeter.moc.o lrameter.moc.o
 
 # Mixer objects
-OBJS += h264encode.o mixer.o bmusb/bmusb.o pbo_frame_allocator.o context.o ref_counted_frame.o theme.o resampler.o httpd.o ebu_r128_proc.o flags.o image_input.o stereocompressor.o filter.o
+OBJS += h264encode.o mixer.o bmusb/bmusb.o pbo_frame_allocator.o context.o ref_counted_frame.o theme.o resampling_queue.o httpd.o ebu_r128_proc.o flags.o image_input.o stereocompressor.o filter.o
 
 %.o: %.cpp
        $(CXX) -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
index 08c562f7ab448250ba36f48e48b4805f01edc707..6bf81192fdfd99421398dedc189e23be75344a5d 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -124,7 +124,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
                        [this]{
                                resource_pool->clean_context();
                        });
-               card->resampler.reset(new Resampler(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
+               card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
                card->usb->configure_card();
        }
 
@@ -249,7 +249,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                if (dropped_frames > FPS * 2) {
                        fprintf(stderr, "Card %d lost more than two seconds (or time code jumping around), resetting resampler\n",
                                card_index);
-                       card->resampler.reset(new Resampler(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
+                       card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
                } else if (dropped_frames > 0) {
                        // Insert silence as needed.
                        fprintf(stderr, "Card %d dropped %d frame(s) (before timecode 0x%04x), inserting silence.\n",
@@ -257,10 +257,10 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                        vector<float> silence;
                        silence.resize((OUTPUT_FREQUENCY / FPS) * 2);
                        for (int i = 0; i < dropped_frames; ++i) {
-                               card->resampler->add_input_samples((unwrapped_timecode - dropped_frames + i) / double(FPS), silence.data(), (OUTPUT_FREQUENCY / FPS));
+                               card->resampling_queue->add_input_samples((unwrapped_timecode - dropped_frames + i) / double(FPS), silence.data(), (OUTPUT_FREQUENCY / FPS));
                        }
                }
-               card->resampler->add_input_samples(unwrapped_timecode / double(FPS), audio.data(), num_samples);
+               card->resampling_queue->add_input_samples(unwrapped_timecode / double(FPS), audio.data(), num_samples);
        }
 
        // Done with the audio, so release it.
@@ -466,7 +466,7 @@ void Mixer::thread_func()
                for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
                        input_frames.push_back(bmusb_current_rendering_frame[card_index]);
                }
-               const int64_t av_delay = TIMEBASE / 10;  // Corresponds to the fixed delay in resampler.h. TODO: Make less hard-coded.
+               const int64_t av_delay = TIMEBASE / 10;  // Corresponds to the fixed delay in resampling_queue.h. TODO: Make less hard-coded.
                h264_encoder->end_frame(fence, pts_int + av_delay, input_frames);
                ++frame;
                pts_int += TIMEBASE / FPS;
@@ -533,7 +533,7 @@ void Mixer::process_audio_one_frame()
                samples_card.resize((OUTPUT_FREQUENCY / FPS) * 2);
                {
                        unique_lock<mutex> lock(cards[card_index].audio_mutex);
-                       if (!cards[card_index].resampler->get_output_samples(pts(), &samples_card[0], OUTPUT_FREQUENCY / FPS)) {
+                       if (!cards[card_index].resampling_queue->get_output_samples(pts(), &samples_card[0], OUTPUT_FREQUENCY / FPS)) {
                                printf("Card %d reported previous underrun.\n", card_index);
                        }
                }
diff --git a/mixer.h b/mixer.h
index 6725a7f46e242fe44bdba8a7c0e583b422b42102..3a19d3aaef946f6257a27a9ae060c0cf057306ba 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -27,7 +27,7 @@
 #include "pbo_frame_allocator.h"
 #include "ref_counted_frame.h"
 #include "ref_counted_gl_sync.h"
-#include "resampler.h"
+#include "resampling_queue.h"
 #include "theme.h"
 #include "timebase.h"
 #include "stereocompressor.h"
@@ -181,7 +181,7 @@ private:
                unsigned dropped_frames = 0;  // Before new_frame.
 
                std::mutex audio_mutex;
-               std::unique_ptr<Resampler> resampler;  // Under audio_mutex.
+               std::unique_ptr<ResamplingQueue> resampling_queue;  // Under audio_mutex.
                int last_timecode = -1;  // Unwrapped.
        };
        CaptureCard cards[MAX_CARDS];  // protected by <bmusb_mutex>
similarity index 94%
rename from resampler.cpp
rename to resampling_queue.cpp
index 138f837250f154c35b42031654cdc15e8e19b3b0..80d12297ce4e90c74d183eae747de34ccdb98fa6 100644 (file)
@@ -16,7 +16,7 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "resampler.h"
+#include "resampling_queue.h"
 
 #include <math.h>
 #include <stddef.h>
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <zita-resampler/vresampler.h>
 
-Resampler::Resampler(unsigned freq_in, unsigned freq_out, unsigned num_channels)
+ResamplingQueue::ResamplingQueue(unsigned freq_in, unsigned freq_out, unsigned num_channels)
        : freq_in(freq_in), freq_out(freq_out), num_channels(num_channels),
          ratio(double(freq_out) / double(freq_in))
 {
@@ -36,7 +36,7 @@ Resampler::Resampler(unsigned freq_in, unsigned freq_out, unsigned num_channels)
         vresampler.process ();
 }
 
-void Resampler::add_input_samples(double pts, const float *samples, ssize_t num_samples)
+void ResamplingQueue::add_input_samples(double pts, const float *samples, ssize_t num_samples)
 {
        if (first_input) {
                // Synthesize a fake length.
@@ -56,7 +56,7 @@ void Resampler::add_input_samples(double pts, const float *samples, ssize_t num_
        }
 }
 
-bool Resampler::get_output_samples(double pts, float *samples, ssize_t num_samples)
+bool ResamplingQueue::get_output_samples(double pts, float *samples, ssize_t num_samples)
 {
        double last_output_len;
        if (first_output) {
similarity index 94%
rename from resampler.h
rename to resampling_queue.h
index 7d3b6025eb7b490655bcf2327e6c3db280195888..c085eceb6755838ea12001cf6aa6d39a6f21e1d5 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _RESAMPLER_H
-#define _RESAMPLER_H 1
+#ifndef _RESAMPLING_QUEUE_H
+#define _RESAMPLING_QUEUE_H 1
 
 // Takes in samples from an input source, possibly with jitter, and outputs a fixed number
 // of samples every iteration. Used to a) change sample rates if needed, and b) deal with
@@ -45,9 +45,9 @@
 #include <deque>
 #include <memory>
 
-class Resampler {
+class ResamplingQueue {
 public:
-       Resampler(unsigned freq_in, unsigned freq_out, unsigned num_channels = 2);
+       ResamplingQueue(unsigned freq_in, unsigned freq_out, unsigned num_channels = 2);
 
        // Note: pts is always in seconds.
        void add_input_samples(double pts, const float *samples, ssize_t num_samples);
@@ -88,4 +88,4 @@ private:
        std::deque<float> buffer;
 };
 
-#endif  // !defined(_RESAMPLER_H)
+#endif  // !defined(_RESAMPLING_QUEUE_H)