diff options
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/card.c | 3 | ||||
-rw-r--r-- | src/pulsecore/ffmpeg/resample2.c | 27 | ||||
-rw-r--r-- | src/pulsecore/sink.c | 69 | ||||
-rw-r--r-- | src/pulsecore/sink.h | 3 | ||||
-rw-r--r-- | src/pulsecore/source.c | 3 |
5 files changed, 79 insertions, 26 deletions
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c index 515d1f90..94064c72 100644 --- a/src/pulsecore/card.c +++ b/src/pulsecore/card.c @@ -160,6 +160,9 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) { c->userdata = NULL; c->set_profile = NULL; + pa_device_init_description(c->proplist); + pa_device_init_icon(c->proplist, TRUE); + pa_assert_se(pa_idxset_put(core->cards, c, &c->index) >= 0); pa_log_info("Created %u \"%s\"", c->index, c->name); diff --git a/src/pulsecore/ffmpeg/resample2.c b/src/pulsecore/ffmpeg/resample2.c index ed59448a..ac9db73c 100644 --- a/src/pulsecore/ffmpeg/resample2.c +++ b/src/pulsecore/ffmpeg/resample2.c @@ -20,7 +20,7 @@ */ /** - * @file resample2.c + * @file libavcodec/resample2.c * audio resampling * @author Michael Niedermayer <michaelni@gmx.at> */ @@ -175,10 +175,6 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun #endif } -/** - * Initializes an audio resampler. - * Note, if either rate is not an integer then simply scale both rates up so they are. - */ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ AVResampleContext *c= av_mallocz(sizeof(AVResampleContext)); double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); @@ -206,33 +202,12 @@ void av_resample_close(AVResampleContext *c){ av_freep(&c); } -/** - * Compensates samplerate/timestamp drift. The compensation is done by changing - * the resampler parameters, so no audible clicks or similar distortions occur - * @param compensation_distance distance in output samples over which the compensation should be performed - * @param sample_delta number of output samples which should be output less - * - * example: av_resample_compensate(c, 10, 500) - * here instead of 510 samples only 500 samples would be output - * - * note, due to rounding the actual compensation might be slightly different, - * especially if the compensation_distance is large and the in_rate used during init is small - */ void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){ // sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr; c->compensation_distance= compensation_distance; c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance; } -/** - * resamples. - * @param src an array of unconsumed samples - * @param consumed the number of samples of src which have been consumed are returned here - * @param src_size the number of unconsumed samples available - * @param dst_size the amount of space in samples available in dst - * @param update_ctx if this is 0 then the context wont be modified, that way several channels can be resampled with the same context - * @return the number of samples written in dst or -1 if an error occurred - */ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){ int dst_index, i; int index= c->index; diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 7441e971..fadbb857 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -33,6 +33,7 @@ #include <pulse/xmalloc.h> #include <pulse/timeval.h> #include <pulse/util.h> +#include <pulse/i18n.h> #include <pulsecore/sink-input.h> #include <pulsecore/namereg.h> @@ -172,6 +173,9 @@ pa_sink* pa_sink_new( if (data->card) pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist); + pa_device_init_description(data->proplist); + pa_device_init_icon(data->proplist, TRUE); + if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_FIXATE], data) < 0) { pa_xfree(s); pa_namereg_unregister(core, name); @@ -1886,3 +1890,68 @@ size_t pa_sink_get_max_request(pa_sink *s) { return r; } + +/* Called from main context */ +pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink) { + const char *ff, *t = NULL, *s = "", *profile, *bus; + + pa_assert(p); + + if (pa_proplist_contains(p, PA_PROP_DEVICE_ICON_NAME)) + return TRUE; + + if ((ff = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) { + + if (pa_streq(ff, "microphone")) + t = "audio-input-microphone"; + else if (pa_streq(ff, "webcam")) + t = "camera-web"; + else if (pa_streq(ff, "computer")) + t = "computer"; + else if (pa_streq(ff, "handset")) + t = "phone"; + } + + if (!t) { + if (is_sink) + t = "audio-card"; + else + t = "audio-input-microphone"; + } + + if ((profile = pa_proplist_gets(p, PA_PROP_DEVICE_PROFILE_NAME))) { + if (strstr(profile, "analog")) + s = "-analog"; + else if (strstr(profile, "iec958")) + s = "-iec958"; + else if (strstr(profile, "hdmi")) + s = "-hdmi"; + } + + bus = pa_proplist_gets(p, PA_PROP_DEVICE_BUS); + + pa_proplist_setf(p, PA_PROP_DEVICE_ICON_NAME, "%s%s%s%s", t, pa_strempty(s), bus ? "-" : "", pa_strempty(bus)); + + return TRUE; +} + +pa_bool_t pa_device_init_description(pa_proplist *p) { + const char *s; + pa_assert(p); + + if (pa_proplist_contains(p, PA_PROP_DEVICE_DESCRIPTION)) + return TRUE; + + if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_FORM_FACTOR))) + if (pa_streq(s, "internal")) { + pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, _("Internal Audio")); + return TRUE; + } + + if ((s = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_NAME))) { + pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, s); + return TRUE; + } + + return FALSE; +} diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 124b4e11..2eaae697 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -225,6 +225,9 @@ void pa_sink_attach(pa_sink *s); void pa_sink_set_soft_volume(pa_sink *s, const pa_cvolume *volume); +pa_bool_t pa_device_init_description(pa_proplist *p); +pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink); + /**** May be called by everyone, from main context */ /* The returned value is supposed to be in the time domain of the sound card! */ diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index c0d6d9ea..4ce5cbfe 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -163,6 +163,9 @@ pa_source* pa_source_new( if (data->card) pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->card->proplist); + pa_device_init_description(data->proplist); + pa_device_init_icon(data->proplist, FALSE); + if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_FIXATE], data) < 0) { pa_xfree(s); pa_namereg_unregister(core, name); |