[pulseaudio-discuss] Bluetooth audio connection issue for multi-user login

2023-05-06 Thread Chengyi Zhao
Hi guys,

In Debian system, if I log in multiple users, the system will start multiple 
PulseAudio processes at user level,
when establishing Bluetooth audio connection with Bluetooth headset, there will 
be a random use of a particular
PulseAudio to start SCO connection, which cannot guarantee the current user can 
use Bluetooth audio.

How can we deal with this issue? Thanks a lot!

Cheers,
Chengyi


Re: [pulseaudio-discuss] why do I use pacat/parec to record monitor device always at the same volume?

2021-11-18 Thread Chengyi Zhao

Thanks a lot!

I found that the default volume of the monitor device is 50%. This is a 
very strange phenomenon. Is it possible to make the volume of the 
monitor device follow the volume of the monitored device?


Thanks,
Chengyi

On 2021/11/18 下午10:06, guest271314 wrote:
I have used parec to capture system audio and have not noticed that 
volume is always the same. The resulting volume of the recording is 
reflective of the system volume, for example, set at pavucontrol.


On Thu, Nov 18, 2021 at 5:26 AM Chengyi Zhao <mailto:zhaochen...@uniontech.com>> wrote:


Hi guys,

Would you please tell me why I use pacat/parec to record monitor device
always at the same volume?

I use pacat/parec to record the sound played by the video player, but
the volume is always the same. Is there any way to make the recording
volume consistent with the playback volume?

Example:
pacat --record -d alsa_output.pci-_01_00.1.hdmi-stereo.monitor >
dump.raw

Thanks you very much!

Best Regards,
Chengyi








[pulseaudio-discuss] why do I use pacat/parec to record monitor device always at the same volume?

2021-11-18 Thread Chengyi Zhao

Hi guys,

Would you please tell me why I use pacat/parec to record monitor device 
always at the same volume?


I use pacat/parec to record the sound played by the video player, but 
the volume is always the same. Is there any way to make the recording 
volume consistent with the playback volume?


Example:
pacat --record -d alsa_output.pci-_01_00.1.hdmi-stereo.monitor > 
dump.raw


Thanks you very much!

Best Regards,
Chengyi





[pulseaudio-discuss] How does PulseAudio adapt to multi-user usage scenarios?

2021-11-14 Thread Chengyi Zhao

Hi guys,

In these system (Debian or Ubuntu) the PulseAudio is a user-level 
process, not a system-level process. Bluetooth is successfully connected 
and able to play audio via A2DP when logging in user1, and then switched 
to user2, the Bluetooth connection is already connected, but there is no 
A2DP sound when playing audio.


How does PulseAudio adapt to multi-user usage scenarios?
Thanks a lot.

Best Regards,
Chengyi




[pulseaudio-discuss] Why does Jack section uses "state.plugged = unknown" and "state.unplugged = unknown"?

2021-09-16 Thread Chengyi Zhao

Hi guys,

I don't know why Jack section uses "state.plugged = unknown" and 
"state.unplugged = unknown" in the path file 
"analog-output-lineout.conf" below.


I think PulseAudio should set Jack to be available when it recognizes 
the "Jack Line Out CLFE" is plugged, and vice versa.


Would you please help explain the true meaning of ”unknown“ here.

[Jack Line Out CLFE]
state.plugged = unknown
state.unplugged = unknown
required-any = any

Best Regards,
Chengyi




[pulseaudio-discuss] Why does PA need to rewrite and rewind when I change the volume while playing audio?

2021-07-26 Thread Chengyi Zhao

Hi guys,

I found the following logic when I change the volume while playing 
audio.I guess there is some audio expertise here, would you please tell 
me the principle, thanks a lot!


In the file sink-input.c(./src/pulsecore/sink-input.c), why does pa need 
to invoke the function pa_sink_input_request_rewind to rewrite and 
rewind the data?


void pa_sink_input_set_volume(...) {
...

pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), 
PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL) == 0);

}

...
}

