int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) { rdpsndPulsePlugin* pulse; RDP_PLUGIN_DATA* data; pulse = xnew(rdpsndPulsePlugin); pulse->device.Open = rdpsnd_pulse_open; pulse->device.FormatSupported = rdpsnd_pulse_format_supported; pulse->device.SetFormat = rdpsnd_pulse_set_format; pulse->device.SetVolume = rdpsnd_pulse_set_volume; pulse->device.Play = rdpsnd_pulse_play; pulse->device.Start = rdpsnd_pulse_start; pulse->device.Close = rdpsnd_pulse_close; pulse->device.Free = rdpsnd_pulse_free; data = pEntryPoints->plugin_data; if (data && strcmp((char*)data->data[0], "pulse") == 0) { if(data->data[1] && strlen((char*)data->data[1]) > 0) pulse->device_name = xstrdup((char*)data->data[1]); else pulse->device_name = NULL; } pulse->dsp_context = freerdp_dsp_context_new(); pulse->mainloop = pa_threaded_mainloop_new(); if (!pulse->mainloop) { DEBUG_WARN("pa_threaded_mainloop_new failed"); rdpsnd_pulse_free((rdpsndDevicePlugin*)pulse); return 1; } pulse->context = pa_context_new(pa_threaded_mainloop_get_api(pulse->mainloop), "freerdp"); if (!pulse->context) { DEBUG_WARN("pa_context_new failed"); rdpsnd_pulse_free((rdpsndDevicePlugin*)pulse); return 1; } pa_context_set_state_callback(pulse->context, rdpsnd_pulse_context_state_callback, pulse); if (!rdpsnd_pulse_connect((rdpsndDevicePlugin*)pulse)) { DEBUG_WARN("rdpsnd_pulse_connect failed"); rdpsnd_pulse_free((rdpsndDevicePlugin*)pulse); return 1; } pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)pulse); return 0; }
int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) { rdpsndDevicePlugin * devplugin; struct pulse_device_data * pulse_data; RD_PLUGIN_DATA * data; int i; devplugin = pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->plugin); if (devplugin == NULL) { LLOGLN(0, ("rdpsnd_pulse: unable to register device.")); return 1; } devplugin->open = rdpsnd_pulse_open; devplugin->format_supported = rdpsnd_pulse_format_supported; devplugin->set_format = rdpsnd_pulse_set_format; devplugin->set_volume = rdpsnd_pulse_set_volume; devplugin->play = rdpsnd_pulse_play; devplugin->close = rdpsnd_pulse_close; devplugin->free = rdpsnd_pulse_free; pulse_data = (struct pulse_device_data *) malloc(sizeof(struct pulse_device_data)); memset(pulse_data, 0, sizeof(struct pulse_device_data)); data = (RD_PLUGIN_DATA *) pEntryPoints->data; if (data && strcmp(data->data[0], "pulse") == 0) { for (i = 1; i < 4 && data->data[i]; i++) { if (i > 1) { strncat(pulse_data->device_name, ":", sizeof(pulse_data->device_name) - strlen(pulse_data->device_name)); } strncat(pulse_data->device_name, (char*)data->data[i], sizeof(pulse_data->device_name) - strlen(pulse_data->device_name)); } } pulse_data->pDecodeImaAdpcm = pEntryPoints->pDecodeImaAdpcm; devplugin->device_data = pulse_data; pulse_data->mainloop = pa_threaded_mainloop_new(); if (!pulse_data->mainloop) { LLOGLN(0, ("rdpsnd_pulse: pa_threaded_mainloop_new failed")); rdpsnd_pulse_free(devplugin); return 1; } pulse_data->context = pa_context_new(pa_threaded_mainloop_get_api(pulse_data->mainloop), "freerdp"); if (!pulse_data->context) { LLOGLN(0, ("rdpsnd_pulse: pa_context_new failed")); rdpsnd_pulse_free(devplugin); return 1; } pa_context_set_state_callback(pulse_data->context, rdpsnd_pulse_context_state_callback, devplugin); if (rdpsnd_pulse_connect(devplugin)) { LLOGLN(0, ("rdpsnd_pulse: rdpsnd_pulse_connect failed")); rdpsnd_pulse_free(devplugin); return 1; } LLOGLN(0, ("rdpsnd_pulse: pulse device '%s' registered.", pulse_data->device_name)); return 0; }