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

Colin Guthrie gmane at colin.guthr.ie
Fri Nov 19 05:48:58 PST 2010

'Twas brillig, and Tsai Yu-Chin at 19/11/10 02:29 did gyre and gimble:
>     pa_ml=pa_mainloop_new();
>     pa_mlapi=pa_mainloop_get_api(pa_ml);
>     context=pa_context_new(pa_mlapi,(*td).pa_ctx_name);
>     pa_context_connect(context,NULL,0,NULL);
>     if(!(stream=pa_stream_new(context,(*td).pa_ctx_name,&sample_spec,NULL))){
>         printf("Failed to create monitoring stream\n");
>         goto quit;
>     }
>     pa_stream_set_monitor_stream(stream,atoi((*td).sink_input_index));
>     pa_stream_set_read_callback(stream,read_callback,&fd);
>     uint32_t monitor_source_index=get_monitor_source_index(context,pa_ml,atoi((*td).sink_input_index));
>     snprintf(msi,sizeof(msi),"%u",monitor_source_index);
>     if(pa_stream_connect_record(stream,msi,&attr,(pa_stream_flags_t)(PA_STREAM_DONT_MOVE|PA_STREAM_PEAK_DETECT))<0){
>         printf("Failed to connect monitoring stream\n");
>         pa_stream_unref(stream);
>         goto quit;
>     }
>     if(end)
>         quit(pa_mlapi,0);
>     signal(SIGALRM,alarm_handler);
>     alarm(10);
>     if(pa_mainloop_run(pa_ml,&ret)<0){
>         printf("mainloop run failed.\n");
>         goto quit;
>     }

You appear to be using the sink_input_index value before you even run
the main loop... This value will just contain the default values and
thus I suspect they all have 0's which ultimately maps to the default
monitor source and no specific sink input.

You need to run the main loop and let all the necessary call backs be
called and get all the necessary index values before you actually use them.



Colin Guthrie

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/]

More information about the pulseaudio-discuss mailing list