All of lore.kernel.org
 help / color / mirror / Atom feed
From: frederik@ofb.net
To: Takashi Iwai <tiwai@suse.de>
Cc: Tanu Kaskinen <tanuk@iki.fi>, alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] parameter for pulse device?
Date: Tue, 15 Oct 2019 08:52:02 -0700	[thread overview]
Message-ID: <20191015155202.bqcqzvvpeesfvuwg@localhost> (raw)
In-Reply-To: <s5hh857o1ik.wl-tiwai@suse.de>

Dear Takashi,

I tested your patch, after commenting some lines in my ~/.asoundrc, and I can confirm that it works. I can now specify a pulse device to 'ecasound':

    ecasound -o alsa,pulse:music -i song.wav

and when I do it with no "DEVICE" argument, then it outputs to the sink defined by "pacmd set-default-sink":

    ecasound -o alsa,pulse -i song.wav

I guess this only exercises one of the cases in your patch where the empty string is recognized as NULL:

+			} else if (!*device) {
+				device = NULL;

Let me know if you want me to do more testing, and apologies for the long delay in my reply.

Thanks,

Frederick


On Fri, Sep 20, 2019 at 09:44:19AM +0200, Takashi Iwai wrote:
>On Fri, 20 Sep 2019 09:35:59 +0200,
>Tanu Kaskinen wrote:
>>
>> On Thu, 2019-09-19 at 14:12 -0700, frederik@ofb.net wrote:
>> > Thank you for the tips.
>> >
>> > I don't know if my input is still needed, but I figured out from
>> > looking at some of the syntax you linked to that I can put this in
>> > ~/.asoundrc and it does the job (this is what I had had in mind when
>> > I asked about "magic with macros", it is somewhat advanced for me):
>> >
>> >     pcm.!pulse {
>> >         @args [ DEV ]
>> >         @args.DEV {
>> >             type string
>> >             default "default"
>> >         }
>> >         type pulse;
>> >         device $DEV
>> >     }
>> >
>> > Now I can set up a filter like this:
>> >
>> >     ecasound -i alsa,pulse:mic -o alsa,pulse:monitor
>> >
>> > Is something like this going into the alsa-plugins repo?
>>
>> I'm sure something like this will be accepted if you submit a patch. I
>> got the impression that Takashi isn't willing to write the patch
>> himself, and nor am I, so you're in the best position to make this
>> happen.
>
>I have a test patch but had no chance to test the stuff at all
>currently as I am (and will be for the next few weeks) traveling.
>
>> Note that
>>
>>             default "default"
>>
>> doesn't do the intended thing with the current pcm_pulse.c code. With
>> the current code the plugin will request PulseAudio to use a device
>> named "default", which most likely won't exist and playback or
>> recording will fail. The plugin code needs to pass NULL as the device
>> name to pa_stream_connect_playback() and pa_stream_connect_record()
>> when it detects that the default device is requested, so you'll need to
>> modify pcm_pulse.c in order to make this work. Instead of "default" as
>> the special string in the configuration, I suggested using "".
>
>Below is the totally untested patch (even not build-tested!)
>If anyone interested, feel free to cook it.
>
>
>thanks,
>
>Takashi
>
>---
>diff --git a/pulse/50-pulseaudio.conf b/pulse/50-pulseaudio.conf
>index 62da207af9ca..916258d942af 100644
>--- a/pulse/50-pulseaudio.conf
>+++ b/pulse/50-pulseaudio.conf
>@@ -1,7 +1,13 @@
> # Add a specific named PulseAudio pcm and ctl (typically useful for testing)
>
> pcm.pulse {
>+	@args [ DEVICE ]
>+	@args.DEVICE {
>+		type string
>+		default ""
>+	}
> 	type pulse
>+	device $DEVICE
> 	hint {
> 		show {
> 			@func refer
>diff --git a/pulse/ctl_pulse.c b/pulse/ctl_pulse.c
>index fbb6eae2ec76..9b820fd04b15 100644
>--- a/pulse/ctl_pulse.c
>+++ b/pulse/ctl_pulse.c
>@@ -664,6 +664,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &server) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*server) {
>+				server = NULL;
> 			}
> 			continue;
> 		}
>@@ -671,6 +673,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &device) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*device) {
>+				device = NULL;
> 			}
> 			continue;
> 		}
>@@ -678,6 +682,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &source) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*source) {
>+				source = NULL;
> 			}
> 			continue;
> 		}
>@@ -685,6 +691,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &sink) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*sink) {
>+				sink = NULL;
> 			}
> 			continue;
> 		}
>diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
>index 283174357e8b..869c9b674c6b 100644
>--- a/pulse/pcm_pulse.c
>+++ b/pulse/pcm_pulse.c
>@@ -1069,6 +1069,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &server) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*server) {
>+				server = NULL;
> 			}
> 			continue;
> 		}
>@@ -1076,6 +1078,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &device) < 0) {
> 				SNDERR("Invalid type for %s", id);
> 				return -EINVAL;
>+			} else if (!*device) {
>+				device = NULL;
> 			}
> 			continue;
> 		}
>@@ -1091,6 +1095,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse)
> 			if (snd_config_get_string(n, &fallback_name) < 0) {
> 				SNDERR("Invalid value for %s", id);
> 				return -EINVAL;
>+			} else if (!*fallback_name) {
>+				fallback_name = NULL;
> 			}
> 			continue;
> 		}
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2019-10-15 15:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 16:47 [alsa-devel] parameter for pulse device? frederik
2019-09-09 17:52 ` Takashi Iwai
2019-09-10 17:33   ` frederik
2019-09-17 12:51     ` Tanu Kaskinen
2019-09-17 12:55       ` Takashi Iwai
2019-09-17 13:14         ` Tanu Kaskinen
2019-09-17 13:17           ` Takashi Iwai
2019-09-19 21:12             ` frederik
2019-09-20  7:35               ` Tanu Kaskinen
2019-09-20  7:44                 ` Takashi Iwai
2019-10-15 15:52                   ` frederik [this message]
2019-10-18  6:17                     ` Takashi Iwai
2019-10-18  6:41                       ` frederik
2019-09-12 15:42 ` [alsa-devel] How to check ALSA version in Linux kernel xinhui zhou
2019-09-15  9:33   ` Takashi Iwai
2019-11-15 23:28   ` [alsa-devel] Number of PCM instance (pcm device file) for one sound card xinhui zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015155202.bqcqzvvpeesfvuwg@localhost \
    --to=frederik@ofb.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=tanuk@iki.fi \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.