Skip to content

Commit

Permalink
offline-pipeline: Add flag to set thread priority
Browse files Browse the repository at this point in the history
BUG=b:359741102
TEST=offline-pipeline /run/imageloader/nc-ap-dlc/package/root/libeffects.so  /tmp/noise.wav /tmp/out.wav --sleep-sec=0.01 --plugin-name=plugin_processor_create_nc --set-thread-priority

Change-Id: I2bd3d98d1e6e21a54221ee7b2ec581a6825ce8a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/6051596
Reviewed-by: Cranel W <[email protected]>
Commit-Queue: Li-Yu Yu <[email protected]>
Tested-by: Li-Yu Yu <[email protected]>
  • Loading branch information
afq984 authored and Chromeos LUCI committed Nov 26, 2024
1 parent 37b5ee5 commit 593473c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion audio_processor/src/bin/offline-pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use audio_processor::processors::profile;
use audio_processor::processors::profile::Measurements;
use audio_processor::processors::CheckShape;
use audio_processor::processors::WavSource;
use audio_processor::util::set_thread_priority;
use audio_processor::AudioProcessor;
use audio_processor::Error;
use audio_processor::MultiBuffer;
Expand Down Expand Up @@ -53,6 +54,10 @@ struct Command {
#[arg(long)]
block_size_frames: Option<usize>,

/// Sets the thread priority similarly to CRAS.
#[arg(long)]
set_thread_priority: bool,

/// Also print JSON profile results in stdout.
#[arg(long)]
json: bool,
Expand Down Expand Up @@ -140,6 +145,14 @@ pub fn main() {

fn run(command: Command) {
eprintln!("{:?}", command);

let mut worker_factory = AudioWorkerSubprocessFactory::default();
if command.set_thread_priority {
set_thread_priority().unwrap();
worker_factory = worker_factory.with_set_thread_priority();
}
let worker_factory = worker_factory; // Remove mut.

let reader = hound::WavReader::open(command.input.clone()).expect("cannot open input file");
let spec = reader.spec();

Expand Down Expand Up @@ -170,7 +183,7 @@ fn run(command: Command) {
let (profile_sender, profile_receiver) = channel();
let mut pipeline = PipelineBuilder::new(check_shape.get_output_format())
.with_profile_sender(profile_sender)
.with_worker_factory(AudioWorkerSubprocessFactory::default())
.with_worker_factory(worker_factory)
.build(Processor::Pipeline {
processors: pipeline_decl,
})
Expand Down

0 comments on commit 593473c

Please sign in to comment.