#include <glib.h>
#include "wav_player_private.h"
+#include <gio/gunixfdlist.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
#define PA_BUS_NAME "org.pulseaudio.Server"
#define PA_SOUND_PLAYER_OBJECT_PATH "/org/pulseaudio/SoundPlayer"
#define PA_SOUND_PLAYER_INTERFACE "org.pulseaudio.SoundPlayer"
g_autoptr(GVariant) reply = NULL;
dbus_cb_data_s *dbus_cb_data = NULL;
+ g_autoptr(GUnixFDList) fd_list = NULL;
+ int fd = -1;
+ int appended_index = -1;
+
if (path == NULL || stream_info == NULL) {
LOGE("invalid params");
return WAV_PLAYER_ERROR_INVALID_PARAMETER;
if (!(conn = __get_dbus_connection()))
return WAV_PLAYER_ERROR_INVALID_OPERATION;
- reply = g_dbus_connection_call_sync(conn, PA_BUS_NAME,
+ fd = open(m_path, O_RDONLY);
+ if (fd == -1) {
+ LOGE("error opening(%s), errno(%d)", m_path, errno);
+ return WAV_PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ LOGI("fd(%d) opened for fd-passing", fd);
+
+ fd_list = g_unix_fd_list_new();
+ appended_index = g_unix_fd_list_append(fd_list, fd, &err);
+ if (appended_index == -1) {
+ LOGE("failed, %s", err->message);
+ close(fd);
+ return WAV_PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ /* Note: Sending appended index to fd-list is required
+ for receiving fd-passing using non-gdbus implementation */
+ reply = g_dbus_connection_call_with_unix_fd_list_sync(conn, PA_BUS_NAME,
PA_SOUND_PLAYER_OBJECT_PATH,
PA_SOUND_PLAYER_INTERFACE,
PA_SOUND_PLAYER_METHOD_NAME_SOUND_PLAY,
- g_variant_new("(siisib)", m_path, loop_count == 0 ? -1 : loop_count,
- getpid(), stream_type, stream_id, (gboolean)stop_others),
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+ g_variant_new("(siisibh)", m_path, loop_count == 0 ? -1 : loop_count,
+ getpid(), stream_type, stream_id, (gboolean)stop_others, appended_index),
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, fd_list, NULL, NULL, &err);
if (!reply) {
- LOGE("g_dbus_connection_call_sync error (%s)", err->message);
- ret = __convert_dbus_error(err->message);
- return ret;
+ LOGE("g_dbus_connection_call_with_unix_fd_list_sync error (%s)", err->message);
+ return __convert_dbus_error(err->message);
}
+ close(fd);
+
g_variant_get(reply, "(i)", &handle);
if (id)
*id = handle;