[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdemultimedia
From: Colin Guthrie <cguthrie () mandriva ! org>
Date: 2012-01-05 10:05:08
Message-ID: 20120105100508.D14C6AC890 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1271781 by cguthrie:
kmix: Add sound feedback for volume changes via libcanberra.
For now this is only available on the PulseAudio backend, but it should be \
somewhat trivial to do the same for the ALSA backend.
M +2 -0 CMakeLists.txt
M +22 -0 kmix/CMakeLists.txt
M +61 -0 kmix/backends/mixer_pulse.cpp
--- trunk/KDE/kdemultimedia/CMakeLists.txt #1271780:1271781
@@ -12,6 +12,8 @@
macro_optional_find_package(PulseAudio)
macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "PulseAudio Audio Server" \
"http://www.pulseaudio.org/" FALSE "0.9.12" "libpulse is needed to let KMix \
control PulseAudio") find_package(GLIB2)
+pkg_check_modules(CANBERRA libcanberra)
+macro_log_feature(CANBERRA_FOUND "libcanberra" "libcanberra audio library" \
"http://0pointer.de/lennart/projects/libcanberra/" FALSE "" "libcanberra is \
needed for kmix sound feedback") macro_optional_find_package(MusicBrainz3)
macro_log_feature(MUSICBRAINZ3_FOUND "MusicBrainz3" "A library that \
provides access to metadata lookup on the MusicBrainz server" \
"http://www.musicbrainz.org" FALSE "" "Music metadata lookup for KDE \
multimedia applications. You need version 3.x of libmusicbrainz, otherwise \
kscd will not be compiled.")
--- trunk/KDE/kdemultimedia/kmix/CMakeLists.txt #1271780:1271781
@@ -21,6 +21,17 @@
add_subdirectory( profiles )
#add_subdirectory( tests )
+if (HAVE_PULSE)
+ include_directories(${PULSEAUDIO_INCLUDE_DIR})
+endif (HAVE_PULSE)
+
+if (CANBERRA_FOUND)
+ add_definitions(-DHAVE_CANBERRA)
+
+ include_directories(${CANBERRA_INCLUDE_DIRS})
+endif (CANBERRA_FOUND)
+
+
set(kmix_adaptor_SRCS
dbus/dbusmixerwrapper.cpp
dbus/dbusmixsetwrapper.cpp
@@ -93,6 +104,9 @@
target_link_libraries(kdeinit_kmix ${PULSEAUDIO_LIBRARY} \
${PULSEAUDIO_MAINLOOP_LIBRARY} ${GLIB2_LIBRARIES}) endif (HAVE_PULSE)
+if (CANBERRA_FOUND)
+ target_link_libraries(kdeinit_kmix ${CANBERRA_LIBRARIES})
+endif (CANBERRA_FOUND)
install(TARGETS kdeinit_kmix DESTINATION ${LIB_INSTALL_DIR} )
@@ -129,6 +143,10 @@
target_link_libraries(kded_kmixd ${PULSEAUDIO_LIBRARY} \
${PULSEAUDIO_MAINLOOP_LIBRARY} ${GLIB2_LIBRARIES}) endif (HAVE_PULSE)
+if (CANBERRA_FOUND)
+ target_link_libraries(kded_kmixd ${CANBERRA_LIBRARIES})
+endif (CANBERRA_FOUND)
+
install(TARGETS kded_kmixd DESTINATION ${PLUGIN_INSTALL_DIR})
#target_link_libraries( kmixd kded_kmixd )
@@ -164,6 +182,10 @@
target_link_libraries(kdeinit_kmixctrl ${PULSEAUDIO_LIBRARY} \
${PULSEAUDIO_MAINLOOP_LIBRARY} ${GLIB2_LIBRARIES}) endif (HAVE_PULSE)
+if (CANBERRA_FOUND)
+ target_link_libraries(kdeinit_kmixctrl ${CANBERRA_LIBRARIES})
+endif (CANBERRA_FOUND)
+
########### next target ###############
add_subdirectory( plasma )
--- trunk/KDE/kdemultimedia/kmix/backends/mixer_pulse.cpp #1271780:1271781
@@ -31,6 +31,9 @@
#include <pulse/glib-mainloop.h>
#include <pulse/ext-stream-restore.h>
+#if defined(HAVE_CANBERRA)
+# include <canberra.h>
+#endif
#define HAVE_SOURCE_OUTPUT_VOLUMES PA_CHECK_VERSION(1,0,0)
@@ -48,6 +51,10 @@
static enum { UNKNOWN, ACTIVE, INACTIVE } s_pulseActive = UNKNOWN;
static int s_outstandingRequests = 0;
+#if defined(HAVE_CANBERRA)
+static ca_context *s_ccontext = NULL;
+#endif
+
QMap<int,Mixer_PULSE*> s_mixers;
typedef QMap<int,devinfo> devmap;
@@ -942,6 +949,15 @@
Q_ASSERT(s_mainloop);
connectToDaemon();
+
+#if defined(HAVE_CANBERRA)
+ int ret = ca_context_create(&s_ccontext);
+ if (ret < 0) {
+ kDebug(67100) << "Disabling Sound Feedback. Canberra \
context failed."; + s_ccontext = NULL;
+ } else
+ ca_context_set_driver(s_ccontext, "pulse");
+#endif
}
kDebug(67100) << "PulseAudio status: " << (s_pulseActive==UNKNOWN \
? "Unknown (bug)" : (s_pulseActive==ACTIVE ? "Active" : "Inactive")); @@ \
-960,6 +976,13 @@
--refcount;
if (0 == refcount)
{
+#if defined(HAVE_CANBERRA)
+ if (s_ccontext) {
+ ca_context_destroy(s_ccontext);
+ s_ccontext = NULL;
+ }
+#endif
+
if (s_context) {
pa_context_unref(s_context);
s_context = NULL;
@@ -1079,6 +1102,44 @@
}
pa_operation_unref(o);
+#if defined(HAVE_CANBERRA)
+ if (s_ccontext) {
+ int playing = 0;
+ int cindex = 2; // Note "2" is simply the index we've \
picked. It's somewhat irrelevant. +
+
+ ca_context_playing(s_ccontext, cindex, &playing);
+
+ // NB Depending on how this is desired to work, we may \
want to simply + // skip playing, or cancel the \
currently playing sound and play our + // new one... for \
now, let's do the latter. + if (playing) {
+ ca_context_cancel(s_ccontext, cindex);
+ playing = 0;
+ }
+
+ if (!playing) {
+ char dev[64];
+
+ snprintf(dev, sizeof(dev), "%lu", (unsigned long) \
iter->index); + ca_context_change_device(s_ccontext, \
dev); +
+ // Ideally we'd use something like \
ca_gtk_play_for_widget()... + ca_context_play(
+ s_ccontext,
+ cindex,
+ CA_PROP_EVENT_DESCRIPTION, i18n("Volume \
Control Feedback Sound").toUtf8().constData(), + \
CA_PROP_EVENT_ID, "audio-volume-change", + \
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", + \
CA_PROP_CANBERRA_ENABLE, "1", + NULL
+ );
+
+ ca_context_change_device(s_ccontext, NULL);
+ }
+ }
+#endif
+
return 0;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic