Skip to main content

Notice

If you are using a Hotmail or Outlook email address, please change it now, as Microsoft is rejecting all email from our service outright.
Topic: foo_out_pulse - pulseaudio output (Read 2501 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: foo_out_pulse - pulseaudio output

Reply #25
If that works, is there any other output in the foobar console when it fails? Could you try with release 0.1 from github?

Thanks for the suggestion, but mpv also didn't work. I got this message: "[ao/pulse] The stream is suspended. Bailing out."

There probably is something wrong with my pulseaudio config, even though I didn't touch it before.

Re: foo_out_pulse - pulseaudio output

Reply #26
I just realised that you can use the pulse cookie to authenticate, you just need to copy or link it into your wine prefix. So you don't need to use the 'auth-ip-acl=' option in Pulseaudio's configuration, which is a bit much better from a security perspective. See the updated setup instructions in the readme

Re: foo_out_pulse - pulseaudio output

Reply #27
Try killing two modules in your system default.pa configuration, module-role-cork and module-suspend-on-idle, by commenting out the two modules. Then you can use "pacmd unload-module <module-name>" to unload those two modules from the current instance.

Re: foo_out_pulse - pulseaudio output

Reply #28
After some digging I was able to fix the issue. On my system there are two pulseaudio instances: one launched under my user and another for gdm. I had to disable the gdm instance and then I could connect via foobar2000.

The component works but unfortunately I still get some occasional audio pops when switching windows or desktops.

Re: foo_out_pulse - pulseaudio output

Reply #29
I still get some occasional audio pops when switching windows or desktops.

That's a very extreme version of that problem, does that happen with other apps or just foobar? Switching windows is a pretty lightweight activity

Re: foo_out_pulse - pulseaudio output

Reply #30
That's a very extreme version of that problem, does that happen with other apps or just foobar? Switching windows is a pretty lightweight activity

I happens only with foobar, but I guess it may be related to Wine. However, it's not constant. Sometimes the playback is flawless no matter what but other times it gets sensitive on CPU spikes it seems.

I saw similar reports of foobar audio issues under Wine and I was trying to find a way to bypass wineaudio or something. It's not so bad so I guess I can live with it.

 

Re: foo_out_pulse - pulseaudio output

Reply #31
The intention of this component was definitely to try and fix that. Wine does seem to have some problems with audio but this bypasses the normal wine audio stack completely. Of course there still could be problems but as long as foobar doesn't get hung up by Wine for longer than the buffer length, in theory there shouldn't be any dropouts, but clearly it's not helping as much as I hoped. You could try increasing the buffer in foobar's Output settings (as this directly controls the Pulseaudio buffer) and check how long the buffer is when it's playing something, running pactl list sink-inputs and looking for "Buffer Latency".

Another option to bypass Wine's audio stack is to use the UPnP media renderer output and have a receiver running on the same machine. The only downside is that visualisations won't work.

Re: foo_out_pulse - pulseaudio output

Reply #32
The intention of this component was definitely to try and fix that. Wine does seem to have some problems with audio but this bypasses the normal wine audio stack completely. Of course there still could be problems but as long as foobar doesn't get hung up by Wine for longer than the buffer length, in theory there shouldn't be any dropouts, but clearly it's not helping as much as I hoped. You could try increasing the buffer in foobar's Output settings (as this directly controls the Pulseaudio buffer) and check how long the buffer is when it's playing something, running pactl list sink-inputs and looking for "Buffer Latency".

Another option to bypass Wine's audio stack is to use the UPnP media renderer output and have a receiver running on the same machine. The only downside is that visualisations won't work.

I investigated the problem further. Indeed, it does NOT happen only with foobar but with any audio player! I listen mostly to foobar on this machine, so I assumed it was related to it.

So now to fix the general audio problem I found some suggestions to change scheduler settings in Pulseaudio. I tried and it seemed to have fixed the issue (so far). Even if it comes back, now I know where the problem might be. Thanks a lot for your help!

Re: foo_out_pulse - pulseaudio output

Reply #33
So now to fix the general audio problem I found some suggestions to change scheduler settings in Pulseaudio. I tried and it seemed to have fixed the issue (so far). Even if it comes back, now I know where the problem might be. Thanks a lot for your help!

Yep, changing the scheduler is necessary for me to get problem-free playback too. Glad it's working!

Re: foo_out_pulse - pulseaudio output

Reply #34
I released a small update with two fixes.

One is that I was noticing occasional crashes when stopping playback, where foobar would just instantly quit and not run the crash reporter. As far as I can tell it's due to a bug in the Windows code in Pulseaudio. For the moment I have added a workaround and it seems more stable for me.

The other change is that you can now configure the prebuffer length (amount of audio send to Pulseaudio before playback starts), and the default is shorter. Before, pulseaudio was left to choose a value automatically and it seemed to always choose the largest possible amount. For most files this wasn't noticeable as foobar could quickly decode enough audio. But for certain files, especially video where foobar is slower to decode, it would result in slow start of playback and slow seeking.

Download

Re: foo_out_pulse - pulseaudio output

Reply #35
Hi.  I'm trying this component out for the first time.  When I try to play, I get "Error: Pulseaudio: connection failed: Access denied" in the console.  PulseAudio is running (only once), 'pactl list' shows a bunch of stuff.  The 'mpv' test command mentioned earlier works fine.  Was there some other fix I've missed?  Thanks.

Re: foo_out_pulse - pulseaudio output

Reply #36
Hi.  I'm trying this component out for the first time.  When I try to play, I get "Error: Pulseaudio: connection failed: Access denied" in the console.  PulseAudio is running (only once), 'pactl list' shows a bunch of stuff.  The 'mpv' test command mentioned earlier works fine.  Was there some other fix I've missed?  Thanks.

Did you follow the instructions in the readme about copying the pulseaudio cookie into your wine prefix?

Re: foo_out_pulse - pulseaudio output

Reply #37
Did you follow the instructions in the readme about copying the pulseaudio cookie into your wine prefix?

Hmmm.  A file already existed at the destination.  So, I'm guessing that the 'ln -s' failed and I didn't notice somehow.  Anyway, the symlink is there now, but I'm getting the same result after restarting pulse and foobar.

Re: foo_out_pulse - pulseaudio output

Reply #38
OK, maybe try copying the file first instead of linking in case Wine isn't following symlinks. And, I'm pretty sure the location I give is where it will look for the cookie, but you could also try "C:\Users\<you>\.pulse-cookie" which I have seen it use in an older version. Maybe PA's cookie on Linux is in a different place? Seems unlikely but you could check "pulseaudio --dump-conf | grep cookie"

Failing that I'm not sure, you could also use IP-based authentication instead by changing the module parameters like:

load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1

Note that it's not very secure as it allows any user access to your pulseaudio daemon, or maybe even other things that shouldn't be able to access it.

Re: foo_out_pulse - pulseaudio output

Reply #39
OK, maybe try copying the file first instead of linking in case Wine isn't following symlinks. And, I'm pretty sure the location I give is where it will look for the cookie, but you could also try "C:\Users\<you>\.pulse-cookie" which I have seen it use in an older version.

No dice with either of these.  The fact there was a file in the Windows location suggests it was looking there, too.

Maybe PA's cookie on Linux is in a different place? Seems unlikely but you could check "pulseaudio --dump-conf | grep cookie"

I think you're onto something!  The ~/.config/pulse/cookie file has an old date.  And, while, 'pulseaudio --dump-conf' works, there is no mention of a cookie.

Re: foo_out_pulse - pulseaudio output

Reply #40
Hmmm.  I removed the cookie, then restarted pulseaudio.  It created a new cookie in that location.  It's got to be the right file.

Re: foo_out_pulse - pulseaudio output

Reply #41
You can check if foobar is trying to load a cookie, using something like this (but change the paths to match your wine prefix):

Code: [Select]
WINEPREFIX=/path/to/your/wine/prefix strace -e file "/path/to/your/wine/prefix/drive_c/Program Files/foobar2000/foobar2000.exe" 2>&1 | grep -i cookie

If they match then, I am stumped. I'd just try the IP auth method.

Re: foo_out_pulse - pulseaudio output

Reply #42
Code: [Select]
WINEPREFIX=/home/dave/.wine/ strace -e file wine "/home/dave/.wine/drive_c/users/dave/AppData/Local/foobar2000/foobar2000.exe" 2>&1 | grep -i cookie
stat64("/home/dave/.wine/dosdevices/c:/users/dave/Cookies", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
lstat64("/home/dave/.wine/dosdevices/c:/users/dave/Cookies", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
Failed to load cookie file from cookie: Unknown error 10009

Same result no matter whether it's a symlink or a copy of the file.   I also changed permissions on the copy to 644 to make sure there was no permissions problem.  I already tried the IP auth method you mentioned.  It did work, but I needed to see if I could work out the security implications before I set it permanently.

Re: foo_out_pulse - pulseaudio output

Reply #43
I have a feeling there is nothing wrong with the plugin code.  Here is more context from a full log.

Code: [Select]
00c3:fixme:msvcp:_Locinfo__Locinfo_ctor_cat_cstr (0891F4FC 1 C) semi-stub
00c3:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
00c3:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
00c3:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
Failed to load cookie file from cookie: Unknown error 10009

I would be interested to see what strace shows for a working installation.

Re: foo_out_pulse - pulseaudio output

Reply #44
Hmm, there is no output from strace there for the cookie so it's not reading the file. When I run it I get:

openat(AT_FDCWD, "/home/sam/.config/pulse/cookie", O_RDONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 80

10009 seems to mean "The file handle supplied is not valid", maybe the path is inaccessible or wrong, or it could just be a bug in the pulseaudio code even if the path is correct. Are you sure the path is definitely right, ie /home/dave/.wine/drive_c/users/dave/.config/pulse/cookie ? I can't really think of anything else to try at the moment but I will reply if I do.

Re: foo_out_pulse - pulseaudio output

Reply #45
Code: [Select]
$ ls -l /home/dave/.wine/drive_c/users/dave/.config/pulse/cookie
-rw-r--r-- 1 dave dave 256 Sep 28 14:04 /home/dave/.wine/drive_c/users/dave/.config/pulse/cookie

As long as pulseaudio is running as me, and 'ps' says it is, I don't see how the path could be inaccessible.  It's accessible to me.  I can also see the file in Wine Explorer and open it in Wine Notepad, exactly in the Windows path shown in the strace.  I wonder if the path isn't getting translated from Windows to linux where it should.  That's what I was hoping to see from a working strace.  But I don't know if the messages are comparable.

In the Wine Console:

Code: [Select]
H:\>dir C:\users\dave\.config\pulse\cookie
Volume in drive C has no label.
Volume Serial Number is c9e2-747b

Directory of C:\users\dave\.config\pulse

 9/28/2020   2:04 PM           256  cookie
       1 file                       256 bytes
       0 directories    239,606,796,288 bytes free

Same thing with 'type' shows unreadable garbage, obviously, but it does read the file. The following is from 'WINEDEBUG=warn+all' without strace:

Code: [Select]
00c7:warn:winsock:wsaErrno errno 115, (Operation now in progress).
00c7:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\.pulse\\client.conf" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:\\users\\dave\\.pulse\\client.conf" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\.config\\pulse\\client.conf" not found (c0000034)
00c7:warn:file:CreateFileW Unable to create file L"C:\\users\\dave\\.config/pulse\\client.conf" (status c0000034)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (2)
00c7:err:msvcrt:msvcrt_get_flags incorrect mode flag: e
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\foobar2000\\user-components\\foo_out_pulse\\pulse\\etc\\pulse\\client.conf" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:\\users\\dave\\AppData\\Local\\foobar2000\\user-components\\foo_out_pulse\\pulse\\etc\\pulse\\client.conf" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:ntdll:FILE_CreateFile L"\\??\\Z:\\usr\\i686-w64-mingw32\\share\\locale\\locale.alias" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"/usr/i686-w64-mingw32/share/locale/locale.alias" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\share\\locale\\en_US.utf8\\LC_MESSAGES\\pulseaudio.mo" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:/users/dave/AppData/Local/share/locale/en_US.utf8/LC_MESSAGES/pulseaudio.mo" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\share\\locale\\en_US\\LC_MESSAGES\\pulseaudio.mo" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:/users/dave/AppData/Local/share/locale/en_US/LC_MESSAGES/pulseaudio.mo" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\share\\locale\\en.utf8\\LC_MESSAGES\\pulseaudio.mo" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:/users/dave/AppData/Local/share/locale/en.utf8/LC_MESSAGES/pulseaudio.mo" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\share\\locale\\en\\LC_MESSAGES\\pulseaudio.mo" not found (c000003a)
00c7:warn:file:CreateFileW Unable to create file L"C:/users/dave/AppData/Local/share/locale/en/LC_MESSAGES/pulseaudio.mo" (status c000003a)
00c7:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (3)
00c7:warn:winsock:wsaErrno errno 115, (Operation now in progress).
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
00c8:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\.pulse-cookie" not found (c0000034)
00c8:warn:file:CreateFileW Unable to create file L"C:\\users\\dave\\.pulse-cookie" (status c0000034)
00c8:warn:msvcrt:MSVCRT__wsopen_dispatch :failed-last error (2)
00c8:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\.config\\pulse" not found (c0000035)
Failed to read cookie file 'C:\users\dave\.config\pulse\cookie': Unknown error 10009
Failed to load cookie file from cookie: Unknown error 10009
00c8:warn:winsock:WS2_recv_base  -> ERROR 10035

Re: foo_out_pulse - pulseaudio output

Reply #46
Everything looks right to me..

Could you try with the first version from github, 0.1?

Re: foo_out_pulse - pulseaudio output

Reply #47
Could you try with the first version from github, 0.1?

Sure!  Got this in the fb2k console:
Code: [Select]
Pulseaudio: Using Windows libpulse
Error: Pulseaudio: connection failed
Error: Pulseaudio: failed to connect
Unrecoverable playback error: Audio device invalidated

I also got a dialog that said "Unrecoverable playback error: Audio device invalidated".  Wine log and strace look about the same.

Here is something interesting.  I've been trying to turn up the pulseaudio client logging, so I created a 'client.conf' file in the same directory.  Since the entries below no longer appear in the log, I've concluded that it is finding and reading the file.

Code: [Select]
00bf:warn:ntdll:FILE_CreateFile L"\\??\\C:\\users\\dave\\AppData\\Local\\foobar2000\\user-components\\foo_out_pulse\\pulse\\etc\\pulse\\client.conf" not found (c000003a)
00bf:warn:file:CreateFileW Unable to create file L"C:\\users\\dave\\AppData\\Local\\foobar2000\\user-components\\foo_out_pulse\\pulse\\etc\\pulse\\client.conf" (status c000003a)

Since I'm not getting any more messages from the pulseaudio client, judging from the code, that could mean that it is successfully opening the cookie, but failing to read it.  On the other hand, I'm looking at v13 pulseaudio code, while you had to use an old version, and I don't know that it's really taking my logging change, anyway.  Unless you're willing to add some debug code to the pulseaudio source that you're compiling, I'm not sure how else to debug this.

Re: foo_out_pulse - pulseaudio output

Reply #48
Version 0.1 of the plugin uses pulseaudio 1.1 built by opensuse and the current version uses pulseaudio 13.0 built by me (so I was thinking there could be an issue with that build), but you can mix and match the libary dlls between versions of the plugin, the ABI is the same. I'm not sure why 0.1 won't connect, does it not connect with IP auth enabled either?

The code printing that error in PA looks a bit strange to me - it opens a file handle successfully and then as soon as it tries to read from it it gets 'file handle not valid'. Maybe I'm reading it wrong though. I'm not really sure what logging to add to that:

https://github.com/pulseaudio/pulseaudio/blob/4e3a080d7699732be9c522be9a96d851f97fbf11/src/pulsecore/authkey.c#L97

Could you give me your distribution/version and wine version? Maybe I can try in a VM.

Re: foo_out_pulse - pulseaudio output

Reply #49
Version 0.1 of the plugin uses pulseaudio 1.1 built by opensuse and the current version uses pulseaudio 13.0 built by me (so I was thinking there could be an issue with that build), but you can mix and match the libary dlls between versions of the plugin, the ABI is the same. I'm not sure why 0.1 won't connect, does it not connect with IP auth enabled either?

Ah, I overlooked the part where you said you got v13 to build!  0.1 works with IP auth.  Without, the output looks more or less the same as your build.

Could you give me your distribution/version and wine version? Maybe I can try in a VM.

I'm certain you don't want to go there.  I'm running gentoo.  It would take considerable time and effort to set it all up.  Wine version is wine-vanilla 5.0.1.

If you're willing, these are the kinds of changes I had in mind.  I've made no attempt to run this through a compiler, so please forgive any syntax errors.

Code: [Select]
--- authkey.c.orig	2020-09-28 19:40:28.894629026 -0700
+++ authkey.c 2020-09-28 20:02:28.404587200 -0700
@@ -76,24 +76,29 @@
     int unlock = 0, ret = -1;
     ssize_t r;
 
+    pa_log("load() function, cookie filename: %s", fn);
     pa_assert(fn);
     pa_assert(data);
     pa_assert(length > 0);
 
     if (create)
+        pa_log("About to call pa_make_secure_parent_dir()");
         pa_make_secure_parent_dir(fn, pa_in_system_mode() ? 0755U : 0700U, -1, -1, false);
 
+    pa_log("About to call pa_open_cloexec()");
     if ((fd = pa_open_cloexec(fn, (create ? O_RDWR|O_CREAT : O_RDONLY)|O_BINARY, S_IRUSR|S_IWUSR)) < 0) {
-
         if (!create || errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) {
-            pa_log_warn("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
+            pa_log("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
             goto finish;
         } else
+            pa_log("pa_open_cloexec() else condition");
             writable = 0;
     }
 
+    pa_log("About to call pa_lock_fd()");
     unlock = pa_lock_fd(fd, 1) >= 0;
 
+    pa_log("About to call pa_loop_read()");
     if ((r = pa_loop_read(fd, data, length, NULL)) < 0) {
         pa_log("Failed to read cookie file '%s': %s", fn, pa_cstrerror(errno));
         goto finish;
@@ -168,21 +173,26 @@
     ssize_t r;
     char *p;
 
+    pa_log("pa_authkey_save() function, cookie filename: %s", fn);
     pa_assert(fn);
     pa_assert(data);
     pa_assert(length > 0);
 
     if ((ret = normalize_path(fn, &p)) < 0)
         return ret;
+    pa_log("Normalized path: %s", fn);
 
+    pa_log("About to call pa_open_cloexec()");
     if ((fd = pa_open_cloexec(p, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0) {
-        pa_log_warn("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
+        pa_log("Failed to open cookie file '%s': %s", fn, pa_cstrerror(errno));
         ret = -1;
         goto finish;
     }
 
+    pa_log("About to call pa_lock_fd()");
     unlock = pa_lock_fd(fd, 1) >= 0;
 
+    pa_log("About to call pa_loop_write()");
     if ((r = pa_loop_write(fd, data, length, NULL)) < 0 || (size_t) r != length) {
         pa_log("Failed to read cookie file '%s': %s", fn, pa_cstrerror(errno));
         ret = -1;

 
SimplePortal 1.0.0 RC1 © 2008-2020