[pulseaudio-discuss] pa_stream_connect_playback bad state

Gian Lorenzo Meocci glmeocci at gmail.com
Thu Feb 18 01:43:49 PST 2010


Hi,

when I call pa_stream_connect_playback I always obtain bad state. Why?


I am using this code:

        m = pa_mainloop_new();
	pa_mainloop_api* mainloop_api = pa_mainloop_get_api(m);
	pa_proplist* proplist = pa_proplist_new();

	/* Create a new connection context */
	if (!(pulsecontext = pa_context_new_with_proplist(mainloop_api, NULL,
proplist)))
	{
		qDebug() << "pa_context_new_with_proplist() failed";
	}

	pa_context_flags flags = PA_CONTEXT_NOFAIL;

	/* Connect the context */
	if (pa_context_connect(pulsecontext, 0, flags, NULL) < 0)
	{
		qDebug() << "pa_context_connect() failed: " <<
pa_strerror(pa_context_errno(pulsecontext));
	}


        s = pa_stream_new (pulsecontext, "CTFULL", &ss, NULL);
	if(s == 0)
	{
		qDebug() << "Error creating stream audio";
		mute = true;
	}

	pa_cvolume cv;
	pa_cvolume_set (&cv, channels, PA_VOLUME_NORM);

	if (pa_stream_connect_playback (s, 0, 0, flags, &cv, 0) < 0)
	{
		connect_fail = true;
		qDebug() << "Unable to connect to PulseAudio";
		qDebug() << "pa_stream_connect_playback() failed: " <<
pa_strerror(pa_context_errno(pulsecontext));
	}
	else
		qDebug() << "Connected to PulseAudio";



thanks a lot,

-- 
Ing. Gian Lorenzo Meocci
http://www.meocci.it



More information about the pulseaudio-discuss mailing list