sndio: Fix segmentation fault when audio card is removed
This can happen if you remove an external audio card or if you stop sndiod(8) while playing a song. sio_write() will retry internally if it fails with errno == EINTR so no need to handle that.
This commit is contained in:
		 Dimitris Papastamos
					Dimitris Papastamos
				
			
				
					committed by
					
						 Max Kellermann
						Max Kellermann
					
				
			
			
				
	
			
			
			 Max Kellermann
						Max Kellermann
					
				
			
						parent
						
							cb1082c58c
						
					
				
				
					commit
					d4f801a8e9
				
			| @@ -17,7 +17,6 @@ | |||||||
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <errno.h> |  | ||||||
| #include <sndio.h> | #include <sndio.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| @@ -183,12 +182,12 @@ SndioOutput::Play(const void *chunk, size_t size, Error &error) | |||||||
|  |  | ||||||
| 	while (1) { | 	while (1) { | ||||||
| 		n = sio_write(sio_hdl, chunk, size); | 		n = sio_write(sio_hdl, chunk, size); | ||||||
| 		if (n < 0) { | 		if (n == 0) { | ||||||
| 			if (errno == EINTR) | 			if (sio_eof(sio_hdl)) { | ||||||
| 				continue; | 				error.Set(sndio_output_domain, -1, "sndio write failed"); | ||||||
| 			error.FormatErrno("Failed to write %zu bytes to sndio output", size); |  | ||||||
| 				return 0; | 				return 0; | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
| 		return n; | 		return n; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user