@@ -760,7 +760,7 @@ void SessionManager::playLoginSound()
760760 return ;
761761
762762 qInfo () << " play system sound: desktop-login" ;
763- playSound (" desktop-login" );
763+ playSoundAutoLogin (" desktop-login" );
764764
765765 // 播放后创建文件
766766 QFile file (markFile);
@@ -794,7 +794,7 @@ void SessionManager::playLogoutSound()
794794 // 始终在注销前退出pulseaudio服务
795795 stopPulseAudioService ();
796796
797- playSound (" desktop-logout" );
797+ playSoundLogout (" desktop-logout" );
798798}
799799
800800void SessionManager::setDPMSMode (bool on)
@@ -892,7 +892,19 @@ void SessionManager::emitCurrentUidChanged(QString uid)
892892 // 这个属性不会变化
893893}
894894
895- inline void SessionManager::playSound (const QString &event)
895+ // 自动登录时session已经启动了,不能使用alsa,会和通过pa或者pipewire抢占通道,导致音频模块异常
896+ inline void SessionManager::playSoundAutoLogin (const QString &event)
897+ {
898+ QDBusInterface soundPlayerInter (" org.deepin.dde.SoundEffect1" , " /org/deepin/dde/SoundEffect1" ,
899+ " org.deepin.dde.SoundEffect1" , QDBusConnection::sessionBus ());
900+ QDBusMessage reply = soundPlayerInter.call (" PlaySound" , event);
901+ if (reply.type () == QDBusMessage::ErrorMessage) {
902+ qWarning () << " Failed to call Play:" << event << reply.errorMessage ();
903+ }
904+ }
905+
906+ // 注销时,不能使用pa或者pipewire,因为session可能会退出,导致没有音效,应该直接使用alsa
907+ inline void SessionManager::playSoundLogout (const QString &event)
896908{
897909 QDBusInterface soundPlayerInter (" org.deepin.dde.SoundThemePlayer1" , " /org/deepin/dde/SoundThemePlayer1" ,
898910 " org.deepin.dde.SoundThemePlayer1" , QDBusConnection::systemBus ());
0 commit comments