+ /* Make sure we track vlc_object_signal() */
+ ufd[n].fd = vlc_object_waitpipe( p_sd );
+ ufd[n].events = POLLIN | POLLHUP;
+ ufd[n].revents = 0;
+
+ if( ufd[n].fd == -1 )
+ {
+ /* On windows, fd will be -1, as we can't select on a pipe()-ed
+ * fildes. Because we have no other solution to track that
+ * object is killed, we make sure the timeout won't be to long. */
+ if( timeout > 1000 || timeout == -1 )
+ timeout = 1000;
+ }
+
+ vlc_object_unlock( p_sd );
+
+ if (poll (ufd, n+1, timeout) > 0)
+ {
+ for (unsigned i = 0; i < n; i++)
+ {
+ if (ufd[i].revents)
+ {
+ uint8_t p_buffer[MAX_SAP_BUFFER+1];
+ ssize_t i_read;
+
+ i_read = net_Read (p_sd, ufd[i].fd, NULL, p_buffer,
+ MAX_SAP_BUFFER, false);
+ if (i_read < 0)
+ msg_Warn (p_sd, "receive error: %m");
+ if (i_read > 6)
+ {
+ /* Parse the packet */
+ p_buffer[i_read] = '\0';
+ ParseSAP (p_sd, p_buffer, i_read);
+ }
+ }