summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2011-09-23 08:21:07 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2011-09-23 08:21:07 +0530
commit8e359a8f710f4f80d2317ea191d429b252c199e7 (patch)
treebe4373682fefb791575e1d1d772c10acfffc2e25
parent681c996438a548a33346230347403f7ad1a724b9 (diff)
source: Only autosuspend network sources
This makes sure we inhibit autosuspend only for network sources (which was the main purpose of adding autosuspend, since constantly monitoring those is network heavy).
-rw-r--r--src/mainwindow.cc10
-rw-r--r--src/mainwindow.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 71b4d20..dc84682 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -394,11 +394,12 @@ static void read_callback(pa_stream *s, size_t length, void *userdata) {
w->updateVolumeMeter(pa_stream_get_device_index(s), pa_stream_get_monitor_stream(s), v);
}
-pa_stream* MainWindow::createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx = -1) {
+pa_stream* MainWindow::createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx = -1, bool suspend = false) {
pa_stream *s;
char t[16];
pa_buffer_attr attr;
pa_sample_spec ss;
+ pa_stream_flags_t flags;
ss.channels = 1;
ss.format = PA_SAMPLE_FLOAT32;
@@ -421,7 +422,10 @@ pa_stream* MainWindow::createMonitorStreamForSource(uint32_t source_idx, uint32_
pa_stream_set_read_callback(s, read_callback, this);
pa_stream_set_suspended_callback(s, suspended_callback, this);
- if (pa_stream_connect_record(s, t, &attr, (pa_stream_flags_t) (PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND|PA_STREAM_DONT_MOVE|PA_STREAM_PEAK_DETECT|PA_STREAM_ADJUST_LATENCY)) < 0) {
+ flags = (pa_stream_flags_t) (PA_STREAM_DONT_MOVE | PA_STREAM_PEAK_DETECT | PA_STREAM_ADJUST_LATENCY |
+ (suspend ? PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND : PA_STREAM_NOFLAGS));
+
+ if (pa_stream_connect_record(s, t, &attr, flags) < 0) {
show_error(_("Failed to connect monitoring stream"));
pa_stream_unref(s);
return NULL;
@@ -459,7 +463,7 @@ void MainWindow::updateSource(const pa_source_info &info) {
w->setBaseVolume(info.base_volume);
if (pa_context_get_server_protocol_version(get_context()) >= 13)
- createMonitorStreamForSource(info.index);
+ createMonitorStreamForSource(info.index, -1, !!(info.flags & PA_SOURCE_NETWORK));
}
w->updating = true;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index dd8df6c..8f779b3 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -89,7 +89,7 @@ public:
void setConnectionState(gboolean connected);
void updateDeviceVisibility();
void reallyUpdateDeviceVisibility();
- pa_stream* createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx);
+ pa_stream* createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx, bool suspend);
void createMonitorStreamForSinkInput(SinkInputWidget* w, uint32_t sink_idx);
void setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *name);