Mercurial > audlegacy
comparison src/audacious/output.c @ 4259:92642f860860
- added template for src_flow
- vis_flow can work now with FMT_FLOAT, but disabled pending src stuff refactoring
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Sat, 09 Feb 2008 01:05:36 +0300 |
parents | 8157686b8115 |
children | 2b7a74fce100 a41fb6bc632a |
comparison
equal
deleted
inserted
replaced
4258:8157686b8115 | 4259:92642f860860 |
---|---|
43 #include "effect.h" | 43 #include "effect.h" |
44 #include "volumecontrol.h" | 44 #include "volumecontrol.h" |
45 #include "visualization.h" | 45 #include "visualization.h" |
46 | 46 |
47 #include "libSAD.h" | 47 #include "libSAD.h" |
48 #include "util.h" | |
48 | 49 |
49 #include <math.h> | 50 #include <math.h> |
50 | 51 |
51 #ifdef USE_SRC | 52 #ifdef USE_SRC |
52 #include <samplerate.h> | 53 #include <samplerate.h> |
81 .buffer_playing = output_buffer_playing, | 82 .buffer_playing = output_buffer_playing, |
82 .output_time = get_output_time, | 83 .output_time = get_output_time, |
83 .written_time = get_written_time, | 84 .written_time = get_written_time, |
84 }; | 85 }; |
85 | 86 |
86 static const struct { | |
87 AFormat afmt; | |
88 SAD_sample_format sadfmt; | |
89 } format_table[] = { | |
90 {FMT_U8, SAD_SAMPLE_U8}, | |
91 {FMT_S8, SAD_SAMPLE_S8}, | |
92 | |
93 {FMT_S16_LE, SAD_SAMPLE_S16_LE}, | |
94 {FMT_S16_BE, SAD_SAMPLE_S16_BE}, | |
95 {FMT_S16_NE, SAD_SAMPLE_S16}, | |
96 | |
97 {FMT_U16_LE, SAD_SAMPLE_U16_LE}, | |
98 {FMT_U16_BE, SAD_SAMPLE_U16_BE}, | |
99 {FMT_U16_NE, SAD_SAMPLE_U16}, | |
100 | |
101 {FMT_S24_LE, SAD_SAMPLE_S24_LE}, | |
102 {FMT_S24_BE, SAD_SAMPLE_S24_BE}, | |
103 {FMT_S24_NE, SAD_SAMPLE_S24}, | |
104 | |
105 {FMT_U24_LE, SAD_SAMPLE_U24_LE}, | |
106 {FMT_U24_BE, SAD_SAMPLE_U24_BE}, | |
107 {FMT_U24_NE, SAD_SAMPLE_U24}, | |
108 | |
109 {FMT_S32_LE, SAD_SAMPLE_S32_LE}, | |
110 {FMT_S32_BE, SAD_SAMPLE_S32_BE}, | |
111 {FMT_S32_NE, SAD_SAMPLE_S32}, | |
112 | |
113 {FMT_U32_LE, SAD_SAMPLE_U32_LE}, | |
114 {FMT_U32_BE, SAD_SAMPLE_U32_BE}, | |
115 {FMT_U32_NE, SAD_SAMPLE_U32}, | |
116 | |
117 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, | |
118 {FMT_FIXED32, SAD_SAMPLE_FIXED32}, | |
119 }; | |
120 | |
121 static void apply_replaygain_info (ReplayGainInfo *rg_info); | 87 static void apply_replaygain_info (ReplayGainInfo *rg_info); |
122 | |
123 static SAD_sample_format | |
124 sadfmt_from_afmt(AFormat fmt) | |
125 { | |
126 int i; | |
127 for (i = 0; i < sizeof(format_table) / sizeof(format_table[0]); i++) { | |
128 if (format_table[i].afmt == fmt) return format_table[i].sadfmt; | |
129 } | |
130 | |
131 return -1; | |
132 } | |
133 | 88 |
134 OutputPlugin * | 89 OutputPlugin * |
135 get_current_output_plugin(void) | 90 get_current_output_plugin(void) |
136 { | 91 { |
137 return op_data.current_output_plugin; | 92 return op_data.current_output_plugin; |
604 gpointer ptr, /* data */ | 559 gpointer ptr, /* data */ |
605 int *going /* 0 when time to stop */ | 560 int *going /* 0 when time to stop */ |
606 ) | 561 ) |
607 { | 562 { |
608 static Flow *postproc_flow = NULL; | 563 static Flow *postproc_flow = NULL; |
564 static Flow *legacy_flow = NULL; | |
609 OutputPlugin *op = playback->output; | 565 OutputPlugin *op = playback->output; |
610 gint writeoffs; | 566 gint writeoffs; |
611 | 567 |
612 if (length <= 0) return; | 568 if (length <= 0) return; |
613 gint time = playback->output->written_time(); | 569 gint time = playback->output->written_time(); |
614 | 570 |
571 if (legacy_flow == NULL) | |
572 { | |
573 legacy_flow = flow_new(); | |
574 flow_link_element(legacy_flow, iir_flow); | |
575 flow_link_element(legacy_flow, effect_flow); | |
576 flow_link_element(legacy_flow, volumecontrol_flow); | |
577 } | |
578 | |
615 if (postproc_flow == NULL) | 579 if (postproc_flow == NULL) |
616 { | 580 { |
617 postproc_flow = flow_new(); | 581 postproc_flow = flow_new(); |
618 flow_link_element(postproc_flow, iir_flow); | |
619 flow_link_element(postproc_flow, effect_flow); | |
620 flow_link_element(postproc_flow, vis_flow); | 582 flow_link_element(postproc_flow, vis_flow); |
621 flow_link_element(postproc_flow, volumecontrol_flow); | |
622 } | 583 } |
623 | 584 |
624 #ifdef USE_SRC | 585 #ifdef USE_SRC |
625 if(src_state != NULL) | 586 if(src_state != NULL) |
626 { | 587 { |
627 /*int lrLength = length / nch;*/ | |
628 int lrLength = length / FMT_SIZEOF(fmt); | 588 int lrLength = length / FMT_SIZEOF(fmt); |
629 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); | 589 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); |
630 if(lengthOfSrcIn < lrLength) | 590 if(lengthOfSrcIn < lrLength) |
631 { | 591 { |
632 lengthOfSrcIn = lrLength; | 592 lengthOfSrcIn = lrLength; |
639 free(srcOut); | 599 free(srcOut); |
640 free(wOut); | 600 free(wOut); |
641 srcOut = (float*)malloc(sizeof(float)*overLrLength); | 601 srcOut = (float*)malloc(sizeof(float)*overLrLength); |
642 wOut = (short int*)malloc(FMT_SIZEOF(op_state.fmt) * overLrLength); | 602 wOut = (short int*)malloc(FMT_SIZEOF(op_state.fmt) * overLrLength); |
643 } | 603 } |
644 /*src_short_to_float_array((short int*)ptr, srcIn, lrLength);*/ | 604 |
645 SAD_dither_process_buffer(sad_state_to_float, ptr, srcIn, lrLength / nch); | 605 SAD_dither_process_buffer(sad_state_to_float, ptr, srcIn, lrLength / nch); |
606 /*flow_execute(postproc_flow, time, &srcIn, lrLength * sizeof(float), FMT_FLOAT, op_state.rate, nch);*/ /*FIXME*/ | |
607 | |
608 | |
646 src_data.data_in = srcIn; | 609 src_data.data_in = srcIn; |
647 src_data.data_out = srcOut; | 610 src_data.data_out = srcOut; |
648 src_data.end_of_input = 0; | 611 src_data.end_of_input = 0; |
649 src_data.input_frames = lrLength / nch; | 612 src_data.input_frames = lrLength / nch; |
650 src_data.output_frames = overLrLength / nch; | 613 src_data.output_frames = overLrLength / nch; |
652 { | 615 { |
653 fprintf(stderr, "src_process(): %s\n", src_strerror(srcError)); | 616 fprintf(stderr, "src_process(): %s\n", src_strerror(srcError)); |
654 } | 617 } |
655 else | 618 else |
656 { | 619 { |
657 /*src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2);*/ | |
658 SAD_dither_process_buffer(sad_state_from_float, srcOut, wOut, src_data.output_frames_gen); | 620 SAD_dither_process_buffer(sad_state_from_float, srcOut, wOut, src_data.output_frames_gen); |
659 ptr = wOut; | 621 ptr = wOut; |
660 length = src_data.output_frames_gen * op_state.nch * FMT_SIZEOF(op_state.fmt); | 622 length = src_data.output_frames_gen * op_state.nch * FMT_SIZEOF(op_state.fmt); |
661 } | 623 } |
662 } else | 624 } else |
674 length = len; | 636 length = len; |
675 } | 637 } |
676 | 638 |
677 if (op_state.fmt == FMT_S16_NE || (op_state.fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || | 639 if (op_state.fmt == FMT_S16_NE || (op_state.fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || |
678 (op_state.fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) { | 640 (op_state.fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) { |
679 length = flow_execute(postproc_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch); | 641 length = flow_execute(legacy_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch); |
680 } else { | 642 } else { |
681 AUDDBG("postproc_flow can deal only with S16_NE streams\n"); /*FIXME*/ | 643 AUDDBG("legacy_flow can deal only with S16_NE streams\n"); /*FIXME*/ |
682 } | 644 } |
683 | 645 |
684 writeoffs = 0; | 646 writeoffs = 0; |
685 while (writeoffs < length) | 647 while (writeoffs < length) |
686 { | 648 { |