Skip to content

Add direction field to sound block to enable microphone control #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

drrmmng
Copy link

@drrmmng drrmmng commented Apr 22, 2019

This is the second attempt of this: #352

This pull request:

  • direction field to sound block to enable microphone control
  • adds new icons for microphone control
  • renames the "volume_muted" icon to "crossed" to better reflect its new purpose

Edit: Closes #277.

@@ -673,12 +901,19 @@ impl Block for Sound {
if name.as_str() == self.id {
match e.button {
MouseButton::Right => self.device.toggle()?,
MouseButton::Left =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for moving away from spawn_child_async() here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like an artifact from my previous pull request. I think the version on the master is superior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you then rebase your pull request?

"volume_full" => " VOL ",
"volume_half" => " VOL ",
"volume_empty" => " VOL ",
// This icon has no spaces around it because it is manually set as text. (sound.rs)
"volume_muted" => "MUTED",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the reason for changing this? And adding the crossed icon?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To separate the icon from the volume percentage field. The output icons start with "volume" and the microphone icons with "mic". The "crossed" icon was previously called "volume_muted" but only affects the percentage field.
The name "crossed" is more generic and since the sound field is now responsible for sound volume and microphone gain I thought that would fit better.

@atheriel
Copy link
Collaborator

Looks much better! I left a few comments for you.

@drrmmng
Copy link
Author

drrmmng commented May 22, 2019

Do you agree with my comments?

Copy link
Contributor

@SWW13 SWW13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, first of all: great work!

I'm the original author of the pulseaudio support, so I know the pain working with pulseaudio.
I've looked over your PR and it looks overall good, but I found some parts that could be simplified.
As the pulseaudio code is very complex, I'd like to keep it as simple as possible.

Also the Cargo.lock shouldn't be included (if not necessary) to ease the merge.
If you struggling with git feel free to ping me.

}

#[cfg(feature = "pulseaudio")]
lazy_static! {
static ref PULSEAUDIO_CLIENT: Result<PulseAudioClient> = PulseAudioClient::new();
static ref PULSEAUDIO_CLIENT_SINK: Result<PulseAudioClient> = PulseAudioClient::new(Direction::Output);
static ref PULSEAUDIO_CLIENT_SOURCE: Result<PulseAudioClient> = PulseAudioClient::new(Direction::Input);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason why you duplicate the client?

I think one should be enough, this should keep the already pretty high complexity a bit lower. The only overhead we get with one client would be requesting both default sink/source at startup and indistinguishable events, which we already have for all sinks / sources.

self.volume(sink_info.volume);
self.muted = sink_info.mute;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging the PulseAudioSinkInfo and PulseAudioSourceInfo struct would enable some code deduplication here.

self.text.set_text(format!("{:02}%", volume));
self.text.set_state(State::Idle);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code can be deduplicated when the match self.direction is only used for selecting the icons.

@@ -673,12 +901,19 @@ impl Block for Sound {
if name.as_str() == self.id {
match e.button {
MouseButton::Right => self.device.toggle()?,
MouseButton::Left =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you then rebase your pull request?

|_| { }
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be unified.

format!("pulseaudio connection failed with error: {}", err),
))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be unified.

@drrmmng
Copy link
Author

drrmmng commented Oct 15, 2019

Hey @SWW13, sorry for the late reply, unfortunately I don't have much time at the moment. Still, I'd like to merge this feature somehow, would you mind helping me out?

@SWW13
Copy link
Contributor

SWW13 commented Oct 15, 2019

I'm also a bit short on time, maybe I find time for it in the next weeks.

@mariojackson
Copy link

Would be awesome if this feature would be implemented. I'm currently learning Rust, so I probably cannot help out myself, but maybe someone finds a little time in the near future.

@ammgws
Copy link
Collaborator

ammgws commented May 2, 2020

Anyone still working on this? @fedario ?

@drrmmng
Copy link
Author

drrmmng commented May 2, 2020

Anyone still working on this? @fedario ?

It would be nice if someone could help me merge this, since it works so far.

@ammgws
Copy link
Collaborator

ammgws commented May 3, 2020

Seems like deduplicating the client is the only major hurdle left

@remi-dupre remi-dupre mentioned this pull request Jun 11, 2020
@ammgws
Copy link
Collaborator

ammgws commented Jul 7, 2020

Superceded by #740

@ammgws ammgws closed this Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for PulseAudio sources in the sound block
5 participants