[alsa-devel] [PATCH] SND_SEQ_BLOCK and SND_SEQ_PORT_CAP_NONE defines

Takashi Iwai tiwai at suse.de
Fri Feb 1 13:38:43 CET 2008


At Thu, 31 Jan 2008 14:42:42 -0300,
Aldrin Martoq wrote:
> 
> Hey hackers,
> 
> While developing pyalsa sequencer API, I found that sometimes 0 is
> used instead of a #defined value or constant.
> 
> In my opinion, given that the alsa API is opaque (hides internal
> structure and provides methods for accessing them), we should define
> those missing "constants" for being consistent. So far I found:
> SND_SEQ_BLOCK 0 (blocking mode)
> SND_SEQ_PORT_CAP_NONE (the port defines no access capabilites)

Well, I myself don't mind to add such defintions, but remember that
these flags are no enum but bits.  When you see BLOCK and NONBLOCK
definitions, you'll likely think these are exclusive.  However,
(BLOCK|NONBLOCK) or (NONE|READ) can be passed without problems.


Takashi

> 
> 
> 
> BTW, Thanks Jaroslav for putting my code; I will send 3rd patch for
> covering the missing items of the python API sequencer when I'll
> finish it.
> 
> Signed-off-by: Aldrin Martoq <amartoq at dcc.uchile.cl>
> ---
> diff --git a/include/seq.h b/include/seq.h
> --- a/include/seq.h
> +++ b/include/seq.h
> @@ -56,7 +56,8 @@ typedef struct _snd_seq snd_seq_t;
>  /**
>   * sequencer opening mode
>   */
> -#define SND_SEQ_NONBLOCK       0x0001  /**< non-blocking mode (flag
> to open mode) */
> +#define SND_SEQ_BLOCK          0x0000  /**< blocking opening mode
> (flag for #snd_seq_open, #snd_seq_nonblock) */
> +#define SND_SEQ_NONBLOCK       0x0001  /**< non-blocking opening mode
> (flag for #snd_seq_open, #snd_seq_nonblock) */
> 
>  /** sequencer handle type */
>  typedef enum _snd_seq_type {
> @@ -204,6 +205,7 @@ typedef struct _snd_seq_port_info snd_se
>  #define SND_SEQ_PORT_SYSTEM_ANNOUNCE   1       /**< system announce port */
> 
>  /** port capabilities (32 bits) */
> +#define SND_SEQ_PORT_CAP_NONE          (0<<0)  /**< port has no
> access capabilities */
>  #define SND_SEQ_PORT_CAP_READ          (1<<0)  /**< readable from this port */
>  #define SND_SEQ_PORT_CAP_WRITE         (1<<1)  /**< writable to this port */
> 
> diff --git a/src/seq/seq.c b/src/seq/seq.c
> --- a/src/seq/seq.c
> +++ b/src/seq/seq.c
> @@ -958,7 +958,7 @@ static int snd_seq_open_noupdate(snd_seq
>   * \note Internally, these are translated to \c O_WRONLY, \c O_RDONLY and
>   * \c O_RDWR respectively and used as the second argument to the C library
>   * open() call.
> - * \param mode Optional modifier.  Can be either 0, or
> + * \param mode Optional modifier.  Can be either #SND_SEQ_BLOCK, or
>   * #SND_SEQ_NONBLOCK, which will make read/write operations
>   * non-blocking.  This can also be set later using #snd_seq_nonblock().
>   * \return 0 on success otherwise a negative error code
> @@ -2161,8 +2161,9 @@ void snd_seq_port_info_set_timestamp_que
>   * Each port has the capability bit-masks to specify the access capability
>   * of the port from other clients.
>   * The capability bit flags are defined as follows:
> + * - #SND_SEQ_PORT_CAP_NONE No access capabilities
>   * - #SND_SEQ_PORT_CAP_READ Readable from this port
> - * - #SND_SEQ_PORT_CAP_WRITE Writable to this port.
> + * - #SND_SEQ_PORT_CAP_WRITE Writable to this port
>   * - #SND_SEQ_PORT_CAP_SYNC_READ For synchronization (not implemented)
>   * - #SND_SEQ_PORT_CAP_SYNC_WRITE For synchronization (not implemented)
>   * - #SND_SEQ_PORT_CAP_DUPLEX Read/write duplex access is supported
> 
> 
> 
> -- 
> Aldrin Martoq
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 


More information about the Alsa-devel mailing list