diff options
author | Maarten Bosmans <mkbosmans@gmail.com> | 2011-01-26 11:44:30 +0100 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2011-03-03 13:52:21 +0000 |
commit | 5997290d1e0298ddd91444e19a5ad66b64c27d34 (patch) | |
tree | 05aec7f037d4f12e1d78e71eeae0431ecd63e6b9 | |
parent | 73e57023ec925af42c8018da8c195e819eb288f7 (diff) |
Add DONT_INHIBIT_AUTO_SUSPEND flag to monitor streams
-rw-r--r-- | src/mainwindow.cc | 45 | ||||
-rw-r--r-- | src/mainwindow.h | 2 |
2 files changed, 10 insertions, 37 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 4995b53..60137b6 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -347,7 +347,7 @@ 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); } -void MainWindow::createMonitorStreamForSource(uint32_t source_idx) { +pa_stream* MainWindow::createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx = -1) { pa_stream *s; char t[16]; pa_buffer_attr attr; @@ -365,29 +365,24 @@ void MainWindow::createMonitorStreamForSource(uint32_t source_idx) { if (!(s = pa_stream_new(get_context(), _("Peak detect"), &ss, NULL))) { show_error(_("Failed to create monitoring stream")); - return; + return NULL; } + if (stream_idx != (uint32_t) -1) + pa_stream_set_monitor_stream(s, stream_idx); + 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_MOVE|PA_STREAM_PEAK_DETECT|PA_STREAM_ADJUST_LATENCY)) < 0) { + 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) { show_error(_("Failed to connect monitoring stream")); pa_stream_unref(s); - return; + return NULL; } + return s; } void MainWindow::createMonitorStreamForSinkInput(SinkInputWidget* w, uint32_t sink_idx) { - char t[16]; - pa_buffer_attr attr; - pa_sample_spec ss; - uint32_t monitor_source_idx; - - ss.channels = 1; - ss.format = PA_SAMPLE_FLOAT32; - ss.rate = 25; - if (!sinkWidgets.count(sink_idx)) return; @@ -396,29 +391,7 @@ void MainWindow::createMonitorStreamForSinkInput(SinkInputWidget* w, uint32_t si w->peak = NULL; } - monitor_source_idx = sinkWidgets[sink_idx]->monitor_index; - - memset(&attr, 0, sizeof(attr)); - attr.fragsize = sizeof(float); - attr.maxlength = (uint32_t) -1; - - snprintf(t, sizeof(t), "%u", monitor_source_idx); - - if (!(w->peak = pa_stream_new(get_context(), _("Peak detect"), &ss, NULL))) { - show_error(_("Failed to create monitoring stream")); - return; - } - - pa_stream_set_monitor_stream(w->peak, w->index); - pa_stream_set_read_callback(w->peak, read_callback, this); - pa_stream_set_suspended_callback(w->peak, suspended_callback, this); - - if (pa_stream_connect_record(w->peak, t, &attr, (pa_stream_flags_t) (PA_STREAM_DONT_MOVE|PA_STREAM_PEAK_DETECT|PA_STREAM_ADJUST_LATENCY)) < 0) { - show_error(_("Failed to connect monitoring stream")); - pa_stream_unref(w->peak); - w->peak = NULL; - return; - } + w->peak = createMonitorStreamForSource(sinkWidgets[sink_idx]->monitor_index, w->index); } void MainWindow::updateSource(const pa_source_info &info) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 2b2dc5c..a1e56f0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -82,7 +82,7 @@ public: void setConnectionState(gboolean connected); void updateDeviceVisibility(); void reallyUpdateDeviceVisibility(); - void createMonitorStreamForSource(uint32_t source_idx); + pa_stream* createMonitorStreamForSource(uint32_t source_idx, uint32_t stream_idx); void createMonitorStreamForSinkInput(SinkInputWidget* w, uint32_t sink_idx); void setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *name); |