static void pulse_stop_playback( ALCdevice* device ) //{{{
{
	pulse_data* data = device->ExtraData;

	if ( !data->stream )
	{
		return;
	}

	ppa_threaded_mainloop_lock( data->loop );

#if PA_CHECK_VERSION(0,9,15)

	if ( ppa_stream_set_buffer_attr_callback )
	{
		ppa_stream_set_buffer_attr_callback( data->stream, NULL, NULL );
	}

#endif
	ppa_stream_set_moved_callback( data->stream, NULL, NULL );
	ppa_stream_set_write_callback( data->stream, NULL, NULL );
	ppa_stream_disconnect( data->stream );
	ppa_stream_unref( data->stream );
	data->stream = NULL;

	ppa_threaded_mainloop_unlock( data->loop );
} //}}}
Beispiel #2
0
static void pulse_close(ALCdevice *device) //{{{
{
    pulse_data *data = device->ExtraData;

    ppa_threaded_mainloop_lock(data->loop);

    if(data->stream)
    {
        ppa_stream_disconnect(data->stream);
        ppa_stream_unref(data->stream);
    }

    ppa_context_disconnect(data->context);
    ppa_context_unref(data->context);

    ppa_threaded_mainloop_unlock(data->loop);

    ppa_threaded_mainloop_stop(data->loop);
    ppa_threaded_mainloop_free(data->loop);

    device->ExtraData = NULL;
    free(device->szDeviceName);
    device->szDeviceName = NULL;
    DestroyRingBuffer(data->ring);

    ppa_xfree(data);
} //}}}
Beispiel #3
0
static void pulse_stop_playback(ALCdevice *device) //{{{
{
    pulse_data *data = device->ExtraData;

    if(!data->stream)
        return;

    ppa_threaded_mainloop_lock(data->loop);

    ppa_stream_disconnect(data->stream);
    ppa_stream_unref(data->stream);
    data->stream = NULL;

    ppa_threaded_mainloop_unlock(data->loop);
} //}}}
// OpenAL {{{
static ALCboolean pulse_open_playback( ALCdevice* device, const ALCchar* device_name ) //{{{
{
	char* pulse_name = NULL;
	pa_sample_spec spec;
	pulse_data* data;
	ALuint len;

	if ( !pulse_load() )
	{
		return ALC_FALSE;
	}

	if ( !device_name )
	{
		device_name = pulse_device;
	}
	else if ( strcmp( device_name, pulse_device ) != 0 )
	{
		ALuint i;

		if ( !allDevNameMap )
		{
			probe_devices( AL_FALSE );
		}

		for ( i = 0; i < numDevNames; i++ )
		{
			if ( strcmp( device_name, allDevNameMap[i].name ) == 0 )
			{
				pulse_name = allDevNameMap[i].device_name;
				break;
			}
		}

		if ( i == numDevNames )
		{
			return ALC_FALSE;
		}
	}

	if ( pulse_open( device, device_name ) == ALC_FALSE )
	{
		return ALC_FALSE;
	}

	data = device->ExtraData;

	ppa_threaded_mainloop_lock( data->loop );

	spec.format = PA_SAMPLE_S16NE;
	spec.rate = 44100;
	spec.channels = 2;

	data->device_name = pulse_name;
	pa_stream* stream = connect_playback_stream( device, 0, NULL, &spec, NULL );

	if ( !stream )
	{
		ppa_threaded_mainloop_unlock( data->loop );
		goto fail;
	}

	if ( ppa_stream_is_suspended( stream ) )
	{
		ppa_stream_disconnect( stream );
		ppa_stream_unref( stream );
		ppa_threaded_mainloop_unlock( data->loop );
		goto fail;
	}

	data->device_name = strdup( ppa_stream_get_device_name( stream ) );

	ppa_stream_disconnect( stream );
	ppa_stream_unref( stream );

	ppa_threaded_mainloop_unlock( data->loop );

	len = GetConfigValueInt( "pulse", "buffer-length", 2048 );

	if ( len != 0 )
	{
		device->UpdateSize = len;
		device->NumUpdates = 1;
	}

	return ALC_TRUE;

fail:
	pulse_close( device );
	return ALC_FALSE;
} //}}}