int pa_sink_input_process_msg(...) {
...

switch (code) {

case PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME:
if (!pa_cvolume_equal(>thread_info.soft_volume, 
>soft_volume)) {

i->thread_info.soft_volume = i->soft_volume;
pa_sink_input_request_rewind(i, 0, true, false, false);
}

   return 0;

...
}

Best Regards,
Chengyi


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Show "Operation Not Authorized" when calling TryAcquire.

2021-06-29 Thread Chengyi Zhao

Hi guys,

Would you please tell me why I can get the following error log after 
auto-connected Bluetooth headset.


6月 22 11:01:13 uos-PC pulseaudio[3385]: E: [pulseaudio] bluez5-util.c: 
Transport TryAcquire() failed for transport 
/org/bluez/hci0/dev_5C_A8_6A_79_D0_45/fd0 (Operation Not Authorized)



Best Regards,
Chengyi


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Why should we set multichannel-input and multichannel-output to a fallback map

2021-04-05 Thread Chengyi Zhao

On 2021/4/3 上午3:48, Tanu Kaskinen wrote:

On Fri, 2021-04-02 at 17:49 +0800, Chengyi Zhao wrote:

Hi guys,

I don't know why we should set multichannel-input and
multichannel-output to fallback map
in the configuration file default.conf.

I think these have no actual usage scenarios, we should delete these
configurations.

Do you agree with me?


./src/modules/alsa/mixer/profile-sets/default.conf:

-[Mapping multichannel-output]
-device-strings = hw:%f
-channel-map = left,right,rear-left,rear-right
-exact-channels = false
-fallback = yes
-priority = 1
-direction = output
-
-[Mapping multichannel-input]
-device-strings = hw:%f
-channel-map = left,right,rear-left,rear-right
-exact-channels = false
-fallback = yes
-priority = 1
-direction = input
-


These are used with sound cards that can't be opened with the regular
mappings. Some pro audio cards can have e.g. 12 channels and refuse to
be opened with any less channels. The "exact-channels" option is set to
false with the multichannel mappings, which means that no matter how
many channels the card requires, these mappings successfully open the
device.


I think there are two issue about these configurations:

1. If the sound card has two channels, this multichannel mapping
may be mapped.
2. Because there is no paths-output and paths-input items,
multichannel ports will not be added.

Thanks,
Chengyi


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Why should we set multichannel-input and multichannel-output to a fallback map

2021-04-02 Thread Chengyi Zhao

Hi guys,

I don't know why we should set multichannel-input and 
multichannel-output to fallback map

in the configuration file default.conf.

I think these have no actual usage scenarios, we should delete these 
configurations.


Do you agree with me?


./src/modules/alsa/mixer/profile-sets/default.conf:

-[Mapping multichannel-output]
-device-strings = hw:%f
-channel-map = left,right,rear-left,rear-right
-exact-channels = false
-fallback = yes
-priority = 1
-direction = output
-
-[Mapping multichannel-input]
-device-strings = hw:%f
-channel-map = left,right,rear-left,rear-right
-exact-channels = false
-fallback = yes
-priority = 1
-direction = input
-


Best Regards,
Chengyi


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] May I modify the configuration of the path 'analog-output-lineout.conf'

2020-11-23 Thread Chengyi Zhao
Hi guys,

I found a Jack that it is Line Out CLFE in the sound card 'Realteck ACL662 
rev3',
and this Jack can adapt 'Mapping multichannel-output' of the profile-sets 
'default.conf'.

Would you please tell me what Line Out CLFE is, and the difference is with Line 
Out? thanks.

Because there is a volume issue when to switch port from headphones to Line Out 
CLFE,
I will modify the path file 'analog-output-lineout.conf' so that I can fix this 
volume issue,
and Line Out CLFE will adapt this path file.

Would you please tell me if I can make such a modification as below? thanks.

Previous configuration of analog-output-lineout.conf:
--
[Jack Line Out CLFE]
state.plugged = unknown
state.unplugged = unknown
required-any = any

Current configuration of analog-output-lineout.conf:
-
[Jack Line Out CLFE]
required-any = any

Best Regards,
Chengyi
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Why I can't find multichannel-input and multichannel-output paths in path folder

2020-10-27 Thread Chengyi Zhao

Hi guys,

I have a computer with using Realtek ALC662 rev3,  it can adapt the 
multichannel profile below,


but I can't find multichannel-input and multichannel-output paths in 
path folder


(/usr/share/pulseaudio/alsa-mixer/paths), please tell me the working 
logic of


multi-channel profile, and how it differs from other profiles, thanks!



[Mapping multichannel-output]
device-strings = hw:%f
channel-map = left,right,rear-left,rear-right
exact-channels = false
fallback = yes
priority = 1
direction = output
paths-output = multichannel-output

[Mapping multichannel-input]
device-strings = hw:%f
channel-map = left,right,rear-left,rear-right
exact-channels = false
fallback = yes
priority = 1
direction = input
paths-input = multichannel-input



Best Regards,

Chengyi

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Pulseaudio is deadlocked when using module-echo-cancel to Bluetooth input audio

2020-09-25 Thread Chengyi Zhao

Hi guys,

Pulseaudio is deadlocked when Bluetooth(HSP) is selected as the input 
audio and module-echo-cancel is loaded.


