|
@@ -452,7 +452,7 @@ static void qpa_fini_in (HWVoiceIn *hw)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...)
|
|
|
+static void qpa_volume_out(HWVoiceOut *hw, struct mixeng_volume *vol)
|
|
|
{
|
|
|
PAVoiceOut *pa = (PAVoiceOut *) hw;
|
|
|
pa_operation *op;
|
|
@@ -463,49 +463,36 @@ static int qpa_ctl_out (HWVoiceOut *hw, int cmd, ...)
|
|
|
pa_cvolume_init (&v); /* function is present in 0.9.13+ */
|
|
|
#endif
|
|
|
|
|
|
- switch (cmd) {
|
|
|
- case VOICE_VOLUME:
|
|
|
- {
|
|
|
- SWVoiceOut *sw;
|
|
|
- va_list ap;
|
|
|
-
|
|
|
- va_start (ap, cmd);
|
|
|
- sw = va_arg (ap, SWVoiceOut *);
|
|
|
- va_end (ap);
|
|
|
-
|
|
|
- v.channels = 2;
|
|
|
- v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.l) / UINT32_MAX;
|
|
|
- v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.r) / UINT32_MAX;
|
|
|
-
|
|
|
- pa_threaded_mainloop_lock(c->mainloop);
|
|
|
-
|
|
|
- op = pa_context_set_sink_input_volume(c->context,
|
|
|
- pa_stream_get_index (pa->stream),
|
|
|
- &v, NULL, NULL);
|
|
|
- if (!op) {
|
|
|
- qpa_logerr(pa_context_errno(c->context),
|
|
|
- "set_sink_input_volume() failed\n");
|
|
|
- } else {
|
|
|
- pa_operation_unref(op);
|
|
|
- }
|
|
|
-
|
|
|
- op = pa_context_set_sink_input_mute(c->context,
|
|
|
- pa_stream_get_index (pa->stream),
|
|
|
- sw->vol.mute, NULL, NULL);
|
|
|
- if (!op) {
|
|
|
- qpa_logerr(pa_context_errno(c->context),
|
|
|
- "set_sink_input_mute() failed\n");
|
|
|
- } else {
|
|
|
- pa_operation_unref(op);
|
|
|
- }
|
|
|
-
|
|
|
- pa_threaded_mainloop_unlock(c->mainloop);
|
|
|
- }
|
|
|
+ v.channels = 2;
|
|
|
+ v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->l) / UINT32_MAX;
|
|
|
+ v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->r) / UINT32_MAX;
|
|
|
+
|
|
|
+ pa_threaded_mainloop_lock(c->mainloop);
|
|
|
+
|
|
|
+ op = pa_context_set_sink_input_volume(c->context,
|
|
|
+ pa_stream_get_index(pa->stream),
|
|
|
+ &v, NULL, NULL);
|
|
|
+ if (!op) {
|
|
|
+ qpa_logerr(pa_context_errno(c->context),
|
|
|
+ "set_sink_input_volume() failed\n");
|
|
|
+ } else {
|
|
|
+ pa_operation_unref(op);
|
|
|
}
|
|
|
- return 0;
|
|
|
+
|
|
|
+ op = pa_context_set_sink_input_mute(c->context,
|
|
|
+ pa_stream_get_index(pa->stream),
|
|
|
+ vol->mute, NULL, NULL);
|
|
|
+ if (!op) {
|
|
|
+ qpa_logerr(pa_context_errno(c->context),
|
|
|
+ "set_sink_input_mute() failed\n");
|
|
|
+ } else {
|
|
|
+ pa_operation_unref(op);
|
|
|
+ }
|
|
|
+
|
|
|
+ pa_threaded_mainloop_unlock(c->mainloop);
|
|
|
}
|
|
|
|
|
|
-static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...)
|
|
|
+static void qpa_volume_in(HWVoiceIn *hw, struct mixeng_volume *vol)
|
|
|
{
|
|
|
PAVoiceIn *pa = (PAVoiceIn *) hw;
|
|
|
pa_operation *op;
|
|
@@ -516,46 +503,33 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...)
|
|
|
pa_cvolume_init (&v);
|
|
|
#endif
|
|
|
|
|
|
- switch (cmd) {
|
|
|
- case VOICE_VOLUME:
|
|
|
- {
|
|
|
- SWVoiceIn *sw;
|
|
|
- va_list ap;
|
|
|
-
|
|
|
- va_start (ap, cmd);
|
|
|
- sw = va_arg (ap, SWVoiceIn *);
|
|
|
- va_end (ap);
|
|
|
-
|
|
|
- v.channels = 2;
|
|
|
- v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.l) / UINT32_MAX;
|
|
|
- v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * sw->vol.r) / UINT32_MAX;
|
|
|
-
|
|
|
- pa_threaded_mainloop_lock(c->mainloop);
|
|
|
-
|
|
|
- op = pa_context_set_source_output_volume(c->context,
|
|
|
- pa_stream_get_index(pa->stream),
|
|
|
- &v, NULL, NULL);
|
|
|
- if (!op) {
|
|
|
- qpa_logerr(pa_context_errno(c->context),
|
|
|
- "set_source_output_volume() failed\n");
|
|
|
- } else {
|
|
|
- pa_operation_unref(op);
|
|
|
- }
|
|
|
-
|
|
|
- op = pa_context_set_source_output_mute(c->context,
|
|
|
- pa_stream_get_index (pa->stream),
|
|
|
- sw->vol.mute, NULL, NULL);
|
|
|
- if (!op) {
|
|
|
- qpa_logerr(pa_context_errno(c->context),
|
|
|
- "set_source_output_mute() failed\n");
|
|
|
- } else {
|
|
|
- pa_operation_unref (op);
|
|
|
- }
|
|
|
-
|
|
|
- pa_threaded_mainloop_unlock(c->mainloop);
|
|
|
- }
|
|
|
+ v.channels = 2;
|
|
|
+ v.values[0] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->l) / UINT32_MAX;
|
|
|
+ v.values[1] = ((PA_VOLUME_NORM - PA_VOLUME_MUTED) * vol->r) / UINT32_MAX;
|
|
|
+
|
|
|
+ pa_threaded_mainloop_lock(c->mainloop);
|
|
|
+
|
|
|
+ op = pa_context_set_source_output_volume(c->context,
|
|
|
+ pa_stream_get_index(pa->stream),
|
|
|
+ &v, NULL, NULL);
|
|
|
+ if (!op) {
|
|
|
+ qpa_logerr(pa_context_errno(c->context),
|
|
|
+ "set_source_output_volume() failed\n");
|
|
|
+ } else {
|
|
|
+ pa_operation_unref(op);
|
|
|
}
|
|
|
- return 0;
|
|
|
+
|
|
|
+ op = pa_context_set_source_output_mute(c->context,
|
|
|
+ pa_stream_get_index(pa->stream),
|
|
|
+ vol->mute, NULL, NULL);
|
|
|
+ if (!op) {
|
|
|
+ qpa_logerr(pa_context_errno(c->context),
|
|
|
+ "set_source_output_mute() failed\n");
|
|
|
+ } else {
|
|
|
+ pa_operation_unref(op);
|
|
|
+ }
|
|
|
+
|
|
|
+ pa_threaded_mainloop_unlock(c->mainloop);
|
|
|
}
|
|
|
|
|
|
static int qpa_validate_per_direction_opts(Audiodev *dev,
|
|
@@ -724,12 +698,12 @@ static struct audio_pcm_ops qpa_pcm_ops = {
|
|
|
.init_out = qpa_init_out,
|
|
|
.fini_out = qpa_fini_out,
|
|
|
.write = qpa_write,
|
|
|
- .ctl_out = qpa_ctl_out,
|
|
|
+ .volume_out = qpa_volume_out,
|
|
|
|
|
|
.init_in = qpa_init_in,
|
|
|
.fini_in = qpa_fini_in,
|
|
|
.read = qpa_read,
|
|
|
- .ctl_in = qpa_ctl_in
|
|
|
+ .volume_in = qpa_volume_in
|
|
|
};
|
|
|
|
|
|
static struct audio_driver pa_audio_driver = {
|
|
@@ -743,7 +717,6 @@ static struct audio_driver pa_audio_driver = {
|
|
|
.max_voices_in = INT_MAX,
|
|
|
.voice_size_out = sizeof (PAVoiceOut),
|
|
|
.voice_size_in = sizeof (PAVoiceIn),
|
|
|
- .ctl_caps = VOICE_VOLUME_CAP
|
|
|
};
|
|
|
|
|
|
static void register_audio_pa(void)
|