Skip to content

Commit

Permalink
More failed stream recording experiments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Dec 17, 2024
1 parent 6456f44 commit ace9945
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ void StreamHistorySession::start(AudioChannelFormat format, bool has_video){
}


#if 0
class HistorySaverThread : public QThread{
public:
HistorySaverThread(StreamHistoryTracker& tracker, const std::string& filename)
: m_tracker(tracker)
, m_filename(filename)
{
}
{}
~HistorySaverThread(){
quit();
wait();
Expand All @@ -86,15 +86,20 @@ class HistorySaverThread : public QThread{
virtual void run() override{
// m_success = m_tracker.save(m_logger, m_filename);
m_success = m_tracker.save(m_filename);
exec();
}

private:
StreamHistoryTracker& m_tracker;
const std::string& m_filename;
bool m_success = false;
};
#endif

bool StreamHistorySession::save(const std::string& filename) const{
// This will be coming in from random threads. It will block until the save
// is finished or failed.

const Data& data = *m_data;

// Get an owning reference to the current tracker.
Expand All @@ -111,8 +116,10 @@ bool StreamHistorySession::save(const std::string& filename) const{
}

// tracker->save(m_logger, filename);
HistorySaverThread saver(*tracker, filename);
return saver.save();
// HistorySaverThread saver(*tracker, filename);
// return saver.save();

return tracker->save(filename);
}
void StreamHistorySession::on_samples(const float* samples, size_t frames){
Data& data = *m_data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class StreamHistoryTracker{
}

bool save(const std::string& filename){
std::unique_ptr<StreamRecording> recording;
std::unique_ptr<StreamRecording2> recording;
{
SpinLockGuard lg(m_lock);
if (m_recordings.empty()){
Expand Down Expand Up @@ -141,7 +141,7 @@ class StreamHistoryTracker{
m_recordings.emplace(
std::piecewise_construct,
std::forward_as_tuple(start_time),
std::forward_as_tuple(new StreamRecording(
std::forward_as_tuple(new StreamRecording2(
m_logger, std::chrono::milliseconds(500),
start_time,
m_audio_samples_per_frame,
Expand All @@ -161,7 +161,7 @@ class StreamHistoryTracker{
const size_t m_audio_samples_per_frame;
const size_t m_audio_frames_per_second;
const bool m_has_video;
std::map<WallClock, std::unique_ptr<StreamRecording>> m_recordings;
std::map<WallClock, std::unique_ptr<StreamRecording2>> m_recordings;
};


Expand Down
Loading

0 comments on commit ace9945

Please sign in to comment.