I don't know why  Thread 1 and Thread 5 are all blocked in the function 
futex_abstimed_wait_cancelable.


Please help analyze the following call stack information, thanks!

(gdb) info thread
  Id   Target Id  Frame
* 1    Thread 0x7f7f23817e00 (LWP 4366) "pulseaudio" 
futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x7f7f0c0013e0) at 
../sysdeps/unix/sysv/linux/futex-internal.h:205
  2    Thread 0x7f7f18818700 (LWP 4601) "alsa-sink-ALC89" 
0x7f7f23feb926 in __GI_ppoll (fds=0x5cc130, nfds=4, 
timeout=, sigmask=sigmask@entry=0x0) at 
../sysdeps/unix/sysv/linux/ppoll.c:39
  3    Thread 0x7f7f13fa8700 (LWP 4604) "alsa-source-ALC" 
0x7f7f23feb926 in __GI_ppoll (fds=0x7940c0, nfds=4, 
timeout=, sigmask=sigmask@entry=0x0) at 
../sysdeps/unix/sysv/linux/ppoll.c:39
  5    Thread 0x7f7f13227700 (LWP 6227) "bluetooth" 
futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x667650) at ../sysdeps/unix/sysv/linux/futex-internal.h:205

(gdb) bt
#0  0x7f7f24260896 in futex_abstimed_wait_cancelable (private=0, 
abstime=0x0, expected=0, futex_word=0x7f7f0c0013e0) at 
../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  0x7f7f24260896 in do_futex_wait (sem=sem@entry=0x7f7f0c0013e0, 
abstime=0x0) at sem_waitcommon.c:111
#2  0x7f7f24260988 in __new_sem_wait_slow 
(sem=sem@entry=0x7f7f0c0013e0, abstime=0x0) at sem_waitcommon.c:181
#3  0x7f7f242609f9 in __new_sem_wait (sem=sem@entry=0x7f7f0c0013e0) 
at sem_wait.c:42
#4  0x7f7f243846d2 in pa_semaphore_wait (s=0x7f7f0c0013e0) at 
pulsecore/semaphore-posix.c:61
#5  0x7f7f243cc224 in pa_asyncmsgq_send (a=0x717130, 
object=, code=code@entry=13, 
userdata=userdata@entry=0x697810, offset=offset@entry=0, 
chunk=chunk@entry=0x0) at pulsecore/asyncmsgq.c:168
#6  0x7f7f1f1f5dfe in command_get_playback_latency (pd=out>, command=, tag=9, t=, 
userdata=) at pulsecore/protocol-native.c:2873
#7  0x7f7f2436df7f in pa_pdispatch_run (pd=0x5c9650, 
packet=packet@entry=0x6f84c0, ancil_data=ancil_data@entry=0x6e0158, 
userdata=userdata@entry=0x6f4600) at pulsecore/pdispatch.c:346
#8  0x7f7f1f1f95e5 in pstream_packet_callback (p=0x6dfec0, 
packet=0x6f84c0, ancil_data=0x6e0158, userdata=0x6f4600) at 
pulsecore/protocol-native.c:4951
#9  0x7f7f2437098d in do_read (p=p@entry=0x6dfec0, 
re=re@entry=0x6e0088) at pulsecore/pstream.c:1020
#10 0x7f7f24373758 in do_pstream_read_write (p=0x6dfec0) at 
pulsecore/pstream.c:253
#11 0x7f7f24373af9 in srb_callback (srb=0x756d90, userdata=0x6dfec0) 
at pulsecore/pstream.c:295
#12 0x7f7f2437434a in srbchannel_rwloop (sr=0x756d90) at 
pulsecore/srbchannel.c:190
#13 0x7f7f242fed28 in dispatch_pollfds (m=0x5cc840) at 
pulse/mainloop.c:140
#14 0x7f7f242fed28 in pa_mainloop_dispatch (m=m@entry=0x5cc840) at 
pulse/mainloop.c:898
#15 0x7f7f242feffc in pa_mainloop_iterate (m=0x5cc840, 
block=, retval=0x7ffceef8cde8) at pulse/mainloop.c:929
#16 0x7f7f242ff0a0 in pa_mainloop_run (m=m@entry=0x5cc840, 
retval=retval@entry=0x7ffceef8cde8) at pulse/mainloop.c:945
#17 0x00407306 in main (argc=, argv=out>) at daemon/main.c:1144

(gdb) c
Continuing.
^C
Thread 1 "pulseaudio" received signal SIGINT, Interrupt.
futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x7f7f0c0013e0) at 
../sysdeps/unix/sysv/linux/futex-internal.h:205

