Commit 2e6aceb4 authored by Arnaud Ferraris's avatar Arnaud Ferraris
Browse files

New upstream version 0.0.5

parents af965913 5885e981
......@@ -18,6 +18,7 @@ dbus_interfaces = [ 'org.mobian_project.CallAudio.xml' ]
generated_dbus_sources += gnome.gdbus_codegen('callaudio-dbus',
sources : dbus_interfaces,
object_manager : false,
docbook : 'libcallaudio',
interface_prefix : dbus_prefix,
install_header : false,
namespace : dbus_namespace)
......
<?xml version="1.0" encoding="UTF-8" ?>
<node>
<!-- org.mobian_project.CallAudio
@short_description: call related audio interface
This D-Bus interface is used to select audio modes
and access other related audio functionality in
a mobile phone context.
-->
<interface name="org.mobian_project.CallAudio">
<!--
......
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
%gtkdocentities;
]>
<book id="index">
<bookinfo>
<title>&package_name; Reference Manual</title>
<releaseinfo>
<para>This document is the API reference for &package_name; &package_version;</para>
<para>
<ulink type="http" url="&package_url;">Libcallaudio</ulink> is a library to allow
setting audio call (f.e. mobile phone environment) related settings by your application.
</para>
<para>
If you find any issues in this API reference, please report it using
<ulink type="http" url="&package_bugreport;">the bugtracker</ulink>.
</para>
</releaseinfo>
<copyright>
<year>2020</year>
<holder>Arnaud Ferraris</holder>
</copyright>
</bookinfo>
<xi:include href="overview.xml"/>
<part>
<title>API Reference</title>
<chapter id="core-api">
<title>Core API</title>
<xi:include href="xml/libcallaudio.xml"/>
</chapter>
<chapter id="dbus-interface">
<title>DBus Interface</title>
<xi:include href="../data/libcallaudio-org.mobian_project.CallAudio.xml"/>
</chapter>
</part>
<index id="api-index-full">
<title>API Index</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
<index id="annotations-glossary">
<title>Annotations glossary</title>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</index>
</book>
if get_option('gtk_doc')
subdir('xml')
private_headers = [
]
content_files = [
'overview.xml',
]
glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
docpath = join_paths(get_option('datadir'), 'gtk-doc', 'html')
gnome.gtkdoc('libcallaudio',
main_xml: 'libcallaudio-docs.xml',
src_dir: [
join_paths(meson.source_root(), 'libcallaudio'),
join_paths(meson.build_root(), 'libcallaudio'),
join_paths(meson.build_root(), 'data'),
],
dependencies: libcallaudio_dep,
gobject_typesfile: 'libcallaudio.types',
scan_args: [
'--rebuild-types',
'--ignore-headers=' + ' '.join(private_headers),
],
fixxref_args: [
'--html-dir=@0@'.format(docpath),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gi')),
],
install_dir: 'libcallaudio',
content_files: content_files,
install: true)
endif
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
%gtkdocentities;
]>
<part>
<title>Libcallaudio Overview</title>
<chapter>
<title>Introduction</title>
<para>
The purpose of libcallaudio is to make it simple for other applications
to control audio routing and other audio related settings in
mobile phone scenarios.
</para>
<para>
&package; provides synchronous and asynchronous APIs to switch
audio profiles, change between the earpiece and the speakers
and mute the microphone.
</para>
</chapter>
<chapter>
<title>Compiling libcallaudio applications</title>
<simplesect>
<title>Using pkg-config</title>
<para> Like other GNOME libraries,
<application>&package_string;</application> uses
<application>pkg-config</application> to provide compiler options. The
package name is
"<literal>&package_ver_str;</literal>". So in
your <literal>configure.ac</literal> script, you might specify something
like: </para>
<informalexample><programlisting>
PKG_CHECK_MODULES(LIBFEEDBACK, [&package_string;-&package_api_version;])
AC_SUBST(LIBFEEDBACK_CFLAGS)
AC_SUBST(LIBFEEDBACK_LIBS)
</programlisting></informalexample>
</simplesect>
<simplesect>
<title>Using Meson/Ninja</title>
<para>
If using Meson/Ninja use a <literal>dependency('&package_string;-&package_api_version;')
</literal> dependency.
</para>
<para>
The "<literal>&package_api_version;</literal>" in the package name is the "API version"
(indicating "the version of the <application>&package_string;</application> API
that first appeared in version &package_api_version;") and is essentially just part of
the package name.
</para>
</simplesect>
</chapter>
</part>
<!ENTITY package "@PACKAGE@">
<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
<!ENTITY package_name "@PACKAGE_NAME@">
<!ENTITY package_string "@PACKAGE_STRING@">
<!ENTITY package_tarname "@PACKAGE_TARNAME@">
<!ENTITY package_url "@PACKAGE_URL@">
<!ENTITY package_version "@PACKAGE_VERSION@">
<!ENTITY package_api_version "@PACKAGE_API_VERSION@">
<!ENTITY package_ver_str "@PACKAGE_STRING@-@PACKAGE_API_VERSION@">
<!ENTITY callaudio_daemon "<ulink url='https://gitlab.com/mobian1/callaudiod/blob/master/README.md'>Callaudio Daemon</ulink>">
ent_conf = configuration_data()
ent_conf.set('PACKAGE', 'libcallaudio')
ent_conf.set('PACKAGE_BUGREPORT', 'https://gitlab.com/mobian1/callaudiod/issues')
ent_conf.set('PACKAGE_NAME', 'libcallaudio')
ent_conf.set('PACKAGE_STRING', 'libcallaudio')
ent_conf.set('PACKAGE_TARNAME', 'libcallaudio-' + meson.project_version())
ent_conf.set('PACKAGE_URL', 'https://gitlab.com/mobian1/callaudiod')
ent_conf.set('PACKAGE_VERSION', meson.project_version())
ent_conf.set('PACKAGE_API_VERSION', apiversion)
configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
......@@ -38,6 +38,11 @@
static CallAudioDbusCallAudio *_proxy;
static gboolean _initted;
typedef struct _CallAudioAsyncData {
CallAudioCallback cb;
gpointer user_data;
} CallAudioAsyncData;
/**
* call_audio_init:
* @error: Error information
......@@ -91,7 +96,7 @@ void call_audio_deinit(void)
static void select_mode_done(GObject *object, GAsyncResult *result, gpointer data)
{
CallAudioDbusCallAudio *proxy = CALL_AUDIO_DBUS_CALL_AUDIO(object);
CallAudioCallback cb = data;
CallAudioAsyncData *async_data = data;
GError *error = NULL;
gboolean success = FALSE;
gboolean ret;
......@@ -106,24 +111,32 @@ static void select_mode_done(GObject *object, GAsyncResult *result, gpointer dat
g_debug("%s: D-bus call returned %d (success=%d)", __func__, ret, success);
if (cb)
cb(ret && success, error);
if (async_data && async_data->cb)
async_data->cb(ret && success, error, async_data->user_data);
}
/**
* call_audio_select_mode_async:
* @mode: Audio mode to select
* @cb: Function to be called when operation completes
* @data: User data to be passed to the callback function after completion
*
* Select the audio mode to use.
*/
gboolean call_audio_select_mode_async(CallAudioMode mode, CallAudioCallback cb)
gboolean call_audio_select_mode_async(CallAudioMode mode,
CallAudioCallback cb,
gpointer data)
{
if (!_initted)
CallAudioAsyncData *async_data = g_new0(CallAudioAsyncData, 1);
if (!_initted || !async_data)
return FALSE;
async_data->cb = cb;
async_data->user_data = data;
call_audio_dbus_call_audio_call_select_mode(_proxy, mode, NULL,
select_mode_done, cb);
select_mode_done, async_data);
return TRUE;
}
......@@ -131,6 +144,7 @@ gboolean call_audio_select_mode_async(CallAudioMode mode, CallAudioCallback cb)
/**
* call_audio_select_mode:
* @mode: Audio mode to select
* @error: The error that will be set if the audio mode could not be selected.
*
* Select the audio mode to use. This function is synchronous, and will return
* only once the operation has been executed.
......@@ -158,7 +172,7 @@ gboolean call_audio_select_mode(CallAudioMode mode, GError **error)
static void enable_speaker_done(GObject *object, GAsyncResult *result, gpointer data)
{
CallAudioDbusCallAudio *proxy = CALL_AUDIO_DBUS_CALL_AUDIO(object);
CallAudioCallback cb = data;
CallAudioAsyncData *async_data = data;
GError *error = NULL;
gboolean success = FALSE;
gboolean ret;
......@@ -173,24 +187,32 @@ static void enable_speaker_done(GObject *object, GAsyncResult *result, gpointer
g_debug("%s: D-bus call returned %d (success=%d)", __func__, ret, success);
if (cb)
cb(ret && success, error);
if (async_data && async_data->cb)
async_data->cb(ret && success, error, async_data->user_data);
}
/**
* call_audio_enable_speaker_async:
* @enable: Desired speaker state
* @cb: Function to be called when operation completes
* @data: User data to be passed to the callback function after completion
*
* Enable or disable speaker output.
*/
gboolean call_audio_enable_speaker_async(gboolean enable, CallAudioCallback cb)
gboolean call_audio_enable_speaker_async(gboolean enable,
CallAudioCallback cb,
gpointer data)
{
if (!_initted)
CallAudioAsyncData *async_data = g_new0(CallAudioAsyncData, 1);
if (!_initted || !async_data)
return FALSE;
async_data->cb = cb;
async_data->user_data = data;
call_audio_dbus_call_audio_call_enable_speaker(_proxy, enable, NULL,
enable_speaker_done, cb);
enable_speaker_done, async_data);
return TRUE;
}
......@@ -198,6 +220,7 @@ gboolean call_audio_enable_speaker_async(gboolean enable, CallAudioCallback cb)
/**
* call_audio_enable_speaker:
* @enable: Desired speaker state
* @error: The error that will be set if the audio mode could not be selected.
*
* Enable or disable speaker output. This function is synchronous, and will
* return only once the operation has been executed.
......@@ -225,7 +248,7 @@ gboolean call_audio_enable_speaker(gboolean enable, GError **error)
static void mute_mic_done(GObject *object, GAsyncResult *result, gpointer data)
{
CallAudioDbusCallAudio *proxy = CALL_AUDIO_DBUS_CALL_AUDIO(object);
CallAudioCallback cb = data;
CallAudioAsyncData *async_data = data;
GError *error = NULL;
gboolean success = 0;
gboolean ret;
......@@ -239,24 +262,32 @@ static void mute_mic_done(GObject *object, GAsyncResult *result, gpointer data)
g_debug("%s: D-bus call returned %d (success=%d)", __func__, ret, success);
if (cb)
cb(ret && success, error);
if (async_data && async_data->cb)
async_data->cb(ret && success, error, async_data->user_data);
}
/**
* call_audio_mute_mic_async:
* @mute: %TRUE to mute the microphone, or %FALSE to unmute it
* @cb: Function to be called when operation completes
* @data: User data to be passed to the callback function after completion
*
* Mute or unmute microphone.
*/
gboolean call_audio_mute_mic_async(gboolean mute, CallAudioCallback cb)
gboolean call_audio_mute_mic_async(gboolean mute,
CallAudioCallback cb,
gpointer data)
{
if (!_initted)
CallAudioAsyncData *async_data = g_new0(CallAudioAsyncData, 1);
if (!_initted || !async_data)
return FALSE;
async_data->cb = cb;
async_data->user_data = data;
call_audio_dbus_call_audio_call_mute_mic(_proxy, mute, NULL,
mute_mic_done, cb);
mute_mic_done, async_data);
return TRUE;
}
......@@ -264,6 +295,7 @@ gboolean call_audio_mute_mic_async(gboolean mute, CallAudioCallback cb)
/**
* call_audio_mute_mic:
* @mute: %TRUE to mute the microphone, or %FALSE to unmute it
* @error: The error that will be set if the audio mode could not be selected.
*
* Mute or unmute microphone. This function is synchronous, and will return
* only once the operation has been executed.
......
......@@ -24,7 +24,9 @@ typedef enum _CallAudioMode {
CALL_AUDIO_MODE_CALL,
} CallAudioMode;
typedef void (*CallAudioCallback)(gboolean success, GError *error);
typedef void (*CallAudioCallback)(gboolean success,
GError *error,
gpointer data);
gboolean call_audio_init (GError **error);
gboolean call_audio_is_inited(void);
......@@ -32,14 +34,17 @@ void call_audio_deinit (void);
gboolean call_audio_select_mode (CallAudioMode mode, GError **error);
gboolean call_audio_select_mode_async(CallAudioMode mode,
CallAudioCallback cb);
CallAudioCallback cb,
gpointer data);
gboolean call_audio_enable_speaker (gboolean enable, GError **error);
gboolean call_audio_enable_speaker_async(gboolean enable,
CallAudioCallback cb);
CallAudioCallback cb,
gpointer data);
gboolean call_audio_mute_mic (gboolean mute, GError **error);
gboolean call_audio_mute_mic_async(gboolean mute,
CallAudioCallback cb);
CallAudioCallback cb,
gpointer data);
G_END_DECLS
......@@ -28,15 +28,17 @@ libcallaudio_deps = [
libcallaudio_c_args = [
'-DG_LOG_DOMAIN="libcallaudio"',
'-I../src',
]
libcallaudio_inc = include_directories('.', '../src')
libtype = 'shared_library'
libcallaudio = build_target(
'callaudio-' + apiversion,
libcallaudio_sources,
soversion : 0,
c_args : libcallaudio_c_args,
include_directories : libcallaudio_inc,
dependencies : libcallaudio_deps,
link_args : libcallaudio_link_args,
install : true,
......@@ -44,7 +46,6 @@ libcallaudio = build_target(
target_type : libtype,
)
libcallaudio_inc = include_directories('.')
libcallaudio_dep = declare_dependency(
sources : [generated_dbus_sources],
link_with : libcallaudio,
......
......@@ -8,7 +8,7 @@
project (
'callaudiod',
'c',
version : '0.0.4',
version : '0.0.5',
license : 'LGPLv3+',
meson_version : '>= 0.50.0',
default_options :
......@@ -43,7 +43,7 @@ else
full_sysconfdir = join_paths(prefix, sysconfdir)
endif
apiversion = '0'
apiversion = '0.1'
libname = 'libcallaudio-' + apiversion
config_data = configuration_data()
......@@ -60,3 +60,4 @@ subdir('data')
subdir('libcallaudio')
subdir('src')
subdir('tools')
subdir('doc')
option('gtk_doc',
type: 'boolean', value: false,
description: 'Whether to generate the API reference for Callaudio')
......@@ -9,6 +9,14 @@
#include "callaudio-dbus.h"
#include <glib-object.h>
/**
* CadOperationType:
* @CAD_OPERATION_SELECT_MODE: Selecting an audio mode (default mode, voice call mode)
* @CAD_OPERATION_ENABLE_SPEAKER: Enable or disable the loudspeaker
* @CAD_OPERATION_MUTE_MIC: Mute or unmute the microphone
*
* Enum values to indicate the operation to be performed.
*/
typedef enum {
CAD_OPERATION_SELECT_MODE = 0,
CAD_OPERATION_ENABLE_SPEAKER,
......
......@@ -140,11 +140,13 @@ static void init_source_info(pa_context *ctx, const pa_source_info *info, int eo
{
CadPulse *self = data;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no source info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no source info (eol=%d)", eol);
return;
}
process_new_source(self, info);
}
......@@ -153,11 +155,13 @@ static void init_sink_info(pa_context *ctx, const pa_sink_info *info, int eol, v
{
CadPulse *self = data;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no sink info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no sink info (eol=%d)", eol);
return;
}
process_new_sink(self, info);
}
......@@ -168,11 +172,13 @@ static void init_card_info(pa_context *ctx, const pa_card_info *info, int eol, v
const gchar *prop;
guint i;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no card info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no card info (eol=%d)", eol);
return;
}
prop = pa_proplist_gets(info->proplist, PA_PROP_DEVICE_BUS_PATH);
if (prop && strcmp(prop, CARD_BUS_PATH) != 0)
......@@ -207,11 +213,14 @@ static void init_cards_list(CadPulse *self)
self->card_id = self->sink_id = self->source_id = -1;
op = pa_context_get_card_info_list(self->ctx, init_card_info, self);
pa_operation_unref(op);
if (op)
pa_operation_unref(op);
op = pa_context_get_sink_info_list(self->ctx, init_sink_info, self);
pa_operation_unref(op);
if (op)
pa_operation_unref(op);
op = pa_context_get_source_info_list(self->ctx, init_source_info, self);
pa_operation_unref(op);
if (op)
pa_operation_unref(op);
}
static void changed_cb(pa_context *ctx, pa_subscription_event_type_t type, uint32_t idx, void *data)
......@@ -228,7 +237,8 @@ static void changed_cb(pa_context *ctx, pa_subscription_event_type_t type, uint3
} else if (kind == PA_SUBSCRIPTION_EVENT_NEW) {
g_debug("new sink %u", idx);
op = pa_context_get_sink_info_by_index(ctx, idx, init_sink_info, self);
pa_operation_unref(op);
if (op)
pa_operation_unref(op);
}
break;
case PA_SUBSCRIPTION_EVENT_SOURCE:
......@@ -238,7 +248,8 @@ static void changed_cb(pa_context *ctx, pa_subscription_event_type_t type, uint3
} else if (kind == PA_SUBSCRIPTION_EVENT_NEW) {
g_debug("new sink %u", idx);
op = pa_context_get_source_info_by_index(ctx, idx, init_source_info, self);
pa_operation_unref(op);
if (op)
pa_operation_unref(op);
}
break;
default:
......@@ -383,11 +394,13 @@ static void set_card_profile(pa_context *ctx, const pa_card_info *info, int eol,
pa_card_profile_info2 *profile;
pa_operation *op = NULL;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no card info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no card info (eol=%d)", eol);
return;
}
if (info->index != operation->pulse->card_id)
return;
......@@ -420,11 +433,13 @@ static void set_output_port(pa_context *ctx, const pa_sink_info *info, int eol,
pa_operation *op = NULL;
const gchar *target_port;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no sink info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no sink info (eol=%d)", eol);
return;
}
if (info->card != operation->pulse->card_id || info->index != operation->pulse->sink_id)
return;
......@@ -476,11 +491,13 @@ static void set_mic_mute(pa_context *ctx, const pa_source_info *info, int eol, v
CadPulseOperation *operation = data;
pa_operation *op = NULL;
if (eol == 1)
if (eol != 0)
return;
if (!info)
g_error("PA returned no source info (eol=%d)", eol);
if (!info) {
g_critical("PA returned no source info (eol=%d)", eol);
return;
}
if (info->card != operation->pulse->card_id || info->index != operation->pulse->source_id)
return;
......@@ -503,6 +520,12 @@ static void set_mic_mute(pa_context *ctx, const pa_source_info *info, int eol, v
}
}
/**
* cad_pulse_select_mode:
* @mode:
* @cad_op:
*
* */
void cad_pulse_select_mode(guint mode, CadOperation *cad_op)
{
CadPulseOperation *operation = g_new(CadPulseOperation, 1);
......@@ -538,16 +561,25 @@ void cad_pulse_select_mode(guint mode, CadOperation *cad_op)