diff -up phonon-4.3.80/phonon/CMakeLists.txt.old_pa phonon-4.3.80/phonon/CMakeLists.txt --- phonon-4.3.80/phonon/CMakeLists.txt.old_pa 2009-12-03 13:29:35.000000000 -0600 +++ phonon-4.3.80/phonon/CMakeLists.txt 2010-01-22 09:52:53.195187362 -0600 @@ -8,15 +8,21 @@ endif (PHONON_BUILD_EXAMPLES) add_subdirectory(experimental) -set(PULSEAUDIO_MINIMUM_VERSION "0.9.21") +set(PULSEAUDIO_MINIMUM_VERSION "0.9.15") macro_optional_find_package(PulseAudio) +# PULSEAUDIO_DEVICE_MANAGER feature check could be moved to FindPulseAudio.cmake, hint hint. -- Rex +macro_ensure_version("0.9.21" "${PULSEAUDIO_VERSION}" PULSEAUDIO_DEVICE_MANAGER) macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "A cross-platform, networked sound server." "http://www.pulseaudio.org" FALSE "" "Allows audio playback via the PulseAudio soundserver when it is running") macro_optional_find_package(GLIB2) macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the pulseaudio for Phonon" "http://www.gtk.org/download/" FALSE) + if (GLIB2_FOUND AND PULSEAUDIO_FOUND) add_definitions(-DHAVE_PULSEAUDIO) include_directories(${GLIB2_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIR}) + if (PULSEAUDIO_DEVICE_MANAGER) + add_definitions(-DHAVE_PULSEAUDIO_DEVICE_MANAGER) + endif(PULSEAUDIO_DEVICE_MANAGER) else(GLIB2_FOUND AND PULSEAUDIO_FOUND) set(PULSEAUDIO_INCLUDE_DIR "") set(PULSEAUDIO_LIBRARY "") diff -up phonon-4.3.80/phonon/pulsesupport.cpp.old_pa phonon-4.3.80/phonon/pulsesupport.cpp --- phonon-4.3.80/phonon/pulsesupport.cpp.old_pa 2009-12-03 13:29:35.000000000 -0600 +++ phonon-4.3.80/phonon/pulsesupport.cpp 2010-01-22 09:48:15.699935986 -0600 @@ -30,7 +30,9 @@ #include #include #include -#include +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER +# include +#endif #endif // HAVE_PULSEAUDIO #include "pulsesupport_p.h" @@ -151,7 +153,34 @@ static QMap s_captureStreamIndexMap; static QMap s_captureStreamMoveQueue; +static void fakeSingleOutputDevice() +{ + // OK so we don't have the device manager extension, but we can show a single device and fake it. + int index; + s_outputDeviceIndexes.clear(); + s_outputDevices.clear(); + s_outputDevicePriorities.clear(); + index = s_deviceIndexCounter++; + s_outputDeviceIndexes.insert("sink:default", index); + s_outputDevices.insert(index, AudioDevice("sink:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + s_outputDevicePriorities[cat].insert(0, index); + } + + s_captureDeviceIndexes.clear(); + s_captureDevices.clear(); + s_captureDevicePriorities.clear(); + index = s_deviceIndexCounter++; + s_captureDeviceIndexes.insert("source:default", index); + s_captureDevices.insert(index, AudioDevice("source:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); + for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { + Phonon::Category cat = static_cast(i); + s_captureDevicePriorities[cat].insert(0, index); + } +} +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER static void ext_device_manager_subscribe_cb(pa_context *, void *); static void ext_device_manager_read_cb(pa_context *c, const pa_ext_device_manager_info *info, int eol, void *userdata) { Q_ASSERT(c); @@ -171,30 +200,7 @@ static void ext_device_manager_read_cb(p if (eol < 0) { logMessage(QString("Failed to initialize device manager extension: %1").arg(pa_strerror(pa_context_errno(c)))); - // OK so we don't have the device manager extension, but we can show a single device and fake it. - int index; - s_outputDeviceIndexes.clear(); - s_outputDevices.clear(); - s_outputDevicePriorities.clear(); - index = s_deviceIndexCounter++; - s_outputDeviceIndexes.insert("sink:default", index); - s_outputDevices.insert(index, AudioDevice("sink:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); - for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { - Phonon::Category cat = static_cast(i); - s_outputDevicePriorities[cat].insert(0, index); - } - - s_captureDeviceIndexes.clear(); - s_captureDevices.clear(); - s_captureDevicePriorities.clear(); - index = s_deviceIndexCounter++; - s_captureDeviceIndexes.insert("source:default", index); - s_captureDevices.insert(index, AudioDevice("source:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0)); - for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) { - Phonon::Category cat = static_cast(i); - s_captureDevicePriorities[cat].insert(0, index); - } - + fakeSingleOutputDevice(); return; } @@ -369,6 +375,7 @@ static void ext_device_manager_read_cb(p } } } +#endif static void set_output_device(QString streamUuid) { @@ -550,12 +557,12 @@ static void subscribe_cb(pa_context *c, } } - static void ext_device_manager_subscribe_cb(pa_context *c, void *) { Q_ASSERT(c); pa_operation *o; PulseUserData *u = new PulseUserData; /** @todo Make some object to receive the info... */ +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER if (!(o = pa_ext_device_manager_read(c, ext_device_manager_read_cb, u))) { // We need to deal with failure on first iteration if (s_connectionEventloop) { @@ -566,6 +573,7 @@ static void ext_device_manager_subscribe return; } pa_operation_unref(o); +#endif // Register for the stream changes... @@ -584,6 +592,7 @@ static void context_state_callback(pa_co { Q_ASSERT(c); + logMessage(QString("context_state_callback %1").arg(pa_context_get_state(c))); switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: case PA_CONTEXT_CONNECTING: @@ -592,8 +601,18 @@ static void context_state_callback(pa_co break; case PA_CONTEXT_READY: +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER // Attempt to load things up ext_device_manager_subscribe_cb(c, NULL); +#else + s_pulseActive = true; + if (s_connectionEventloop) { + s_connectionEventloop->exit(0); + s_connectionEventloop = 0; + } + fakeSingleOutputDevice(); + ext_device_manager_subscribe_cb(c, NULL); +#endif break; case PA_CONTEXT_FAILED: @@ -665,6 +684,7 @@ PulseSupport::PulseSupport() if (pa_context_connect(s_context, NULL, static_cast(0), 0) >= 0) { pa_context_set_state_callback(s_context, &context_state_callback, s_connectionEventloop); // Now we block until we connect or otherwise... + logMessage("Entering eventloop..."); s_connectionEventloop->exec(); } #endif @@ -821,11 +841,13 @@ static void setDevicePriority(Category c } devices[list.size()] = NULL; +#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER pa_operation *o; if (!(o = pa_ext_device_manager_reorder_devices_for_role(s_context, role.toUtf8().constData(), (const char**)devices, NULL, NULL))) logMessage(QString("pa_ext_device_manager_reorder_devices_for_role() failed")); else pa_operation_unref(o); +#endif for (i = 0; i < list.size(); ++i) pa_xfree(devices[i]);