示例#1
0
文件: context.cpp 项目: KDE/plasma-pa
void Context::streamRestoreWrite(const pa_ext_stream_restore_info *info)
{
    if (!PAOperation(pa_ext_stream_restore_write(m_context,
                                                 PA_UPDATE_REPLACE,
                                                 info,
                                                 1,
                                                 true,
                                                 nullptr,
                                                 nullptr))) {
        qCWarning(PLASMAPA) << "pa_ext_stream_restore_write failed";
    }
}
示例#2
0
void PulseAudioSystem::stream_restore_read_callback(pa_context *c, const pa_ext_stream_restore_info *i, int eol, void *userdata) {
	PulseAudioSystem *pas = reinterpret_cast<PulseAudioSystem *>(userdata);

	if (eol == 0) {
		QString name = QLatin1String(i->name);

		// were we looking for this restoration?
		if (pas->qhMissingSinks.contains(name)) {
			// make sure it still has the volume we gave it
			if (pa_cvolume_equal(&pas->qhMissingSinks[name].attenuated_volume, &i->volume) != 0) {
				// update the stream restore record
				pa_ext_stream_restore_info restore = *i;
				restore.volume = pas->qhMissingSinks[name].normal_volume;
				pas->iRemainingOperations++;
				pa_operation_unref(pa_ext_stream_restore_write(c, PA_UPDATE_REPLACE, &restore, 1, 1, restore_volume_success_callback, pas));
			}

			pas->qhMissingSinks.remove(name);
		}

	} else if (eol < 0) {
		qWarning("PulseAudio: Couldn't read stream restore database.");
		pas->qhMissingSinks.clear();

	} else {
		// verify missing list is empty
		if (pas->qhMissingSinks.count() > 0) {
			qWarning("PulseAudio: Failed to match %d stream(s).", pas->qhMissingSinks.count());
			pas->qhMissingSinks.clear();
		}

		// trigger the volume completion callback;
		// necessary so that shutdown actions are called
		restore_volume_success_callback(c, 1, pas);
	}
}
void PulseAudioSinksManager::pulseAudioMixerControlStreamRestoreCallback (pa_context *ctx, const pa_ext_stream_restore_info  *info,
                                     int eol, void *userdata) {
    pa_ext_stream_restore_info new_info;
    PulseAudioSinksManager* sinksManager = (PulseAudioSinksManager*)userdata;
    if (eol) return;

    new_info.name = info->name;
    new_info.channel_map = info->channel_map;
    new_info.volume = info->volume;
    new_info.mute = info->mute;
    std::string device = sinksManager->defaultDevice.toStdString();
    new_info.device = device.c_str();

    PaOperation op(pa_ext_stream_restore_write (ctx,PA_UPDATE_REPLACE,
                                     &new_info, 1,1, NULL, NULL));
    if (!op) {
            //g_warning ("pa_ext_stream_restore_write() failed: %s",
              //         pa_strerror (pa_context_errno (control->priv->pa_context)));
            return;
    }

    //g_debug ("Changed default device for %s to %s", info->name, info->device);

}