mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Endianess cleaning
This commit is contained in:
		
							parent
							
								
									dbd884fbf4
								
							
						
					
					
						commit
						6a95bf1516
					
				
					 8 changed files with 16 additions and 40 deletions
				
			
		| 
						 | 
					@ -30,7 +30,6 @@
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include "pcm_local.h"
 | 
					#include "pcm_local.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -249,54 +248,42 @@ u_int64_t snd_pcm_format_silence_64(int format)
 | 
				
			||||||
	case SND_PCM_SFMT_U16_LE:
 | 
						case SND_PCM_SFMT_U16_LE:
 | 
				
			||||||
	case SND_PCM_SFMT_U24_LE:
 | 
						case SND_PCM_SFMT_U24_LE:
 | 
				
			||||||
	case SND_PCM_SFMT_U32_LE:
 | 
						case SND_PCM_SFMT_U32_LE:
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return 0x8000800080008000UL;
 | 
							return 0x8000800080008000UL;
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return 0x0080008000800080UL;
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return 0x0080008000800080UL;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_U16_BE:
 | 
						case SND_PCM_SFMT_U16_BE:
 | 
				
			||||||
	case SND_PCM_SFMT_U24_BE:
 | 
						case SND_PCM_SFMT_U24_BE:
 | 
				
			||||||
	case SND_PCM_SFMT_U32_BE:
 | 
						case SND_PCM_SFMT_U32_BE:
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return 0x0000008000000080UL;
 | 
							return 0x0000008000000080UL;
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return 0x8000000080000000UL;
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return 0x8000000080000000UL;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_FLOAT_LE:		
 | 
						case SND_PCM_SFMT_FLOAT_LE:		
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return (float)0.0;
 | 
							return (float)0.0;
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return bswap_32((u_int32_t)((float)0.0));
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return bswap_32((u_int32_t)((float)0.0));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_FLOAT64_LE:
 | 
						case SND_PCM_SFMT_FLOAT64_LE:
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return (double)0.0;
 | 
							return (double)0.0;
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return bswap_64((u_int64_t)((double)0.0));
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return bswap_64((u_int64_t)((double)0.0));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_FLOAT_BE:		
 | 
						case SND_PCM_SFMT_FLOAT_BE:		
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return bswap_32((u_int32_t)((float)0.0));
 | 
							return bswap_32((u_int32_t)((float)0.0));
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return (float)0.0;
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return (float)0.0;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_FLOAT64_BE:
 | 
						case SND_PCM_SFMT_FLOAT64_BE:
 | 
				
			||||||
#if defined(LITTLE_ENDIAN)
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
		return bswap_64((u_int64_t)((double)0.0));
 | 
							return bswap_64((u_int64_t)((double)0.0));
 | 
				
			||||||
#elif defined(BIG_ENDIAN)
 | 
					 | 
				
			||||||
		return (double)0.0;
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "endian"
 | 
							return (double)0.0;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	case SND_PCM_SFMT_IEC958_SUBFRAME_LE:
 | 
						case SND_PCM_SFMT_IEC958_SUBFRAME_LE:
 | 
				
			||||||
	case SND_PCM_SFMT_IEC958_SUBFRAME_BE:
 | 
						case SND_PCM_SFMT_IEC958_SUBFRAME_BE:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,6 @@ IMA compatability project proceedings, Vol 2, Issue 2, May 1992.
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,7 +30,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
| 
						 | 
					@ -116,14 +115,12 @@ int conv_index(int src_format, int dst_format)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sign = (snd_pcm_format_signed(src_format) !=
 | 
						sign = (snd_pcm_format_signed(src_format) !=
 | 
				
			||||||
		snd_pcm_format_signed(dst_format));
 | 
							snd_pcm_format_signed(dst_format));
 | 
				
			||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
	src_endian = snd_pcm_format_big_endian(src_format);
 | 
						src_endian = snd_pcm_format_big_endian(src_format);
 | 
				
			||||||
	dst_endian = snd_pcm_format_big_endian(dst_format);
 | 
						dst_endian = snd_pcm_format_big_endian(dst_format);
 | 
				
			||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
 | 
					#else
 | 
				
			||||||
	src_endian = snd_pcm_format_little_endian(src_format);
 | 
						src_endian = snd_pcm_format_little_endian(src_format);
 | 
				
			||||||
	dst_endian = snd_pcm_format_little_endian(dst_format);
 | 
						dst_endian = snd_pcm_format_little_endian(dst_format);
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#error "Unsupported endian..."
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_endian < 0)
 | 
						if (src_endian < 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,6 @@
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <endian.h>
 | 
					 | 
				
			||||||
#include <byteswap.h>
 | 
					#include <byteswap.h>
 | 
				
			||||||
#include <math.h>
 | 
					#include <math.h>
 | 
				
			||||||
#include "../pcm_local.h"
 | 
					#include "../pcm_local.h"
 | 
				
			||||||
| 
						 | 
					@ -530,12 +529,10 @@ int getput_index(int format)
 | 
				
			||||||
	int sign, width, endian;
 | 
						int sign, width, endian;
 | 
				
			||||||
	sign = !snd_pcm_format_signed(format);
 | 
						sign = !snd_pcm_format_signed(format);
 | 
				
			||||||
	width = snd_pcm_format_width(format) / 8 - 1;
 | 
						width = snd_pcm_format_width(format) / 8 - 1;
 | 
				
			||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
 | 
					#ifdef SND_LITTLE_ENDIAN
 | 
				
			||||||
	endian = snd_pcm_format_big_endian(format);
 | 
						endian = snd_pcm_format_big_endian(format);
 | 
				
			||||||
#elif __BYTE_ORDER == __BIG_ENDIAN
 | 
					 | 
				
			||||||
	endian = snd_pcm_format_little_endian(format);
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#error "Unsupported endian..."
 | 
						endian = snd_pcm_format_little_endian(format);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	if (endian < 0)
 | 
						if (endian < 0)
 | 
				
			||||||
		endian = 0;
 | 
							endian = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue