Skip to content

Commit

Permalink
roc-streaminggh-183: Remove is_alive from Watchdog and LatencyMonitor
Browse files Browse the repository at this point in the history
is_alive() mechanism is replaces with status codes and is
no longer used.
  • Loading branch information
gavv committed Jul 26, 2024
1 parent a0ca351 commit 883cc07
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 46 deletions.
12 changes: 0 additions & 12 deletions src/internal_modules/roc_audio/latency_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ LatencyMonitor::LatencyMonitor(IFrameReader& frame_reader,
, capture_ts_(0)
, packet_sample_spec_(packet_sample_spec)
, frame_sample_spec_(frame_sample_spec)
, alive_(true)
, init_status_(status::NoStatus) {
if ((init_status_ = tuner_.init_status()) != status::StatusOK) {
return;
Expand All @@ -56,12 +55,6 @@ status::StatusCode LatencyMonitor::init_status() const {
return init_status_;
}

bool LatencyMonitor::is_alive() const {
roc_panic_if(init_status_ != status::StatusOK);

return alive_;
}

const LatencyMetrics& LatencyMonitor::metrics() const {
roc_panic_if(init_status_ != status::StatusOK);

Expand All @@ -73,15 +66,10 @@ status::StatusCode LatencyMonitor::read(Frame& frame,
FrameReadMode mode) {
roc_panic_if(init_status_ != status::StatusOK);

if (!alive_) {
return status::StatusAbort;
}

compute_niq_latency_();
query_metrics_();

if (!pre_read_()) {
alive_ = false;
return status::StatusAbort;
}

Expand Down
5 changes: 0 additions & 5 deletions src/internal_modules/roc_audio/latency_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ class LatencyMonitor : public IFrameReader, public core::NonCopyable<> {
//! Check if the object was successfully constructed.
status::StatusCode init_status() const;

//! Check if the stream was not aborted.
bool is_alive() const;

//! Get metrics.
const LatencyMetrics& metrics() const;

Expand Down Expand Up @@ -124,8 +121,6 @@ class LatencyMonitor : public IFrameReader, public core::NonCopyable<> {
const SampleSpec packet_sample_spec_;
const SampleSpec frame_sample_spec_;

bool alive_;

status::StatusCode init_status_;
};

Expand Down
12 changes: 0 additions & 12 deletions src/internal_modules/roc_audio/watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Watchdog::Watchdog(IFrameReader& reader,
, status_(arena)
, status_pos_(0)
, show_status_(false)
, alive_(true)
, init_status_(status::NoStatus) {
if (config.no_playback_timeout >= 0) {
max_blank_duration_ =
Expand Down Expand Up @@ -116,20 +115,10 @@ status::StatusCode Watchdog::init_status() const {
return init_status_;
}

bool Watchdog::is_alive() const {
roc_panic_if(init_status_ != status::StatusOK);

return alive_;
}

status::StatusCode
Watchdog::read(Frame& frame, packet::stream_timestamp_t duration, FrameReadMode mode) {
roc_panic_if(init_status_ != status::StatusOK);

if (!alive_) {
return status::StatusAbort;
}

const status::StatusCode code = reader_.read(frame, duration, mode);
if (code != status::StatusOK && code != status::StatusPart) {
return code;
Expand All @@ -138,7 +127,6 @@ Watchdog::read(Frame& frame, packet::stream_timestamp_t duration, FrameReadMode
sample_spec_.validate_frame(frame);

if (!update_(frame)) {
alive_ = false;
return status::StatusAbort;
}

Expand Down
4 changes: 0 additions & 4 deletions src/internal_modules/roc_audio/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ class Watchdog : public IFrameReader, public core::NonCopyable<> {
//! Check if the object was successfully constructed.
status::StatusCode init_status() const;

//! Check if the stream was not aborted.
bool is_alive() const;

//! Read audio frame.
//! @remarks
//! Updates stream state and reads frame from the input reader.
Expand Down Expand Up @@ -148,7 +145,6 @@ class Watchdog : public IFrameReader, public core::NonCopyable<> {
size_t status_pos_;
bool show_status_;

bool alive_;
status::StatusCode init_status_;
};

Expand Down
13 changes: 0 additions & 13 deletions src/tests/roc_audio/test_watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ void expect_read(status::StatusCode expected_status,
for (size_t n = 0; n < frame->num_raw_samples(); n++) {
DOUBLES_EQUAL(magic_sample, (double)frame->raw_samples()[n], 0);
}

CHECK(watchdog.is_alive());
} else {
CHECK(!watchdog.is_alive());
}
}

Expand Down Expand Up @@ -179,9 +175,6 @@ TEST(watchdog, no_playback_timeout_blank_frames) {

meta_reader.set_flags(0);
expect_read(status::StatusAbort, watchdog, SamplesPerFrame);

meta_reader.set_flags(Frame::HasSignal);
expect_read(status::StatusAbort, watchdog, SamplesPerFrame);
}

TEST(watchdog, no_playback_timeout_blank_and_non_blank_frames) {
Expand Down Expand Up @@ -341,9 +334,6 @@ TEST(watchdog, broken_playback_timeout_equal_frame_sizes) {

meta_reader.set_flags(Frame::HasSignal | Frame::HasGaps | Frame::HasDrops);
expect_read(status::StatusAbort, watchdog, BreakageWindow);

meta_reader.set_flags(Frame::HasSignal);
expect_read(status::StatusAbort, watchdog, BreakageWindow);
}
}

Expand Down Expand Up @@ -604,9 +594,6 @@ TEST(watchdog, warmup_early_nonblank) {

meta_reader.set_flags(0);
expect_read(status::StatusAbort, watchdog, SamplesPerFrame);

meta_reader.set_flags(Frame::HasSignal);
expect_read(status::StatusAbort, watchdog, SamplesPerFrame);
}

// Forwarding mode to underlying reader.
Expand Down

0 comments on commit 883cc07

Please sign in to comment.