All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH - alsa-lib 1/1] Change card/pid get functions to return -ENOSYS if the kernel is too old
@ 2016-04-01 17:33 Adam Goode
  2016-04-01 17:45 ` Adam Goode
  2016-04-01 21:15 ` Martin Koegler
  0 siblings, 2 replies; 17+ messages in thread
From: Adam Goode @ 2016-04-01 17:33 UTC (permalink / raw)
  To: patch; +Cc: Adam Goode, alsa-devel, martin.koegler

When trying to get the pid or card of a client, the get functions will
return -1 if there is no pid or card for a client. Clients have zero or
one of these, so -1 is correct for these cases. But we also need to detect
the case where the kernel cannot tell us if there is a card or pid, so
that userspace can fallback to probing this information in the old way.

Signed-off-by: Adam Goode <agoode@google.com>

diff --git a/src/seq/seq.c b/src/seq/seq.c
index 4405e68..7de1e81 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -1522,9 +1522,10 @@ int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info)
 }
 
 /**
- * \brief Get the sound card number.
+ * \brief Get the sound card number if the kernel supports this.
  * \param info client_info container
- * \return card number or -1 if value is not available.
+ * \return card number, -1 if there is no card for this client,
+ *  or \c -ENOSYS if the kernel does not have support for this operation
  *
  * Only available for SND_SEQ_KERNEL_CLIENT clients.
  */
@@ -1535,9 +1536,10 @@ int snd_seq_client_info_get_card(const snd_seq_client_info_t *info)
 }
 
 /**
- * \brief Get the owning PID.
+ * \brief Get the owning PID if the kernel supports this.
  * \param info client_info container
- * \return pid or -1 if value is not available.
+ * \return pid, -1 if there is no PID for this client,
+ *  or \c -ENOSYS if the kernel does not have support for this operation
  *
  * Only available for SND_SEQ_USER_CLIENT clients.
  */
diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c
index 578ef12..a1d1e4a 100644
--- a/src/seq/seq_hw.c
+++ b/src/seq/seq_hw.c
@@ -102,8 +102,8 @@ static int snd_seq_hw_get_client_info(snd_seq_t *seq, snd_seq_client_info_t * in
 		return -errno;
 	}
 	if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) {
-		info->card = -1;
-		info->pid = -1;
+		info->card = -ENOSYS;
+		info->pid = -ENOSYS;
 	}
 	return 0;
 }
@@ -374,8 +374,8 @@ static int snd_seq_hw_query_next_client(snd_seq_t *seq, snd_seq_client_info_t *i
 		return -errno;
 	}
 	if (hw->version < SNDRV_PROTOCOL_VERSION(1, 0, 2)) {
-		info->card = -1;
-		info->pid = -1;
+		info->card = -ENOSYS;
+		info->pid = -ENOSYS;
 	}
 	return 0;
 }
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-01-03 13:35 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 17:33 [PATCH - alsa-lib 1/1] Change card/pid get functions to return -ENOSYS if the kernel is too old Adam Goode
2016-04-01 17:45 ` Adam Goode
2016-04-01 21:15 ` Martin Koegler
2016-04-04 14:54   ` Takashi Iwai
2016-04-05 15:21     ` Adam Goode
2016-04-07 19:23     ` Adam Goode
2016-04-07 20:10       ` Martin Koegler
2016-04-07 23:00         ` Takashi Sakamoto
2016-04-08 10:24         ` Takashi Iwai
2016-04-08 12:56           ` Jaroslav Kysela
2016-04-08 13:10             ` Takashi Iwai
2016-04-08 15:21               ` Adam Goode
2016-04-08 17:56                 ` Martin Koegler
2016-04-08 19:53                   ` Adam Goode
2016-06-06 13:57                     ` Adam Goode
2016-06-06 14:01                       ` Takashi Iwai
2017-01-03 13:34                         ` Adam Goode

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.