Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/internal_modules/roc_audio/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "roc_core/rate_limiter.h"
#include "roc_core/time.h"
#include "roc_packet/units.h"
#include "roc_sndio/io_config.h"
#include "roc_status/code_to_str.h"

namespace roc {
Expand All @@ -32,7 +33,7 @@ struct ProfilerConfig {
//! Default Initialization.
ProfilerConfig()
: profiling_interval(core::Second)
, chunk_duration(10 * core::Millisecond) {
, chunk_duration(sndio::DefaultFrameLength) {
}

//! Override Initialization.
Expand Down
9 changes: 9 additions & 0 deletions src/internal_modules/roc_sndio/io_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
namespace roc {
namespace sndio {

namespace {

//! Default duration of a frame. 10ms is rather high,
//! but works well even on cheap sound cards and CPUs.
//! Usually you can use much lower values.
const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

} // namespace

//! Sink and source config.
struct IoConfig {
//! Sample spec
Expand Down
6 changes: 0 additions & 6 deletions src/internal_modules/roc_sndio/io_pump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
namespace roc {
namespace sndio {

namespace {

const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

} // namespace

IoPump::IoPump(core::IPool& frame_pool,
core::IPool& frame_buffer_pool,
ISource& source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ const core::nanoseconds_t ReportInterval = 10 * core::Second;
// 40ms or 20ms, and sometimes even 10ms
const core::nanoseconds_t DefaultLatency = core::Millisecond * 60;

// 10ms is rather high, but works well even on cheap sound cards and CPUs.
// Usually you can use much lower values.
const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

const core::nanoseconds_t MinTimeout = core::Millisecond * 50;
const core::nanoseconds_t MaxTimeout = core::Second * 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
namespace roc {
namespace sndio {

namespace {

const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

} // namespace

SoxSink::SoxSink(audio::FrameFactory& frame_factory,
core::IArena& arena,
const IoConfig& io_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
namespace roc {
namespace sndio {

namespace {

const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

} // namespace

SoxSource::SoxSource(audio::FrameFactory& frame_factory,
core::IArena& arena,
const IoConfig& io_config,
Expand Down
7 changes: 6 additions & 1 deletion src/tools/roc_copy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ size_t compute_max_frame_size(const sndio::IoConfig& io_config) {
audio::ChanLayout_Surround, audio::ChanOrder_Smpte,
audio::ChanMask_Surround_7_1_4, 48000);

return spec.ns_2_samples_overall(io_config.frame_length) * sizeof(audio::sample_t);
core::nanoseconds_t len = io_config.frame_length;
if (len == 0) {
len = sndio::DefaultFrameLength;
}

return spec.ns_2_samples_overall(len) * sizeof(audio::sample_t);
}

bool parse_input_uri(const gengetopt_args_info& args, address::IoUri& input_uri) {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/roc_recv/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool build_context_config(const gengetopt_args_info& args,
audio::ChanMask_Surround_7_1_4, 48000);
core::nanoseconds_t len = io_config.frame_length;
if (len == 0) {
len = 10 * core::Millisecond;
len = sndio::DefaultFrameLength;
}
context_config.max_frame_size =
spec.ns_2_samples_overall(len) * sizeof(audio::sample_t);
Expand Down
13 changes: 12 additions & 1 deletion src/tools/roc_send/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool build_context_config(const gengetopt_args_info& args,
audio::ChanMask_Surround_7_1_4, 48000);
core::nanoseconds_t len = io_config.frame_length;
if (len == 0) {
len = 10 * core::Millisecond;
len = sndio::DefaultFrameLength;
}
context_config.max_packet_size =
packet::Packet::approx_size(spec.ns_2_samples_overall(len));
Expand All @@ -113,6 +113,17 @@ bool build_context_config(const gengetopt_args_info& args,
roc_log(LogError, "invalid --max-frame-size: should be > 0");
return false;
}
} else {
audio::SampleSpec spec = io_config.sample_spec;
spec.use_defaults(audio::Format_Pcm, audio::PcmSubformat_Raw,
audio::ChanLayout_Surround, audio::ChanOrder_Smpte,
audio::ChanMask_Surround_7_1_4, 48000);
core::nanoseconds_t len = io_config.frame_length;
if (len == 0) {
len = sndio::DefaultFrameLength;
}
context_config.max_frame_size =
spec.ns_2_samples_overall(len) * sizeof(audio::sample_t);
}

return true;
Expand Down
Loading