static SNDFILE* sndfile = NULL;
-static pa_sample_spec sample_spec = { 0, 0, 0 };
+static pa_sample_spec sample_spec = { 0, 0, 0 };
+static pa_channel_map channel_map;
+static int channel_map_set = 0;
static sf_count_t (*readf_function)(SNDFILE *_sndfile, void *ptr, sf_count_t frames);
if (verbose)
fprintf(stderr, "Connection established.\n");
- stream = pa_stream_new(c, stream_name, &sample_spec, NULL);
+ stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL);
assert(stream);
pa_stream_set_state_callback(stream, stream_state_callback, NULL);
" -d, --device=DEVICE The name of the sink/source to connect to\n"
" -n, --client-name=NAME How to call this client on the server\n"
" --stream-name=NAME How to call this stream on the server\n"
- " --volume=VOLUME Specify the initial (linear) volume in range 0...256\n",
+ " --volume=VOLUME Specify the initial (linear) volume in range 0...65536\n"
+ " --channel-map=CHANNELMAP Set the channel map to the use\n",
argv0);
}
enum {
ARG_VERSION = 256,
ARG_STREAM_NAME,
- ARG_VOLUME
+ ARG_VOLUME,
+ ARG_CHANNELMAP
};
int main(int argc, char *argv[]) {
{"help", 0, NULL, 'h'},
{"verbose", 0, NULL, 'v'},
{"volume", 1, NULL, ARG_VOLUME},
+ {"channel-map", 1, NULL, ARG_CHANNELMAP},
{NULL, 0, NULL, 0}
};
break;
}
+ case ARG_CHANNELMAP:
+ if (!pa_channel_map_parse(&channel_map, optarg)) {
+ fprintf(stderr, "Invalid channel map\n");
+ goto quit;
+ }
+
+ channel_map_set = 1;
+ break;
+
default:
goto quit;
}
break;
}
+ assert(pa_sample_spec_valid(&sample_spec));
+
+ if (channel_map_set && channel_map.channels != sample_spec.channels) {
+ fprintf(stderr, "Channel map doesn't match file.\n");
+ goto quit;
+ }
+
if (verbose) {
char t[PA_SAMPLE_SPEC_SNPRINT_MAX];
pa_sample_spec_snprint(t, sizeof(t), &sample_spec);