]> git.sesse.net Git - nageru/blobdiff - alsa_input.h
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[nageru] / alsa_input.h
index b08d47ac66729a9730ce4fed7171440669a71056..060b9212690fce317f9dfac701af37d597af908a 100644 (file)
 // as a whole, since that's what AudioMixer::add_audio() wants.
 
 #include <alsa/asoundlib.h>
-#include <alsa/pcm.h>
 #include <stdint.h>
 #include <sys/types.h>
 #include <atomic>
+#include <chrono>
 #include <functional>
+#include <memory>
 #include <string>
 #include <thread>
-#include <unordered_map>
-#include <vector>
 
 #include "bmusb/bmusb.h"
-#include "timebase.h"
+#include "quittable_sleeper.h"
 
 class ALSAPool;
-class DeviceSpecProto;
 
 class ALSAInput {
 public:
-       typedef std::function<bool(const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length)> audio_callback_t;
+       typedef std::function<bool(const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length, std::chrono::steady_clock::time_point ts)> audio_callback_t;
 
        ALSAInput(const char *device, unsigned sample_rate, unsigned num_channels, audio_callback_t audio_callback, ALSAPool *parent_pool, unsigned internal_dev_index);
        ~ALSAInput();
@@ -71,7 +69,7 @@ private:
 
        snd_pcm_t *pcm_handle = nullptr;
        std::thread capture_thread;
-       std::atomic<bool> should_quit{false};
+       QuittableSleeper should_quit;
        std::unique_ptr<uint8_t[]> buffer;
        ALSAPool *parent_pool;
        unsigned internal_dev_index;