2 This file is part of PulseAudio.
4 Copyright 2013 Intel Corporation
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 #include "stream-util.h"
28 #include <pulse/def.h>
30 #include <pulsecore/core-format.h>
31 #include <pulsecore/macro.h>
33 int pa_stream_get_volume_channel_map(const pa_cvolume
*volume
, const pa_channel_map
*original_map
, const pa_format_info
*format
,
34 pa_channel_map
*volume_map
) {
36 pa_channel_map volume_map_local
;
40 pa_assert(volume_map
);
43 if (volume
->channels
== original_map
->channels
) {
44 *volume_map
= *original_map
;
48 if (volume
->channels
== 1) {
49 pa_channel_map_init_mono(volume_map
);
53 pa_log_info("Invalid stream parameters: the volume is incompatible with the channel map.");
54 return -PA_ERR_INVALID
;
57 r
= pa_format_info_get_channel_map(format
, &volume_map_local
);
58 if (r
== -PA_ERR_NOENTITY
) {
59 if (volume
->channels
== 1) {
60 pa_channel_map_init_mono(volume_map
);
64 pa_log_info("Invalid stream parameters: multi-channel volume is set, but channel map is not.");
65 return -PA_ERR_INVALID
;
69 pa_log_info("Invalid channel map.");
70 return -PA_ERR_INVALID
;
73 if (volume
->channels
== volume_map_local
.channels
) {
74 *volume_map
= volume_map_local
;
78 if (volume
->channels
== 1) {
79 pa_channel_map_init_mono(volume_map
);
83 pa_log_info("Invalid stream parameters: the volume is incompatible with the channel map.");
85 return -PA_ERR_INVALID
;