From: Lennart Poettering Date: Sat, 31 Jan 2009 00:17:09 +0000 (+0100) Subject: implement pa_channel_map_can_fade X-Git-Tag: submit/2.0-panda/20130828.192557~2318 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b979ab39482a7ebf9eb1725b5a17141d1afce3d8;p=profile%2Fivi%2Fpulseaudio-panda.git implement pa_channel_map_can_fade --- diff --git a/src/map-file b/src/map-file index e076a43..3aa1d7a 100644 --- a/src/map-file +++ b/src/map-file @@ -10,6 +10,7 @@ pa_bytes_per_second; pa_bytes_snprint; pa_bytes_to_usec; pa_channel_map_can_balance; +pa_channel_map_can_fade; pa_channel_map_compatible; pa_channel_map_equal; pa_channel_map_init; diff --git a/src/pulse/channelmap.c b/src/pulse/channelmap.c index 455bda1..6ff30c2 100644 --- a/src/pulse/channelmap.c +++ b/src/pulse/channelmap.c @@ -647,30 +647,77 @@ int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) { int pa_channel_map_can_balance(const pa_channel_map *map) { unsigned c; + pa_bool_t left = FALSE, right = FALSE; pa_assert(map); - for (c = 0; c < map->channels; c++) + for (c = 0; c < map->channels; c++) { switch (map->map[c]) { case PA_CHANNEL_POSITION_LEFT: - case PA_CHANNEL_POSITION_RIGHT: case PA_CHANNEL_POSITION_REAR_LEFT: - case PA_CHANNEL_POSITION_REAR_RIGHT: case PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: - case PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: case PA_CHANNEL_POSITION_SIDE_LEFT: + case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: + case PA_CHANNEL_POSITION_TOP_REAR_LEFT: + left = TRUE; + break; + + case PA_CHANNEL_POSITION_RIGHT: + case PA_CHANNEL_POSITION_REAR_RIGHT: + case PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: case PA_CHANNEL_POSITION_SIDE_RIGHT: + case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: + case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: + right = TRUE; + break; + + default: + ; + } + + if (left && right) + return 1; + } + + return 0; +} + +int pa_channel_map_can_fade(const pa_channel_map *map) { + unsigned c; + pa_bool_t front = FALSE, rear = FALSE; + + for (c = 0; c < map->channels; c++) { + + switch (map->map[c]) { + case PA_CHANNEL_POSITION_FRONT_LEFT: + case PA_CHANNEL_POSITION_FRONT_RIGHT: + case PA_CHANNEL_POSITION_FRONT_CENTER: + case PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: + case PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: + case PA_CHANNEL_POSITION_TOP_FRONT_CENTER: + front = TRUE; + break; + + case PA_CHANNEL_POSITION_REAR_LEFT: + case PA_CHANNEL_POSITION_REAR_RIGHT: + case PA_CHANNEL_POSITION_REAR_CENTER: case PA_CHANNEL_POSITION_TOP_REAR_LEFT: case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: - return 1; + case PA_CHANNEL_POSITION_TOP_REAR_CENTER: + rear = TRUE; + break; default: ; } + if (front && rear) + return 1; + } + return 0; } diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h index de2d712..f9124b2 100644 --- a/src/pulse/channelmap.h +++ b/src/pulse/channelmap.h @@ -239,6 +239,11 @@ int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) PA * available. \since 0.9.15 */ int pa_channel_map_can_balance(const pa_channel_map *map) PA_GCC_PURE; +/** Returns non-zero if it makes sense to apply a volume 'fade' + * (i.e. 'balance' between front and rear) with this mapping, i.e. if + * there are front/rear channels available. \since 0.9.15 */ +int pa_channel_map_can_fade(const pa_channel_map *map) PA_GCC_PURE; + /** Tries to find a well-known channel mapping name for this channel * mapping. I.e. "stereo", "surround-71" and so on. If the channel * mapping is unknown NULL will be returned. This name can be parsed