Skip to content

Commit

Permalink
Fix busted CI. (#427)
Browse files Browse the repository at this point in the history
* Fail CI if build fails.

Signed-off-by: Josh Matthews <[email protected]>

* Fix examples.

Signed-off-by: Josh Matthews <[email protected]>

* Fix deadlock when shutting down a context.

Signed-off-by: Josh Matthews <[email protected]>

---------

Signed-off-by: Josh Matthews <[email protected]>
  • Loading branch information
jdm authored Oct 18, 2024
1 parent ed1d4c7 commit ebbba84
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 57 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ jobs:
build_result:
name: Result
runs-on: ubuntu-latest
if: always()
needs: ["Build"]
steps:
- name: Mark the job as successful
- name: Success
run: exit 0
if: success()
- name: Mark the job as unsuccessful
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
- name: Failure
run: exit 1
if: "!success()"

if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
5 changes: 3 additions & 2 deletions backends/gstreamer/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ impl GStreamerBackend {
.spawn(move || {
match recvr.recv().unwrap() {
BackendMsg::Shutdown(context_id, instance_id) => {
if let Some(vec) = instances_.lock().unwrap().get_mut(&context_id) {
let mut instances_ = instances_.lock().unwrap();
if let Some(vec) = instances_.get_mut(&context_id) {
vec.retain(|m| m.0 != instance_id);
if vec.is_empty() {
instances_.lock().unwrap().remove(&context_id);
instances_.remove(&context_id);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions examples/audio_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ use std::{thread, time};
fn run_example(servo_media: Arc<ServoMedia>) {
let options = <RealTimeAudioContextOptions>::default();
let sample_rate = options.sample_rate;
let context = servo_media.create_audio_context(
&ClientContextId::build(1, 1),
AudioContextOptions::RealTimeAudioContext(options),
);
let context = servo_media
.create_audio_context(
&ClientContextId::build(1, 1),
AudioContextOptions::RealTimeAudioContext(options),
)
.unwrap();
let context = context.lock().unwrap();
let args: Vec<_> = env::args().collect();
let default = "./examples/resources/viper_cut.ogg";
Expand Down
5 changes: 3 additions & 2 deletions examples/biquad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let mut options = OscillatorNodeOptions::default();
Expand Down
5 changes: 3 additions & 2 deletions examples/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let mut options = OscillatorNodeOptions::default();
let osc = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/channelsum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let mut options = OscillatorNodeOptions::default();
let osc = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/constant_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();

Expand Down
4 changes: 3 additions & 1 deletion examples/iir_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let id = ClientContextId::build(1, 1);
let context = servo_media.create_audio_context(&id, Default::default());
let context = servo_media
.create_audio_context(&id, Default::default())
.unwrap();

{
let context = context.lock().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/media_element_source_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl PlayerGLContext for PlayerContextDummy {

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default()).unwrap();
let context = context.lock().unwrap();
let listener = context.listener();

Expand Down
6 changes: 4 additions & 2 deletions examples/muted_audiocontext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn run_example(servo_media: Arc<ServoMedia>) {
let context_id1 = &ClientContextId::build(1, 1);
let context1 = servo_media.create_audio_context(&context_id1, Default::default());
{
let context = context1.unwrap().lock().unwrap();
let context1 = context1.unwrap();
let context = context1.lock().unwrap();
let dest = context.dest_node();
let options = OscillatorNodeOptions::default();
let osc1 = context.create_node(
Expand All @@ -33,7 +34,8 @@ fn run_example(servo_media: Arc<ServoMedia>) {
{
let mut options = OscillatorNodeOptions::default();
options.oscillator_type = Sawtooth;
let context = context2.unwrap().lock().unwrap();
let context2 = context2.unwrap();
let context = context2.lock().unwrap();
let dest = context.dest_node();
let osc3 = context.create_node(
AudioNodeInit::OscillatorNode(options.clone()),
Expand Down
9 changes: 6 additions & 3 deletions examples/offline_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {
options.length = 1024 * FRAMES_PER_BLOCK_USIZE;
let sample_rate = options.sample_rate;
let options = AudioContextOptions::OfflineAudioContext(options);
let context = servo_media.create_audio_context(&ClientContextId::build(1, 1), options);
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), options)
.unwrap();
let context = context.lock().unwrap();
let processed_audio = Arc::new(Mutex::new(Vec::new()));
let processed_audio_ = processed_audio.clone();
Expand Down Expand Up @@ -47,8 +49,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {
// Close offline context.
let _ = context.close();
// Create audio context to play the processed audio.
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 2), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 2), Default::default())
.unwrap();
let context = context.lock().unwrap();
let buffer_source = context.create_node(
AudioNodeInit::AudioBufferSourceNode(Default::default()),
Expand Down
25 changes: 15 additions & 10 deletions examples/oscillator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let mut options = OscillatorNodeOptions::default();
Expand All @@ -33,8 +34,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {
thread::sleep(time::Duration::from_millis(3000));

options.oscillator_type = Square;
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 2), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 2), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc2 = context.create_node(
Expand All @@ -53,8 +55,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {
thread::sleep(time::Duration::from_millis(1000));

options.oscillator_type = Sawtooth;
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 3), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 3), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc3 = context.create_node(
Expand All @@ -74,8 +77,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {
thread::sleep(time::Duration::from_millis(1000));

options.oscillator_type = Triangle;
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 4), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 4), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc4 = context.create_node(
Expand All @@ -97,8 +101,9 @@ fn run_example(servo_media: Arc<ServoMedia>) {

options.oscillator_type = Custom;

let context =
servo_media.create_audio_context(&ClientContextId::build(1, 5), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 5), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc5 = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/panner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let listener = context.listener();
Expand Down
5 changes: 3 additions & 2 deletions examples/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/params_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let mut options = OscillatorNodeOptions::default();
options.freq = 2.0;
Expand Down
7 changes: 4 additions & 3 deletions examples/params_connect2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = context.unwrap().lock().unwrap();
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let mut options = OscillatorNodeOptions::default();
options.freq = 2.0;
let lfo = context.create_node(AudioNodeInit::OscillatorNode(options), Default::default());
Expand Down
5 changes: 3 additions & 2 deletions examples/params_settarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let osc = context.create_node(
AudioNodeInit::OscillatorNode(Default::default()),
Expand Down
2 changes: 1 addition & 1 deletion examples/play_noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default()).unwrap();
let context = context.lock().unwrap();
let buffer_source = context.create_node(
AudioNodeInit::AudioBufferSourceNode(Default::default()),
Expand Down
5 changes: 3 additions & 2 deletions examples/set_value_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();

Expand Down
5 changes: 3 additions & 2 deletions examples/stereo_panner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc = context.create_node(
Expand Down
5 changes: 3 additions & 2 deletions examples/stream_dest_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use std::sync::Arc;
use std::{thread, time};

fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let context = servo_media
.create_audio_context(&ClientContextId::build(1, 1), Default::default())
.unwrap();
let context = context.lock().unwrap();
let options = OscillatorNodeOptions::default();
let osc1 = context.create_node(
Expand Down
3 changes: 2 additions & 1 deletion examples/stream_reader_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fn run_example(servo_media: Arc<ServoMedia>) {
let context =
servo_media.create_audio_context(&ClientContextId::build(1, 1), Default::default());
let input = servo_media.create_audiostream();
let context = context.unwrap().lock().unwrap();
let context = context.unwrap();
let context = context.lock().unwrap();
let dest = context.dest_node();
let osc1 = context.create_node(
AudioNodeInit::MediaStreamSourceNode(input),
Expand Down
1 change: 1 addition & 0 deletions examples/wave_shaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn run_example(servo_media: Arc<ServoMedia>) {
let context = servo_media.create_audio_context(&id, Default::default());

{
let context = context.unwrap();
let context = context.lock().unwrap();
let curve = vec![1., 0., 0., 0.75, 0.5];

Expand Down

0 comments on commit ebbba84

Please sign in to comment.