mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	remap: Cleanup remap function selection, add pa_set_remap_func() helper
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
This commit is contained in:
		
							parent
							
								
									3b5868a274
								
							
						
					
					
						commit
						0967f0fcdc
					
				
					 4 changed files with 22 additions and 40 deletions
				
			
		| 
						 | 
					@ -166,6 +166,19 @@ bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pa_set_remap_func(pa_remap_t *m, pa_do_remap_func_t func_s16,
 | 
				
			||||||
 | 
					    pa_do_remap_func_t func_float) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (m->format == PA_SAMPLE_S16NE)
 | 
				
			||||||
 | 
					        m->do_remap = func_s16;
 | 
				
			||||||
 | 
					    else if (m->format == PA_SAMPLE_FLOAT32NE)
 | 
				
			||||||
 | 
					        m->do_remap = func_float;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        pa_assert_not_reached();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* set the function that will execute the remapping based on the matrices */
 | 
					/* set the function that will execute the remapping based on the matrices */
 | 
				
			||||||
static void init_remap_c(pa_remap_t *m) {
 | 
					static void init_remap_c(pa_remap_t *m) {
 | 
				
			||||||
    unsigned n_oc, n_ic;
 | 
					    unsigned n_oc, n_ic;
 | 
				
			||||||
| 
						 | 
					@ -178,28 +191,12 @@ static void init_remap_c(pa_remap_t *m) {
 | 
				
			||||||
            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
					            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_log_info("Using mono to stereo remapping");
 | 
					        pa_log_info("Using mono to stereo remapping");
 | 
				
			||||||
        switch (m->format) {
 | 
					        pa_set_remap_func(m, (pa_do_remap_func_t) remap_mono_to_stereo_s16ne_c,
 | 
				
			||||||
        case PA_SAMPLE_S16NE:
 | 
					            (pa_do_remap_func_t) remap_mono_to_stereo_float32ne_c);
 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_s16ne_c;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        case PA_SAMPLE_FLOAT32NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_float32ne_c;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            pa_assert_not_reached();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        pa_log_info("Using generic matrix remapping");
 | 
					        pa_log_info("Using generic matrix remapping");
 | 
				
			||||||
        switch (m->format) {
 | 
					
 | 
				
			||||||
        case PA_SAMPLE_S16NE:
 | 
					        pa_set_remap_func(m, remap_channels_matrix_s16ne_c, remap_channels_matrix_float32ne_c);
 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_channels_matrix_s16ne_c;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        case PA_SAMPLE_FLOAT32NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_channels_matrix_float32ne_c;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            pa_assert_not_reached();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,4 +55,7 @@ void pa_set_init_remap_func(pa_init_remap_func_t func);
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]);
 | 
					bool pa_setup_remap_arrange(const pa_remap_t *m, int8_t arrange[PA_CHANNELS_MAX]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pa_set_remap_func(pa_remap_t *m, pa_do_remap_func_t func_s16,
 | 
				
			||||||
 | 
					    pa_do_remap_func_t func_float);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* fooremapfoo */
 | 
					#endif /* fooremapfoo */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,16 +136,7 @@ static void init_remap_mmx(pa_remap_t *m) {
 | 
				
			||||||
            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
					            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_log_info("Using MMX mono to stereo remapping");
 | 
					        pa_log_info("Using MMX mono to stereo remapping");
 | 
				
			||||||
        switch (m->format) {
 | 
					        pa_set_remap_func(m, remap_mono_to_stereo_s16ne_mmx, remap_mono_to_stereo_float32ne_mmx);
 | 
				
			||||||
        case PA_SAMPLE_S16NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_s16ne_mmx;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        case PA_SAMPLE_FLOAT32NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_float32ne_mmx;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            pa_assert_not_reached();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* defined (__i386__) || defined (__amd64__) */
 | 
					#endif /* defined (__i386__) || defined (__amd64__) */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,16 +135,7 @@ static void init_remap_sse2(pa_remap_t *m) {
 | 
				
			||||||
            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
					            m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_log_info("Using SSE2 mono to stereo remapping");
 | 
					        pa_log_info("Using SSE2 mono to stereo remapping");
 | 
				
			||||||
        switch (m->format) {
 | 
					        pa_set_remap_func(m, remap_mono_to_stereo_s16ne_sse2, remap_mono_to_stereo_float32ne_sse2);
 | 
				
			||||||
        case PA_SAMPLE_S16NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_s16ne_sse2;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        case PA_SAMPLE_FLOAT32NE:
 | 
					 | 
				
			||||||
            m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_float32ne_sse2;
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            pa_assert_not_reached();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* defined (__i386__) || defined (__amd64__) */
 | 
					#endif /* defined (__i386__) || defined (__amd64__) */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue