Takashi Sakamoto [Wed, 16 Mar 2022 00:03:48 +0000 (09:03 +0900)]
meson: code refactoring to remove useless assignments for include headers
In meson build, gnome.mkenums_simple() and gnome.genmarshal()
voluntarily install headers, therefore it's useless to install
them explicitly by install_headers().
This commit removes useless assignments for include headers. I note that
gnome.generate_gir() fails to parse codes when enums are prior to
headers and sources. This commit also reorder entries for safe.
Takashi Sakamoto [Tue, 15 Mar 2022 23:30:07 +0000 (08:30 +0900)]
ctl: fix misfunction of alsactl_get_card_id_list()
Even if instantiation of libudev enumerator is successful,
alsactl_get_card_id_list() handles the success as failure. As a result,
the function does not work at all.
Takashi Sakamoto [Sat, 28 Aug 2021 02:51:36 +0000 (11:51 +0900)]
seq: use safer way to copy strings
The call of strncpy can results in destination buffer without null as
terminator in the case of truncation. Compiler reports the risk as
warnings, like:
In function ‘strncpy’,
inlined from ‘alsaseq_get_queue_info_by_name’ at ../src/seq/query.c:670:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation]
95 | return __builtin___strncpy_chk (__dest, __src, __len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 | __glibc_objsize (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~
This commit uses safer way to copy strings, g_strlcpy(), to fix the bug.
Fixes: 4e8675f631ce ("seq: client_info: add properties and accessor methods") Fixes: f3457eaf706b ("seq: port_info: add properties") Fixes: 1eabdf6bc647 ("seq: add global method to get the information of queue") Fixes: f26342b3ab3d ("seq: queue_info: add properties and constructors") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Sakamoto [Sat, 28 Aug 2021 02:51:36 +0000 (11:51 +0900)]
ctl/rawmidi/hwdep: fix compiler warning due to uninitialized variables
In some libraries, the local variable of udev enumerate is carelessly
uninitialized. As a result, compiler generates warnings, like:
../src/ctl/query.c: In function ‘alsactl_get_card_id_list’:
../src/ctl/query.c:131:8: warning: ‘enumerator’ may be used uninitialized in this function [-Wmaybe-uninitialized]
131 | if (enumerator == NULL)
| ^
This commit fixes the bug.
Fixes: d1936fbbe7e2 ("ctl: add global method to get list of available sound cards") Fixes: cb128c5b59e0 ("rawmidi; add global method to get list of rawmidi device for sound card") Fixes: d4a9f6735d05 ("hwdep: add global method to get list of hwdep devices in sound card") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Sakamoto [Fri, 20 Nov 2020 07:41:36 +0000 (16:41 +0900)]
hwdep: fix metadata and documentation for the type of interface
The scanner of g-i and gtk-doc can't handle macro lines in enumeration
lines expectedly.
This commit fixes to generate valid metadata and documentation.
Fixes: 843c9fe68228 ("hwdep: conditional build for Linux kernel 4.12 or later") Fixes: 45f650bf29e8 ("hwdep: conditional build for Linux kernel v4.9 or later") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
rawmidi: query: fix usage of uninitialized value
Fixes: cb128c5b59e0 ("rawmidi; add global method to get list of rawmidi device for sound card") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Sakamoto [Mon, 16 Nov 2020 23:52:54 +0000 (08:52 +0900)]
ctl: card: change prototype of function relevant to TLV
In ALSA control interface, the data of TLV (Type-Length-Value) style is
defined as array with unsigned int type of element. However, current
implementation of ALSACtl.Card handles them as signed int type.
This commit fixes the bug. The commit loses backward compatibility to
v0.1.0 release in a point of type of function argument. The exported
symbols relevant to TLV are updated with new version.
Takashi Sakamoto [Mon, 16 Nov 2020 13:27:54 +0000 (22:27 +0900)]
rawmidi: stream_pair: fix to select substream
ALSARawmidi.StreamPair.open() has subdevice_id to select one of
substreams supported by the Rawmidi device. However, this parameter is
ignored and the first substream is always selected.
In ALSA rawmidi core, private structure associated to file descriptor
to control character device assists selection of rawmidi substream.
It requires to keep the file descriptor until the selected substream
is actually attached by open rawmidi character device.
Current implementation of libalsarawmidi is to close the file descriptor
before opening rawmidi character device. This is the cause of the issue.
This commit fixes the bug by keeping the file descriptor till opening
rawmidi character device.
Takashi Sakamoto [Mon, 16 Nov 2020 13:27:54 +0000 (22:27 +0900)]
rawmidi: query: allow caller to take ownership of file descriptor for control character device
In design of ALSA rawmidi interface, ALSA control interface has important
function to some operations. The alsarawmidi library has an internal
helper function to operate control character device. The helper function
closes file descriptor to the control character device before returning
to caller, however it's inconvenient to some operations.
This commit allows the caller to take ownership for opened file descriptor
of control character device.
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: query: use GFileError to report error
This commit uses GFileError to report errors in library global functions.
It's better to add new GLib enumerations and GQuark for the reporting,
however it's cumbersome to add them just for the global functions.
Thus this commit just uses the existent error in GLib.
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: stream_pair: report error about write-only file descriptor
In design of ALSA rawmidi interface, one character device can handle
operations for both capture and playback. Applications can indicate
usage of both or either by flags of open system call.
The libalsarawmidi library checks the flag by fcntl(2) system call to
create GSource for capture. When the file descriptor is not configured
for read, the call returns error.
This commit handles the error for local error reporting.
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: query: simplify count check
Usually, when creating list of something, count decision at first, then
generate items of the list. At last, the number of items is checked as
the same as the count. However, it's unlikely to have different number
of items.
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: add checks for method arguments
In Rules for use of GError, it's just used for recoverable runtime
error, not for programming error. The invalid arguments are a kind of
programming error.
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: skip check of return value from g_malloc()
In GLib implementation, the call of g_malloc() can bring program abort
due to memory starvation. This is necessarily preferable because applications
cannot handle the case and GLib has alternative APIs named 'try' to
allow applications to handle the case.
On the other hand, the memory starvation is system wide issue and it's
hard for applications to solve the issue. It's reasonable for the
implementation to have program abort somehow.
Furthermore, the call of g_object_new() can bring program abort due
to memory starvation. It's impossible for applications to handle the
case.
This commit skips check of return value from g_malloc().
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep: query: use GFileError to report error
This commit uses GFileError to report errors in library global functions.
It's better to add new GLib enumerations and GQuark for the reporting,
however it's cumbersome to add them just for the global functions.
Thus this commit just uses the existent error in GLib.
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep: query: simplify count check
Usually, when creating list of something, count decision at first, then
generate items of the list. At last, the number of items is checked as
the same as the count. However, it's unlikely to have different number
of items.
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep: add checks for method arguments
In Rules for use of GError, it's just used for recoverable runtime
error, not for programming error. The invalid arguments are a kind of
programming error.
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep: skip check of return value from g_malloc()
In GLib implementation, the call of g_malloc() can bring program abort
due to memory starvation. This is necessarily preferable because applications
cannot handle the case and GLib has alternative APIs named 'try' to
allow applications to handle the case.
On the other hand, the memory starvation is system wide issue and it's
hard for applications to solve the issue. It's reasonable for the
implementation to have program abort somehow.
Furthermore, the call of g_object_new() can bring program abort due
to memory starvation. It's impossible for applications to handle the
case.
This commit skips check of return value from g_malloc().
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
timer: instance_param: simplify count check
Usually, when creating list of something, count decision at first, then
generate items of the list. At last, the number of items is checked as
the same as the count. However, it's unlikely to have different number
of items.
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
ctl: query: simplify count check
Usually, when creating list of something, count decision at first, then
generate items of the list. At last, the number of items is checked as
the same as the count. However, it's unlikely to have different number
of items.
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: query: use GFileError to report error
In design of ALSA sequencer, sequencer character device is not
corresponding to each substance in ALSA Sequencer. It's a kind of
interface to query and operate. Applications adds user client
and operates it to use its services. Nevertheless, the interface
has some functionality without adding the user instances.
For the functionality, this library has global functions. The functions
are not relevant to the user instance, therefore it's not reasonable to
use error domain specific to the user instance.
This commit uses GFileError to report errors in the global functions.
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: report error for queue access permission
Queue in ALSA sequencer has locking mechanism and client has access
permission to operate the queue. When unpermitted, the operation fails
and return EPERM error code.
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: report error for port access permission
Port in ALSA sequencer has capability and client has access permission
to operate the port. When unpermitted, the operation fails and return
EPERM error code.
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: add checks for method arguments
In Rules for use of GError, it's just used for recoverable runtime
error, not for programming error. The invalid arguments are a kind of
programming error.
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: skip check of return value from g_malloc()
In GLib implementation, the call of g_malloc() can bring program abort
due to memory starvation. This is necessarily preferable because applications
cannot handle the case and GLib has alternative APIs named 'try' to
allow applications to handle the case.
On the other hand, the memory starvation is system wide issue and it's
hard for applications to solve the issue. It's reasonable for the
implementation to have program abort somehow.
Furthermore, the call of g_object_new() can bring program abort due
to memory starvation. It's impossible for applications to handle the
case.
This commit skips check of return value from g_malloc().
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: query: use GFileError to report error
In design of ALSA timer, timer character device is not corresponding to
each substance of timer device. It's a kind of interface to query and
operate. Applications adds user instance and operates it to use its
services. Nevertheless, the interface has some functionality without
adding the user instances.
For the functionality, this library has global functions. The functions
are not relevant to the user instance, therefore it's not reasonable to
use error domain specific to the user instance.
This commit uses GFileError to report errors in the global functions.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: report error for timer already attached
After opening character device, applications can select event type. The
operation should be done before attaching to any timer device or the other
instances, Else it fails and returns EBUSY error to the applications.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: report error for unattached timer instance
When querying or starting the user instance, the instance should be
attached to any timer device or the other instances. Else, applications
receives EBADFD error.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: report error for timer instance not found
After instantiation and opening character device, application can attach
any timer device to the instance according to the identifier information.
If ALSA timer system has no substance identified by the information,
application receives ENODEV error.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: instance-params: add checks for method arguments
In Rules for use of GError, it's just used for recoverable runtime
error, not for programming error. The invalid arguments are a kind of
programming error.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: add checks for method arguments
In Rules for use of GError, it's just used for recoverable runtime
error, not for programming error. The invalid arguments are a kind of
programming error.
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: skip check of return value from g_malloc()
In GLib implementation, the call of g_malloc() can bring program abort
due to memory starvation. This is necessarily preferable because applications
cannot handle the case and GLib has alternative APIs named 'try' to
allow applications to handle the case.
On the other hand, the memory starvation is system wide issue and it's
hard for applications to solve the issue. It's reasonable for the
implementation to have program abort somehow.
Furthermore, the call of g_object_new() can bring program abort due
to memory starvation. It's impossible for applications to handle the
case.
This commit skips check of return value from g_malloc().
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: fix function comment
The function comment for documentation includes wrong descriptions.
This commit corrects it.
Fixes: 3a6d788bf47d ("timer: user_instance: add an API to attach user instance to another instance as slave") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: query: use GFileError to report error
This commit uses GFileError to report errors in library global functions.
It's better to add new GLib enumerations and GQuark for the reporting,
however it's cumbersome to add them just for the global functions.
Thus this commit just uses the existent error in GLib.