audio_format, output_thread: add more audio_format_valid() assertions
This commit is contained in:
		@@ -22,6 +22,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <stdbool.h>
 | 
					#include <stdbool.h>
 | 
				
			||||||
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum sample_format {
 | 
					enum sample_format {
 | 
				
			||||||
	SAMPLE_FORMAT_UNDEFINED = 0,
 | 
						SAMPLE_FORMAT_UNDEFINED = 0,
 | 
				
			||||||
@@ -219,6 +220,9 @@ static inline void
 | 
				
			|||||||
audio_format_mask_apply(struct audio_format *af,
 | 
					audio_format_mask_apply(struct audio_format *af,
 | 
				
			||||||
			const struct audio_format *mask)
 | 
								const struct audio_format *mask)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						assert(audio_format_valid(af));
 | 
				
			||||||
 | 
						assert(audio_format_mask_valid(mask));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mask->sample_rate != 0)
 | 
						if (mask->sample_rate != 0)
 | 
				
			||||||
		af->sample_rate = mask->sample_rate;
 | 
							af->sample_rate = mask->sample_rate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -227,6 +231,8 @@ audio_format_mask_apply(struct audio_format *af,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (mask->channels != 0)
 | 
						if (mask->channels != 0)
 | 
				
			||||||
		af->channels = mask->channels;
 | 
							af->channels = mask->channels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						assert(audio_format_valid(af));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -192,6 +192,7 @@ audio_format_parse(struct audio_format *dest, const char *src,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	audio_format_init(dest, rate, sample_format, channels);
 | 
						audio_format_init(dest, rate, sample_format, channels);
 | 
				
			||||||
 | 
						assert(audio_format_valid(dest));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,6 +115,7 @@ audio_output_open(struct audio_output *ao,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	bool open;
 | 
						bool open;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						assert(audio_format_valid(audio_format));
 | 
				
			||||||
	assert(mp != NULL);
 | 
						assert(mp != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ao->fail_timer != NULL) {
 | 
						if (ao->fail_timer != NULL) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,6 +95,8 @@ ao_filter_open(struct audio_output *ao,
 | 
				
			|||||||
	       struct audio_format *audio_format,
 | 
						       struct audio_format *audio_format,
 | 
				
			||||||
	       GError **error_r)
 | 
						       GError **error_r)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						assert(audio_format_valid(audio_format));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* the replay_gain filter cannot fail here */
 | 
						/* the replay_gain filter cannot fail here */
 | 
				
			||||||
	if (ao->replay_gain_filter != NULL)
 | 
						if (ao->replay_gain_filter != NULL)
 | 
				
			||||||
		filter_open(ao->replay_gain_filter, audio_format, error_r);
 | 
							filter_open(ao->replay_gain_filter, audio_format, error_r);
 | 
				
			||||||
@@ -136,6 +138,7 @@ ao_open(struct audio_output *ao)
 | 
				
			|||||||
	assert(!ao->open);
 | 
						assert(!ao->open);
 | 
				
			||||||
	assert(ao->pipe != NULL);
 | 
						assert(ao->pipe != NULL);
 | 
				
			||||||
	assert(ao->chunk == NULL);
 | 
						assert(ao->chunk == NULL);
 | 
				
			||||||
 | 
						assert(audio_format_valid(&ao->in_audio_format));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ao->fail_timer != NULL) {
 | 
						if (ao->fail_timer != NULL) {
 | 
				
			||||||
		/* this can only happen when this
 | 
							/* this can only happen when this
 | 
				
			||||||
@@ -164,6 +167,8 @@ ao_open(struct audio_output *ao)
 | 
				
			|||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						assert(audio_format_valid(filter_audio_format));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ao->out_audio_format = *filter_audio_format;
 | 
						ao->out_audio_format = *filter_audio_format;
 | 
				
			||||||
	audio_format_mask_apply(&ao->out_audio_format,
 | 
						audio_format_mask_apply(&ao->out_audio_format,
 | 
				
			||||||
				&ao->config_audio_format);
 | 
									&ao->config_audio_format);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user