#define FILE_FULL_PATH 1024 /* File path length */
#define ROLE_NAME_LEN 64 /* Role name length */
#define VOLUME_GAIN_TYPE_LEN 64 /* Volume gain type length */
+#define RETRY_NUM 100
struct ipc_data {
char filename[FILE_FULL_PATH];
}
pa_log_debug("pa_scache_play_item() start");
- if ((ret = pa_scache_play_item(u->module->core, name, sink, PA_VOLUME_NORM, p, &stream_idx) < 0)) {
- pa_log_error("pa_scache_play_item fail");
+ ret = pa_scache_play_item(u->module->core, name, sink, PA_VOLUME_NORM, p, &stream_idx);
+ if (ret < 0) {
+ pa_log_error("pa_scache_play_item fail, ret[%d]", ret);
goto exit;
}
pa_log_debug("pa_scache_play_item() end, stream_idx(%u)", stream_idx);
*stream_idx = result;
pa_idxset_put(u->stream_idxs, stream_idx, &idx);
}
-
pa_dbus_send_basic_value_reply(conn, msg, DBUS_TYPE_INT32, &result);
}
goto fail;
}
+ /* for non-blocking read */
+ fcntl(u->fd, F_SETFL, O_NONBLOCK);
+
/* change access mode so group can use keytone pipe */
if (fchmod (u->fd, 0666) == -1)
pa_log_warn("Changing keytone access mode is failed. errno=[%d][%s]", errno, strerror(errno));
struct userdata *u = userdata;
struct ipc_data data;
int ret = 0;
- int size = 0;
+ int data_size = 0;
+ int read_sum = 0;
+ int retry_count = 0;
pa_assert(io);
pa_assert(u);
}
if (events & PA_IO_EVENT_INPUT) {
- size = sizeof(data);
- memset(&data, 0, size);
- ret = read(fd, (void *)&data, size);
- if(ret != -1) {
+ data_size = sizeof(data);
+ memset(&data, 0, data_size);
+ while (read_sum != data_size && retry_count < RETRY_NUM) {
+ ret = read(fd, ((void *)&data)+read_sum, data_size-read_sum);
+ if (ret < 0 && errno == EAGAIN)
+ retry_count++;
+ else
+ read_sum += ret;
+ }
+ if (read_sum == data_size) {
pa_log_info("name(%s), role(%s), volume_gain_type(%s)", data.filename, data.role, data.volume_gain_type);
_simple_play(u, data.filename, data.role, data.volume_gain_type);
-
} else {
- pa_log_warn("Fail to read file");
+ pa_log_warn("Fail to read, retry_count(%d), read sum(%d), err(%s)", retry_count, read_sum, pa_cstrerror(errno));
}
}