stream-volumes: Support source-output volume controls now available in PA.

This commit is contained in:
Colin Guthrie 2011-05-06 10:55:17 +01:00
parent 50efee1180
commit 9784b9d76d
6 changed files with 47 additions and 5 deletions

View File

@ -606,6 +606,7 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
w = sourceOutputWidgets[info.index];
else {
sourceOutputWidgets[info.index] = w = SourceOutputWidget::create(this);
w->setChannelMap(info.channel_map, true);
recsVBox->pack_start(*w, false, false, 0);
w->index = info.index;
w->clientIndex = info.client;
@ -631,6 +632,11 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
setIconFromProplist(w->iconImage, info.proplist, "audio-input-microphone");
#if HAVE_SOURCE_OUTPUT_VOLUMES
w->setVolume(info.volume);
w->muteToggleButton->set_active(info.mute);
#endif
w->updating = false;
if (is_new)

View File

@ -39,6 +39,8 @@
# define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0))
#endif
#define HAVE_SOURCE_OUTPUT_VOLUMES PA_CHECK_VERSION(1,0,0)
enum SinkInputType {
SINK_INPUT_ALL,
SINK_INPUT_CLIENT,

View File

@ -39,8 +39,8 @@ public:
void setSinkIndex(uint32_t idx);
uint32_t sinkIndex();
virtual void executeVolumeUpdate();
virtual void onDeviceChangePopup();
virtual void onMuteToggleButton();
virtual void onDeviceChangePopup();
virtual void onKill();
private:

View File

@ -52,9 +52,9 @@ void SinkWidget::executeVolumeUpdate() {
pa_operation_unref(o);
ca_context_playing(ca_gtk_context_get(), 2, &playing);
if (playing)
return;
//ca_context_playing(ca_gtk_context_get(), 2, &playing);
//if (playing)
// return;
snprintf(dev, sizeof(dev), "%lu", (unsigned long) index);
ca_context_change_device(ca_gtk_context_get(), dev);

View File

@ -37,9 +37,11 @@ SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefP
terminate.set_label(_("Terminate Recording"));
/* Source Outputs do not have volume controls */
#if !HAVE_SOURCE_OUTPUT_VOLUMES
/* Source Outputs do not have volume controls in versions of PA < 1.0 */
muteToggleButton->hide();
lockToggleButton->hide();
#endif
}
SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) {
@ -69,6 +71,34 @@ uint32_t SourceOutputWidget::sourceIndex() {
return mSourceIndex;
}
#if HAVE_SOURCE_OUTPUT_VOLUMES
void SourceOutputWidget::executeVolumeUpdate() {
pa_operation* o;
if (!(o = pa_context_set_source_output_volume(get_context(), index, &volume, NULL, NULL))) {
show_error(_("pa_context_set_source_output_volume() failed"));
return;
}
pa_operation_unref(o);
}
void SourceOutputWidget::onMuteToggleButton() {
StreamWidget::onMuteToggleButton();
if (updating)
return;
pa_operation* o;
if (!(o = pa_context_set_source_output_mute(get_context(), index, muteToggleButton->get_active(), NULL, NULL))) {
show_error(_("pa_context_set_source_output_mute() failed"));
return;
}
pa_operation_unref(o);
}
#endif
void SourceOutputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_source_output(get_context(), index, NULL, NULL))) {

View File

@ -38,6 +38,10 @@ public:
uint32_t index, clientIndex;
void setSourceIndex(uint32_t idx);
uint32_t sourceIndex();
#if HAVE_SOURCE_OUTPUT_VOLUMES
virtual void executeVolumeUpdate();
virtual void onMuteToggleButton();
#endif
virtual void onDeviceChangePopup();
virtual void onKill();