205    in ../sysdeps/unix/sysv/linux/futex-internal.h
(gdb) info thread
  Id   Target Id  Frame
* 1    Thread 0x7f7f23817e00 (LWP 4366) "pulseaudio" 
futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x7f7f0c0013e0) at 
../sysdeps/unix/sysv/linux/futex-internal.h:205
  2    Thread 0x7f7f18818700 (LWP 4601) "alsa-sink-ALC89" 
0x7f7f23feb926 in __GI_ppoll (fds=0x5cc130, nfds=4, 
timeout=, sigmask=sigmask@entry=0x0) at 
../sysdeps/unix/sysv/linux/ppoll.c:39
  3    Thread 0x7f7f13fa8700 (LWP 4604) "alsa-source-ALC" 
0x7f7f23feb926 in __GI_ppoll (fds=0x7940c0, nfds=4, 
timeout=, sigmask=sigmask@entry=0x0) at 
../sysdeps/unix/sysv/linux/ppoll.c:39
  5    Thread 0x7f7f13227700 (LWP 6227) "bluetooth" 
futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x667650) at ../sysdeps/unix/sysv/linux/futex-internal.h:205

(gdb) thread 5
[Switching to thread 5 (Thread 0x7f7f13227700 (LWP 6227))]
#0  futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, 
futex_word=0x667650) at ../sysdeps/unix/sysv/linux/futex-internal.h:205

205    in ../sysdeps/unix/sysv/linux/futex-internal.h
(gdb) bt
#0  0x7f7f24260896 in futex_abstimed_wait_cancelable (private=0, 
abstime=0x0, expected=0, futex_word=0x667650) at 
../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  0x7f7f24260896 in do_futex_wait (sem=sem@entry=0x667650, 
abstime=0x0) at 

[pulseaudio-discuss] Questions about device_start_waiting_for_profiles

2020-09-13 Thread Chengyi Zhao

Hi guys,

I have a question for the code below, please give your opinion, thanks!

The function device_start_waiting_for_profiles is to wait for connecting 
profiles,
but only waited 3 seconds(WAIT_FOR_PROFILES_TIMEOUT_USEC), if Bluetooth 
transport state

will be changed after 3 seconds(WAIT_FOR_PROFILES_TIMEOUT_USEC),
I think whether there are any issues with the code logic or not.


    /* src/modules/bluetooth/bluez5-util.c */

    n_disconnected_profiles = 
device_count_disconnected_profiles(t->device);


    new_device_appeared = !old_any_connected && 
pa_bluetooth_device_any_transport_connected(t->device);
    device_disconnected = old_any_connected && 
!pa_bluetooth_device_any_transport_connected(t->device);


    if (new_device_appeared) {
    if (n_disconnected_profiles > 0)
    device_start_waiting_for_profiles(t->device); < here
    else
pa_hook_fire(>device->discovery->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED], 
t->device);

    return;
    }

    static void device_start_waiting_for_profiles(pa_bluetooth_device 
*device) {

        pa_assert(!device->wait_for_profiles_timer);
        device->wait_for_profiles_timer = 
pa_core_rttime_new(device->discovery->core,

pa_rtclock_now() + WAIT_FOR_PROFILES_TIMEOUT_USEC,  < here
wait_for_profiles_cb, device);
    }

    static void wait_for_profiles_cb(pa_mainloop_api *api, 
pa_time_event* event, const struct timeval *tv, void *userdata) {

        pa_bluetooth_device *device = userdata;
        pa_strbuf *buf;
        pa_bluetooth_profile_t profile;
        bool first = true;
        char *profiles_str;

        device_stop_waiting_for_profiles(device);  < here

        /* .. */
    }

Best Regards,
Chengyi

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] 回复: How to fix pulseaudio crash when playing music

2020-06-09 Thread Chengyi Zhao
Hi Georg,

Thanks for your reply!

Hi all,

I try to apply the following patch to fix this issue, please help review, 
thanks!

Date:   Tue Jun 9 22:09:36 2020 +0800

srb: ignore srb when reading/writing srb generated an exception

When the function do_read() returns -1, the program continues
reading the same srb, maybe it will occur the crash.

diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c
index 3b94a3adf..4fcec51c6 100644
--- a/src/pulsecore/pstream.c
+++ b/src/pulsecore/pstream.c
@@ -235,7 +235,7 @@ void pa_cmsg_ancil_data_close_fds(struct pa_cmsg_ancil_data 
*ancil) {
 static int do_write(pa_pstream *p);
 static int do_read(pa_pstream *p, struct pstream_read *re);

-static void do_pstream_read_write(pa_pstream *p) {
+static int do_pstream_read_write(pa_pstream *p) {
 pa_assert(p);
 pa_assert(PA_REFCNT_VALUE(p) > 0);

@@ -244,8 +244,15 @@ static void do_pstream_read_write(pa_pstream *p) {
 p->mainloop->defer_enable(p->defer_event, 0);

 if (!p->dead && p->srb) {
- do_write(p);
- while (!p->dead && do_read(p, >readsrb) == 0);
+if(do_write(p) < 0)
+goto ignore;
+
+int r = 0;
+while (!p->dead && r == 0) {
+r = do_read(p, >readsrb);
+if (r < 0)
+goto ignore;
+}
 }

 if (!p->dead && pa_iochannel_is_readable(p->io)) {
@@ -263,7 +270,12 @@ static void do_pstream_read_write(pa_pstream *p) {
 }

 pa_pstream_unref(p);
-return;
+return 0;
+
+ignore:
+
+pa_pstream_unref(p);
+return -1;

 fail:

@@ -272,9 +284,11 @@ fail:

 pa_pstream_unlink(p);
 pa_pstream_unref(p);
+return -1;
 }

 static bool srb_callback(pa_srbchannel *srb, void *userdata) {
+int r;
 bool b;
 pa_pstream *p = userdata;

@@ -284,11 +298,11 @@ static bool srb_callback(pa_srbchannel *srb, void 
*userdata) {

 pa_pstream_ref(p);

-do_pstream_read_write(p);
+r = do_pstream_read_write(p);

 /* If either pstream or the srb is going away, return false.
We need to check this before p is destroyed. */
-b = (PA_REFCNT_VALUE(p) > 1) && (p->srb == srb);
+b = (r == 0) && (PA_REFCNT_VALUE(p) > 1) && (p->srb == srb);
 pa_pstream_unref(p);

 return b;

Best Regards,
Chengyi

From: Georg Chini 
Sent: Tuesday, June 9, 2020 2:01
To: General PulseAudio Discussion ; 
Zhao Chengyi 
Subject: Re: [pulseaudio-discuss] 回复: How to fix pulseaudio crash when playing 
music

On 09.06.20 10:39, Zhao Chengyi wrote:
Please ignore the gdb bt information above because of error dbgsyms,
and please refer to the following logs when occurring crash.

5月 26 03:14:24 test-PC pulseaudio[2841]: W: [pulseaudio] pstream.c: Received 
SHM memblock frame with invalid frame length.
5月 26 03:14:24 test-PC pulseaudio[2841]: E: [pulseaudio] pstream.c: Assertion 
're->data || re->memblock' failed at pulsecore/pstream.c:862, function 
do_read(). Aborting.
5月 26 03:14:24 test-PC systemd[1]: Created slice 
system-systemd\x2dcoredump.slice.
5月 26 03:14:24 test-PC systemd[1]: Started Process Core Dump (PID 10183/UID 0).
5月 26 03:14:25 test-PC bluetoothd[1700]: Endpoint unregistered: sender=:1.60 
path=/MediaEndpoint/A2DPSource
5月 26 03:14:25 test-PC bluetoothd[1700]: Endpoint unregistered: sender=:1.60 
path=/MediaEndpoint/A2DPSink
5月 26 03:14:25 test-PC daemon/audio[2874]: audio_events.go:65: pulseaudio 
context state failed
5月 26 03:14:25 test-PC systemd[2674]: pulseaudio.service: Main process exited, 
code=dumped, status=6/ABRT
5月 26 03:14:25 test-PC systemd[2674]: pulseaudio.service: Failed with result 
'core-dump'.
5月 26 03:14:25 test-PC systemd-coredump[10184]: Process 2841 (pulseaudio) of 
user 1000 dumped core.

  Stack trace of thread 2841:
  #0  0x8702a714 raise 
(libc.so.6)
  #1  0x870188e8 abort 
(libc.so.6)
  #2  0x873b5728 n/a 
(libpulsecommon-12.2.so)
  #3  0x873b7fd8 n/a 
(libpulsecommon-12.2.so)
  #4  0x873b8368 n/a 
(libpulsecommon-12.2.so)
  #5  0x873b8bec n/a 
(libpulsecommon-12.2.so)
  #6  0x87339c70 
pa_mainloop_dispatch (libpulse.so.0)
  #7  0x8733a01c 
pa_mainloop_iterate (libpulse.so.0)
  #8  0x8733a0d8 
pa_mainloop_run (libpulse.so.0)
  #9  0x00406894 main 
(pulseaudio)
  #10 0x87018d24 
__libc_start_main (libc.so.6)