sr: demodevice: Make read channel non-blocking

Both pipe channels are currently configured as blocking. We read from the pipe
in receive_data. Since the channel is configured as blocking we'll block in
receive_data until all data has been received. receive_data will be called from
the mainloop, so as consequence the mainloop will be blocked until the demo
device has finished sampling. This is not so much of a problem if we are
sampling in blocking mode (using sr_session_run()) and the demo device is the
only device in the session, but it will fail badly for all other configurations
(e.g. multiple devices or async sampling).

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2012-07-06 23:23:30 +02:00 committed by Uwe Hermann
parent 93b03d091a
commit e6e8f8e053
1 changed files with 2 additions and 0 deletions

View File

@ -440,6 +440,8 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
ctx->channels[0] = g_io_channel_unix_new(ctx->pipe_fds[0]); ctx->channels[0] = g_io_channel_unix_new(ctx->pipe_fds[0]);
ctx->channels[1] = g_io_channel_unix_new(ctx->pipe_fds[1]); ctx->channels[1] = g_io_channel_unix_new(ctx->pipe_fds[1]);
g_io_channel_set_flags(ctx->channels[0], G_IO_FLAG_NONBLOCK, NULL);
/* Set channel encoding to binary (default is UTF-8). */ /* Set channel encoding to binary (default is UTF-8). */
g_io_channel_set_encoding(ctx->channels[0], NULL, NULL); g_io_channel_set_encoding(ctx->channels[0], NULL, NULL);
g_io_channel_set_encoding(ctx->channels[1], NULL, NULL); g_io_channel_set_encoding(ctx->channels[1], NULL, NULL);