From: Jaroslav Kysela Date: Sat, 8 Mar 2003 16:35:18 +0000 (+0000) Subject: Added snd_pcm_type_name() X-Git-Tag: v1.0.3~209 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=157107491cb6b18122d84c80fa58f3df1962eb1a;p=alsa-lib.git Added snd_pcm_type_name() Fixed rate conversion plugin (SIGSEGV) - rounding problem --- diff --git a/include/pcm.h b/include/pcm.h index 9630c3b1..cc71d00f 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -348,6 +348,7 @@ enum _snd_pcm_type { SND_PCM_TYPE_DMIX, /** Jack Audio Connection Kit plugin */ SND_PCM_TYPE_JACK, + SND_PCM_TYPE_LAST = SND_PCM_TYPE_JACK }; /** PCM type */ @@ -947,6 +948,7 @@ snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj); * \{ */ +const char *snd_pcm_type_name(snd_pcm_state_t state); const char *snd_pcm_stream_name(const snd_pcm_stream_t stream); const char *snd_pcm_access_name(const snd_pcm_access_t _access); const char *snd_pcm_format_name(const snd_pcm_format_t format); diff --git a/src/Versions b/src/Versions index dab89280..fbcacbc5 100644 --- a/src/Versions +++ b/src/Versions @@ -92,6 +92,7 @@ ALSA_0.9.0rc8 { ALSA_0.9.0 { global: + snd_pcm_type_name; snd_timer_query_info; snd_timer_query_params; snd_timer_query_status; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 1375ab81..c510ceec 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1217,6 +1217,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign } #ifndef DOC_HIDDEN +#define PCMTYPE(v) [SND_PCM_TYPE_##v] = #v #define STATE(v) [SND_PCM_STATE_##v] = #v #define STREAM(v) [SND_PCM_STREAM_##v] = #v #define READY(v) [SND_PCM_READY_##v] = #v @@ -1233,6 +1234,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign #define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d #define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d + static const char *snd_pcm_stream_names[] = { STREAM(PLAYBACK), STREAM(CAPTURE), @@ -1339,6 +1341,33 @@ static const char *snd_pcm_format_descriptions[] = { FORMATD(U18_3BE, "Unsigned 18 bit Big Endian in 3bytes"), }; +static const char *snd_pcm_type_names[] = { + PCMTYPE(HW), + PCMTYPE(HOOKS), + PCMTYPE(MULTI), + PCMTYPE(FILE), + PCMTYPE(NULL), + PCMTYPE(SHM), + PCMTYPE(INET), + PCMTYPE(COPY), + PCMTYPE(LINEAR), + PCMTYPE(ALAW), + PCMTYPE(MULAW), + PCMTYPE(ADPCM), + PCMTYPE(RATE), + PCMTYPE(ROUTE), + PCMTYPE(PLUG), + PCMTYPE(SHARE), + PCMTYPE(METER), + PCMTYPE(MIX), + PCMTYPE(DROUTE), + PCMTYPE(LBSERVER), + PCMTYPE(LINEAR_FLOAT), + PCMTYPE(LADSPA), + PCMTYPE(DMIX), + PCMTYPE(JACK), +}; + static const char *snd_pcm_subformat_names[] = { SUBFORMAT(STD), }; @@ -1511,6 +1540,23 @@ const char *snd_pcm_state_name(snd_pcm_state_t state) return snd_pcm_state_names[state]; } +/** + * \brief get name of PCM type + * \param type PCM type + * \return ascii name of PCM type + */ +#ifndef DOXYGEN +const char *INTERNAL(snd_pcm_type_name)(snd_pcm_type_t type) +#else +const char *snd_pcm_type_name(snd_pcm_type_t type) +#endif +{ + if (type > SND_PCM_TYPE_LAST) + return NULL; + return snd_pcm_type_names[type]; +} +default_symbol_version(__snd_pcm_type_name, snd_pcm_type_name, ALSA_0.9.0); + /** * \brief Dump current hardware setup for PCM * \param pcm PCM handle diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 37c1fea6..7e1d07c3 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -351,6 +351,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm, snd_pcm_t *slave = plugin->slave; snd_pcm_uframes_t xfer = 0; snd_pcm_sframes_t result; + int err; while (size > 0) { snd_pcm_uframes_t frames = size; @@ -358,8 +359,8 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm, snd_pcm_uframes_t slave_offset; snd_pcm_uframes_t slave_frames = ULONG_MAX; - snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); - if (slave_frames == 0) + err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + if (err < 0 || slave_frames == 0) break; frames = plugin->write(pcm, areas, offset, frames, slave_areas, slave_offset, &slave_frames); diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 395f5b67..d5d0c10a 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -458,11 +458,13 @@ static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) } params->boundary = boundary1; sparams.boundary = boundary2; +#if 0 if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { rate->pitch = (((u_int64_t)boundary2 * DIV) + boundary1 / 2) / boundary1; } else { rate->pitch = (((u_int64_t)boundary1 * DIV) + boundary2 / 2) / boundary2; } +#endif recalc(pcm, &sparams.avail_min); recalc(pcm, &sparams.xfer_align); recalc(pcm, &sparams.start_threshold);