mirror of
				https://github.com/alsa-project/alsa-tools.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Fixed big-endian support
This commit is contained in:
		
							parent
							
								
									3343a6b188
								
							
						
					
					
						commit
						365af335eb
					
				
					 2 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
					@ -154,7 +154,7 @@ output_spdif(uint8_t *data_start, uint8_t *data_end, int quiet)
 | 
				
			||||||
        done_banner = 1;
 | 
					        done_banner = 1;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
#ifndef WORDS_BIGENDIAN
 | 
					#ifndef _a_b_c_d_e_f /* WORDS_BIGENDIAN */
 | 
				
			||||||
      // extract_ac3 seems to write swabbed data
 | 
					      // extract_ac3 seems to write swabbed data
 | 
				
			||||||
      swab(&buf[10], &buf[10], syncinfo.frame_size * 2 - 2);
 | 
					      swab(&buf[10], &buf[10], syncinfo.frame_size * 2 - 2);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,6 +41,7 @@ int output_open(output_t *output)
 | 
				
			||||||
	char devstr[128];
 | 
						char devstr[128];
 | 
				
			||||||
	snd_pcm_hw_params_t *params;
 | 
						snd_pcm_hw_params_t *params;
 | 
				
			||||||
	unsigned int rate, buffer_time, period_time, tmp;
 | 
						unsigned int rate, buffer_time, period_time, tmp;
 | 
				
			||||||
 | 
						snd_pcm_format_t format = output->bits == 16 ? SND_PCM_FORMAT_S16 : SND_PCM_FORMAT_U8;
 | 
				
			||||||
	int err, step;
 | 
						int err, step;
 | 
				
			||||||
	snd_pcm_hw_params_alloca(¶ms);
 | 
						snd_pcm_hw_params_alloca(¶ms);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,6 +77,7 @@ int output_open(output_t *output)
 | 
				
			||||||
				sprintf(devstr, "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", s[0], s[1], s[2], s[3]);
 | 
									sprintf(devstr, "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", s[0], s[1], s[2], s[3]);
 | 
				
			||||||
				if (out_config.card)
 | 
									if (out_config.card)
 | 
				
			||||||
					sprintf(devstr + strlen(devstr), ",CARD=%s", out_config.card);
 | 
										sprintf(devstr + strlen(devstr), ",CARD=%s", out_config.card);
 | 
				
			||||||
 | 
									format = SND_PCM_FORMAT_S16_LE;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				if (out_config.card)
 | 
									if (out_config.card)
 | 
				
			||||||
					sprintf(devstr, "plughw:%s", out_config.card);
 | 
										sprintf(devstr, "plughw:%s", out_config.card);
 | 
				
			||||||
| 
						 | 
					@ -114,29 +116,29 @@ int output_open(output_t *output)
 | 
				
			||||||
	err = snd_pcm_hw_params_set_access(pcm, params,
 | 
						err = snd_pcm_hw_params_set_access(pcm, params,
 | 
				
			||||||
					   SND_PCM_ACCESS_RW_INTERLEAVED);
 | 
										   SND_PCM_ACCESS_RW_INTERLEAVED);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		fprintf(stderr, "Access type not available");
 | 
							fprintf(stderr, "Access type not available\n");
 | 
				
			||||||
		goto __close;
 | 
							goto __close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	err = snd_pcm_hw_params_set_format(pcm, params, output->bits == 16 ? SND_PCM_FORMAT_S16_LE : SND_PCM_FORMAT_U8);
 | 
						err = snd_pcm_hw_params_set_format(pcm, params, format);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		fprintf(stderr, "Sample format non available");
 | 
							fprintf(stderr, "Sample format non available\n");
 | 
				
			||||||
		goto __close;
 | 
							goto __close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	err = snd_pcm_hw_params_set_channels(pcm, params, output->channels);
 | 
						err = snd_pcm_hw_params_set_channels(pcm, params, output->channels);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		fprintf(stderr, "Channels count non available");
 | 
							fprintf(stderr, "Channels count non available\n");
 | 
				
			||||||
		goto __close;
 | 
							goto __close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rate = output->rate;
 | 
						rate = output->rate;
 | 
				
			||||||
	err = snd_pcm_hw_params_set_rate_near(pcm, params, &rate, 0);
 | 
						err = snd_pcm_hw_params_set_rate_near(pcm, params, &rate, 0);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		fprintf(stderr, "Rate not available");
 | 
							fprintf(stderr, "Rate not available\n");
 | 
				
			||||||
		goto __close;
 | 
							goto __close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	buffer_time = 500000;
 | 
						buffer_time = 500000;
 | 
				
			||||||
	err = snd_pcm_hw_params_set_buffer_time_near(pcm, params, &buffer_time, 0);
 | 
						err = snd_pcm_hw_params_set_buffer_time_near(pcm, params, &buffer_time, 0);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
		fprintf(stderr, "Buffer time not available");
 | 
							fprintf(stderr, "Buffer time not available\n");
 | 
				
			||||||
		goto __close;
 | 
							goto __close;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	step = 2;
 | 
						step = 2;
 | 
				
			||||||
| 
						 | 
					@ -146,7 +148,7 @@ int output_open(output_t *output)
 | 
				
			||||||
		tmp = period_time;
 | 
							tmp = period_time;
 | 
				
			||||||
		err = snd_pcm_hw_params_set_period_time_near(pcm, params, &tmp, 0);
 | 
							err = snd_pcm_hw_params_set_period_time_near(pcm, params, &tmp, 0);
 | 
				
			||||||
		if (err < 0) {
 | 
							if (err < 0) {
 | 
				
			||||||
			fprintf(stderr, "Period time not available");
 | 
								fprintf(stderr, "Period time not available\n");
 | 
				
			||||||
			goto __close;
 | 
								goto __close;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (tmp == period_time) {
 | 
							if (tmp == period_time) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue