]> git.alsa-project.org Git - alsa-gobject.git/log
alsa-gobject.git
3 years agoctl/hwdep/rawmidi: fix uninitialized warning
Takashi Sakamoto [Mon, 29 Nov 2021 04:44:21 +0000 (13:44 +0900)]
ctl/hwdep/rawmidi: fix uninitialized warning

This commit fixes uninitialized warnings.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agobump version up to 0.2.1 for maintenance release v0.2.1
Takashi Sakamoto [Sun, 29 Aug 2021 10:07:42 +0000 (19:07 +0900)]
bump version up to 0.2.1 for maintenance release

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: use safer way to copy strings
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>
4 years agoctl/rawmidi/hwdep: fix compiler warning due to uninitialized variables
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>
4 years agoseq: event_data_ctl: fix getter API for value parameter
Takashi Sakamoto [Fri, 27 Aug 2021 08:37:03 +0000 (17:37 +0900)]
seq: event_data_ctl: fix getter API for value parameter

ALSASeq.EventDataCtl.get_value() is programmed carelessly to return
the value in parameter field instead of value field.

This commit fixes the bug.

Fixes: a8f603eff4f5 ("seq: event_data_ctl: add accessor methods")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoupdate Fedora release for CI environment
Takashi Sakamoto [Fri, 28 May 2021 11:31:19 +0000 (20:31 +0900)]
update Fedora release for CI environment

This commit update Fedora release up to 34.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agofix workflow according to EOF of i386 ubuntu distribution
Takashi Sakamoto [Fri, 28 May 2021 11:14:12 +0000 (20:14 +0900)]
fix workflow according to EOF of i386 ubuntu distribution

Ubuntu 19.10/i386 is EOL and no release is available for i386 architecture
in Ubuntu project.

This commit removes job for i386 architecture from workflow of Github
Actions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agocorrect install section in README
Takashi Sakamoto [Fri, 28 May 2021 11:13:24 +0000 (20:13 +0900)]
correct install section in README

The command `meson build` is not correct.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agobump version up to 0.2.0 to release v0.2.0
Takashi Sakamoto [Fri, 20 Nov 2020 07:41:36 +0000 (16:41 +0900)]
bump version up to 0.2.0 to release

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoupgrade CI operationg system to Fedora 33
Takashi Sakamoto [Fri, 20 Nov 2020 07:41:36 +0000 (16:41 +0900)]
upgrade CI operationg system to Fedora 33

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoupgrade CI operationg system to Ubuntu 20.04 LTS amd64
Takashi Sakamoto [Fri, 20 Nov 2020 07:41:36 +0000 (16:41 +0900)]
upgrade CI operationg system to Ubuntu 20.04 LTS amd64

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: fix metadata and documentation for the type of interface
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>
4 years agohwdep: conditional build for Linux kernel 4.12 or later
Takashi Sakamoto [Fri, 20 Nov 2020 05:19:44 +0000 (14:19 +0900)]
hwdep: conditional build for Linux kernel 4.12 or later

The type of interface in ALSA HwDep interface got a new entries in Linux
kernel v4.12.

This commit adds conditional macro to build for Linux kernel v4.12 or later.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: conditional build for Linux kernel v4.9 or later
Takashi Sakamoto [Fri, 20 Nov 2020 05:19:44 +0000 (14:19 +0900)]
hwdep: conditional build for Linux kernel v4.9 or later

The type of interface in ALSA HwDep interface got a new entry in Linux
kernel v4.9.

This commit adds conditional macro to build for Linux kernel v4.9 or later.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: client_info: conditional build for Linux kernel v4.6 or later
Takashi Sakamoto [Fri, 20 Nov 2020 05:19:44 +0000 (14:19 +0900)]
seq: client_info: conditional build for Linux kernel v4.6 or later

Some members were added to snd_seq_client_info strucutre in Linux kernel
v4.6.

This commit adds conditional macro to build for Linux kernel v4.6 or later.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: query: fulfil comment about GError v0.1.99
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
rawmidi: query: fulfil comment about GError

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: query: fulfil comment about GError
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
hwdep: query: fulfil comment about GError

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: query: fulfil comment about GError
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
seq: query: fulfil comment about GError

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: query: fulfil comment about GError
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
timer: query: fulfil comment about GError

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: query: fulfil comment about GError
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
ctl: query: fulfil comment about GError

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: query: fix usage of uninitialized value
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>
4 years agohwdep: query: fix usage of uninitialized value
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
hwdep: query: fix usage of uninitialized value

Fixes: d4a9f6735d05 ("hwdep: add global method to get list of hwdep devices in sound card")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: stream_pair: update function comment for error reporting
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
rawmidi: stream_pair: update function comment for error reporting

This commit updates function comment for error reporting with
alsarawmidi_stream_pair_error_quark() or g_file_error_quark() domains.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: fix function comment
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
timer: user_instance: fix function comment

Fixes: 880be3869d91 ("timer: user_instance: update function comment for error reporting")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: device_id: fix function comment
Takashi Sakamoto [Tue, 17 Nov 2020 06:44:48 +0000 (15:44 +0900)]
timer: device_id: fix function comment

Fixes: dcd983281ef8 ("timer: device_id: add accessor methods and constructors")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: change prototype of function relevant to TLV
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: stream_pair: fix to select substream
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: query: allow caller to take ownership of file descriptor for control charact...
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: obsolete library-wide GQuark for error reporting
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: obsolete library-wide GQuark for error reporting

This commit obsoletes library-wide GQuark. This is not exported, thus
it doesn't lose backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: query: use GFileError to report error
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: stream_pair: report error about write-only file descriptor
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: report error for card disconnection state
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: report error for card disconnection state

When sound card is under disconnection state, operations fail and return
ENODEV error.

This commit handles the situation in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: report open/read/write/fcntl error
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: report open/read/write/fcntl error

The call of open/read/write system call can return several types of error
from VFS. It's hard to dispatch all of the error in local error domain.

This commit uses GFileError to dispatch the most of the error. At
failure of conversion to GFileError, local error domain is used.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: report error for ioctl
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: report error for ioctl

This commit uses class-local error domain to report ioctl failure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: stream-pair: add GQuark to report error for ALSARawmidi.StreamPair
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: stream-pair: add GQuark to report error for ALSARawmidi.StreamPair

This commit adds new GLib GQuark as a domain of error in instance of
ALSARawmidiStreamPair class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: add GLib enumerations for error reporting
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: add GLib enumerations for error reporting

This commit adds new GLib enumeration for error reporting in
instance of ALSARawmidiStreamPair class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: query: simplify count check
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.

This commit simplifies the count check.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: stream_pair: just return when character device is not opened
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: stream_pair: just return when character device is not opened

It's programming mistake when operating without opening character device.

This commit uses GLib macro just return in the case with warnings.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: add checks for method arguments
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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: check whether method argument for GError is available
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
rawmidi: check whether method argument for GError is available

In Rules for use of GError, the check of arguments for GError may be
preferable to avoid to unexpected function call.

This commit adds the check.

Reference: https://developer.gnome.org/glib/stable/glib-Error-Reporting.html
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agorawmidi: skip check of return value from g_malloc()
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().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: fix code for GFileError
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
seq: user_client: fix code for GFileError

Fixes: d662f5702de4 ("seq: user_client: report open/write error")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: fix code for GFileError
Takashi Sakamoto [Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)]
timer: user_instance: fix code for GFileError

Fixes: a400f241e9ef ("timer: user_instance: report error due to open system call")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep; obsolete library-wide GQuark for error reporting
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep; obsolete library-wide GQuark for error reporting

This commit obsoletes library-wide GQuark. This is not exported, thus
it doesn't lose backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: query: use GFileError to report error
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: query: simplify count check
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.

This commit simplifies the count check.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: add checks for method arguments
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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: check whether method argument for GError is available
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
hwdep: check whether method argument for GError is available

In Rules for use of GError, the check of arguments for GError may be
preferable to avoid to unexpected function call.

This commit adds the check.

Reference: https://developer.gnome.org/glib/stable/glib-Error-Reporting.html
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agohwdep: skip check of return value from g_malloc()
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().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: instance_param: simplify count check
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.

This commit simplifies the count check.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: query: simplify count check
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.

This commit simplifies the count check.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: query: remove duplicated semicolon
Takashi Sakamoto [Sun, 15 Nov 2020 14:04:32 +0000 (23:04 +0900)]
seq: query: remove duplicated semicolon

Fixes: c5b7c598fde4 ("seq: add global method to get list of client ID in ALSA Sequencer")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: obsolete library-wide error quark
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: obsolete library-wide error quark

This commit obsoletes library-wide GQuark. This is not exported, thus
it doesn't lose backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: query: code refactoring for error path
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: query: code refactoring for error path

This commit uses label to ensure closing file descriptor.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: query: code refactoring to unify code to open file descriptor
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: query: code refactoring to unify code to open file descriptor

Some global functions execute the same sequence of operation to open
sequencer character device.

This commit unifies the sequence into a helper function as code
refactoring.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: query: use GFileError to report error
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: update function comment for error reporting
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: update function comment for error reporting

This commit updates function comment for error reporting with
alsaseq_user_instance_error_quark() or g_file_error_quark() domains.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: report error for queue access permission
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.

This commit handles the code for local error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: report error for port access permission
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.

This commit handles the code for local error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: report open/write error
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: report open/write error

The call of open system call can return several types of error from VFS.
It's hard to dispatch all of the error in local error domain.

This commit uses GFileError to dispatch the most of the error. At
failure of conversion to GFileError, local error domain is used.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: report error for ioctl
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: report error for ioctl

This commit uses class-local error domain to report ioctl failure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: add GQuark to report error for ALSASeq.UserClient
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: add GQuark to report error for ALSASeq.UserClient

This commit adds new GLib GQuark as a domain of error in instance of
ALSASeqUserInstance class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: add GLib enumeration to report type of error for ALSASeq.UserClient
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: add GLib enumeration to report type of error for ALSASeq.UserClient

This commit adds new GLib enumeration for error reporting in
instance of ALSASeqUserClient class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: user_client: just return when character device is not opened
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: user_client: just return when character device is not opened

It's programming mistake when operating without opening character device.

This commit uses GLib macro just return in the case with warnings.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: add checks for method arguments
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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: check whether method argument for GError is available
Takashi Sakamoto [Sun, 15 Nov 2020 02:54:07 +0000 (11:54 +0900)]
seq: check whether method argument for GError is available

In Rules for use of GError, the check of arguments for GError may be
preferable to avoid to unexpected function call.

This commit adds the check.

Reference: https://developer.gnome.org/glib/stable/glib-Error-Reporting.html
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoseq: skip check of return value from g_malloc()
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().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: obsolete library-wide GQuark for error reporting
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: obsolete library-wide GQuark for error reporting

This commit obsoletes library-wide GQuark. This is not exported, thus
it doesn't lose backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: query: code refactoring to unify open function
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: query: code refactoring to unify open function

Some global functions execute the same sequence of operation to open
timer character device.

This commit unifies the sequence into a helper function as code
refactoring.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: query: use GFileError to report error
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: update function comment for error reporting
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: update function comment for error reporting

This commit updates function comment for error reporting with
alsactl_card_error_quark() or g_file_error_quark() domains.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: report error for timer already attached
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.

This commit handles it and report local error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: report error for unattached timer instance
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.

This commit handles it and report local error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: report error for timer instance not found
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.

This commit handles it and report local error.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: report error due to open system call
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: report error due to open system call

The call of open system call can return several types of error from VFS.
It's hard to dispatch all of the error in local error domain.

This commit uses GFileError to dispatch the most of the error. At
failure of conversion to GFileError, local error domain is used.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: report error due to ioctl failure
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: report error due to ioctl failure

This commit uses class-local error domain to report ioctl failure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: add GQuark to report error for ALSATimer.UserInstance
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: add GQuark to report error for ALSATimer.UserInstance

This commit adds new GLib GQuark as a domain of error in instance of
ALSATimerUserInstance class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: add GLib enumeration to report type of error for ALSATimer.UserInstance
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: add GLib enumeration to report type of error for ALSATimer.UserInstance

This commit adds new GLib enumeration for error reporting in
instance of ALSATimerUserInstance class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: just return when character device is not opened
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: user_instance: just return when character device is not opened

It's programming mistake when operating without opening character device.

This commit uses GLib macro just return in the case with warnings.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: instance-params: add checks for method arguments
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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: add checks for method arguments
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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: check whether method argument for GError is available
Takashi Sakamoto [Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)]
timer: check whether method argument for GError is available

In Rules for use of GError, the check of arguments for GError may be
preferable to avoid to unexpected function call.

This commit adds the check.

Reference: https://developer.gnome.org/glib/stable/glib-Error-Reporting.html
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: skip check of return value from g_malloc()
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().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agotimer: user_instance: fix function comment
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>
4 years agoctl: obsolete library-wide GQuark for error reporting
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: obsolete library-wide GQuark for error reporting

This commit obsoletes library-wide GQuark. This is not exported, thus
it doesn't lose backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: query: use GFileError to report error
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.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: update function comment for error reporting
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: update function comment for error reporting

This commit updates function comment for error reporting with
alsactl_card_error_quark() or g_file_error_quark() domains.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report error due to existent control element
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report error due to existent control element

The operation to add user-defined control elements returns EBUSY when
sound card has any control element which has the same identifier.

This commit handles the error in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report error due to operations against element owned by the other processes
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report error due to operations against element owned by the other processes

Some operations to control element returns EBUSY or EPERM when the
element is locked for write by the other processes.

This commit handles the error in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report error about unsupported element operation
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report error about unsupported element operation

ANy operation to control element returns EPERM when the operation is not
supported by the element.

This commit handles the error in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report error about element not found
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report error about element not found

Any operation to control element returns ENOENT when sound card doesn't
have the element.

This commit handles the error in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report error about disconnection
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report error about disconnection

When sound card is under disconnection state, operations fail and return
ENODEV error.

This commit handles the situation in local error domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report open error
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report open error

The call of open system call can return several types of error from VFS.
It's hard to dispatch all of the error in local error domain.

This commit uses GFileError to dispatch the most of the error. At
failure of conversion to GFileError, local error domain is used.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: report system call error with own error domain
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: report system call error with own error domain

This commit uses class-local error domain to report ioctl failure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: add GQuark to report error specific for the class
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: add GQuark to report error specific for the class

This commit adds new GLib GQuark as a domain of error in instance of
ALSACtlCard class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: add GLib enumerations for error reporting
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: add GLib enumerations for error reporting

This commit adds new GLib enumeration for error reporting in
instance of ALSACtlCard class.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: card: just return when character device is not opened
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: card: just return when character device is not opened

It's programming error when operating without opening character device.

This commit uses GLib macro just return in the case with warnings.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: add checks for method arguments
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: 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.

This commit adds the check for method arguments.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: check whether method argument for GError is available
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: check whether method argument for GError is available

In Rules for use of GError, the check of arguments for GError may be
preferable to avoid to unexpected function call.

This commit adds the check.

Reference: https://developer.gnome.org/glib/stable/glib-Error-Reporting.html
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
4 years agoctl: skip check of return value from g_malloc()
Takashi Sakamoto [Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)]
ctl: 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().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>