pcm/Export: DSD_U32 quarters the sample rate
DSD_U32 packs four bytes instead of one large "sample", thus the sample rate is one quarter of the input sample rate. This fixes a rather critical DSD_U32 playback problem.
This commit is contained in:
		
							
								
								
									
										2
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								NEWS
									
									
									
									
									
								
							| @@ -1,6 +1,8 @@ | |||||||
| ver 0.20.2 (not yet released) | ver 0.20.2 (not yet released) | ||||||
| * decoder | * decoder | ||||||
|   - flac: add options "probesize" and "analyzeduration" |   - flac: add options "probesize" and "analyzeduration" | ||||||
|  | * output | ||||||
|  |   - alsa: fix the DSD_U32 sample rate | ||||||
|  |  | ||||||
| ver 0.20.1 (2017/01/09) | ver 0.20.1 (2017/01/09) | ||||||
| * input | * input | ||||||
|   | |||||||
| @@ -101,12 +101,24 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const | |||||||
| unsigned | unsigned | ||||||
| PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const | PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const | ||||||
| { | { | ||||||
|  | #ifdef ENABLE_DSD | ||||||
|  | 	if (dsd_u32) | ||||||
|  | 		/* DSD_U32 combines four 8-bit "samples" in one 32-bit | ||||||
|  | 		   "sample" */ | ||||||
|  | 		sample_rate /= 4; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	return sample_rate; | 	return sample_rate; | ||||||
| } | } | ||||||
|  |  | ||||||
| unsigned | unsigned | ||||||
| PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const | PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const | ||||||
| { | { | ||||||
|  | #ifdef ENABLE_DSD | ||||||
|  | 	if (dsd_u32) | ||||||
|  | 		sample_rate *= 4; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	return sample_rate; | 	return sample_rate; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -146,6 +146,9 @@ PcmExportTest::TestDsdU32() | |||||||
| 	PcmExport::Params params; | 	PcmExport::Params params; | ||||||
| 	params.dsd_u32 = true; | 	params.dsd_u32 = true; | ||||||
|  |  | ||||||
|  | 	CPPUNIT_ASSERT_EQUAL(params.CalcOutputSampleRate(705600u), 176400u); | ||||||
|  | 	CPPUNIT_ASSERT_EQUAL(params.CalcInputSampleRate(176400u), 705600u); | ||||||
|  |  | ||||||
| 	PcmExport e; | 	PcmExport e; | ||||||
| 	e.Open(SampleFormat::DSD, 2, params); | 	e.Open(SampleFormat::DSD, 2, params); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann