[pulseaudio-discuss] How to capture one of multiple radios that these radios play at the same time?

Tsai Yu-Chin yorjing at gmail.com
Fri Nov 19 05:03:06 PST 2010


Thank you for your answers.
But I can't still realize how to create a "Sink Input Monitor"?
I also use "pa_stream_set_monitor_stream" method in my code before,
but it still records all streams playing on the sink.
I want to create a "Sink Input Monitor"; however,it seems that I
create "Sink Monitor".
I want to record only one audio form a unique sink input, but I record
all audios from whole sink.

Can you teach me how to create a "Sink Input Monitor" to record a
single audio in one sink input again?
Maybe I am silly so that I can't realize your answer before.

Thank you very much.

2010/11/19 Colin Guthrie <gmane at colin.guthr.ie>:
> 'Twas brillig, and Colin Guthrie at 19/11/10 11:33 did gyre and gimble:
>> 'Twas brillig, and Tsai Yu-Chin at 19/11/10 02:29 did gyre and gimble:
>>> Thank you for your help.
>>> I refer to source code of pavucontrol and I program a simple code below:
>>
>> Ultimately what your code is doing is thus:
>>
>> 1. Get the Sink Index the stream is using.
>> 2. Get the Monitor Source for the Sink.
>> 3. Record from the Monitor of the Sink.
>>
>>
>> The sink monitor will contain the product of *all* streams playing on
>> the sink. There is a special "Sink Input Monitor" that you can connect
>> to for your recording. It's will just contain the sound for the Sink
>> Input itself. You still need to get the Monitor for the sink to which
>> your stream is attached, but you pass this in to the
>> pa_stream_connect_record function as a string.
>>
>> In pavucontrol's mainwindow.cc see the method:
>> MainWindow::createMonitorStreamForSinkInput()
>>
>
> For clarity, the code below is NOT from the above function. I meant to
> include some text saying "so you could write something like this:" here :)
>
>> int sink_input_index = ?; /* You should have this value already in your
>> code */
>> int sink_monitor_source_index = ?; /* You should have this value already
>> in your code */
>> char dev[16];
>> pa_stream *stream;
>>
>> /* assume variable "ss" is your sample spec and "attr" is your buffer
>> attributes */
>>
>> if (!(stream = pa_stream_new(context, _("Single Radio Snooper!"), &ss,
>> NULL))) {
>>   /* ERROR */
>>   return;
>> }
>>
>> /* Put the source which we'll record here (i.e. the montior of the sink
>> the stream is playing on) */
>> dev = snprintf(dev, sizeof(dev), "%u", sink_monitor_source_index);
>>
>> /* restrict the recording to just one monitor stream */
>> pa_stream_set_monitor_stream(stream, sink_input_index);
>>
>> /* Set callbacks */
>> pa_stream_set_read_callback(stream, ....);
>> pa_stream_set_suspended_callback(stream, ....);
>>
>> if (pa_stream_connect_record(stream, dev, &attr, (pa_stream_flags_t)
>> (PA_STREAM_DONT_MOVE|PA_STREAM_ADJUST_LATENCY)) < 0) {
>>   /* ERROR */
>>   pa_stream_unref(stream);
>>   stream = NULL;
>>   return;
>> }
>>
>>
>>
>> Obviously if the user moves your stream to another device you have to
>> tear down and recreate your stream against the new monitor source. Not
>> ideal, but should be fine in most circumstances. Sadly there isn't a way
>> to record the radio fully across device moves as far as I know...
>> although perhaps not setting the PA_STREAM_DONT_MOVE flag will allow the
>> record stream to automatically move if the stream is moved? I don't know...
>>
>> HTHs
>>
>
>
> --
>
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
>
> Day Job:
>  Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>  Mageia Contributor [http://www.mageia.org/]
>  PulseAudio Hacker [http://www.pulseaudio.org/]
>  Trac Hacker [http://trac.edgewall.org/]
>
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at mail.0pointer.de
> https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
>



More information about the pulseaudio-discuss mailing list