Commit 51c816fd authored by Takashi Iwai's avatar Takashi Iwai

ALSA: oss: Fix assignment in if condition

There are a few places doing assignments in if condition in ALSA PCM
and OSS emulation layers, which is a bad coding style that may confuse
readers and occasionally lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-56-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 137c171c
...@@ -185,7 +185,8 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer) ...@@ -185,7 +185,8 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */ if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
int err; int err;
unsigned int index; unsigned int index;
if ((err = mixer->get_recsrc(fmixer, &index)) < 0) err = mixer->get_recsrc(fmixer, &index);
if (err < 0)
return err; return err;
result = 1 << index; result = 1 << index;
} else { } else {
...@@ -517,7 +518,8 @@ static void snd_mixer_oss_get_volume1_vol(struct snd_mixer_oss_file *fmixer, ...@@ -517,7 +518,8 @@ static void snd_mixer_oss_get_volume1_vol(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN) if (numid == ID_UNKNOWN)
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { kctl = snd_ctl_find_numid(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return; return;
} }
...@@ -555,7 +557,8 @@ static void snd_mixer_oss_get_volume1_sw(struct snd_mixer_oss_file *fmixer, ...@@ -555,7 +557,8 @@ static void snd_mixer_oss_get_volume1_sw(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN) if (numid == ID_UNKNOWN)
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { kctl = snd_ctl_find_numid(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return; return;
} }
...@@ -620,7 +623,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer, ...@@ -620,7 +623,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN) if (numid == ID_UNKNOWN)
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { kctl = snd_ctl_find_numid(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return; return;
} }
...@@ -636,7 +640,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer, ...@@ -636,7 +640,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,
uctl->value.integer.value[0] = snd_mixer_oss_conv2(left, uinfo->value.integer.min, uinfo->value.integer.max); uctl->value.integer.value[0] = snd_mixer_oss_conv2(left, uinfo->value.integer.min, uinfo->value.integer.max);
if (uinfo->count > 1) if (uinfo->count > 1)
uctl->value.integer.value[1] = snd_mixer_oss_conv2(right, uinfo->value.integer.min, uinfo->value.integer.max); uctl->value.integer.value[1] = snd_mixer_oss_conv2(right, uinfo->value.integer.min, uinfo->value.integer.max);
if ((res = kctl->put(kctl, uctl)) < 0) res = kctl->put(kctl, uctl);
if (res < 0)
goto __unalloc; goto __unalloc;
if (res > 0) if (res > 0)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
...@@ -661,7 +666,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer, ...@@ -661,7 +666,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN) if (numid == ID_UNKNOWN)
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { kctl = snd_ctl_find_numid(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return; return;
} }
...@@ -681,7 +687,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer, ...@@ -681,7 +687,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,
} else { } else {
uctl->value.integer.value[0] = (left > 0 || right > 0) ? 1 : 0; uctl->value.integer.value[0] = (left > 0 || right > 0) ? 1 : 0;
} }
if ((res = kctl->put(kctl, uctl)) < 0) res = kctl->put(kctl, uctl);
if (res < 0)
goto __unalloc; goto __unalloc;
if (res > 0) if (res > 0)
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
...@@ -809,9 +816,11 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned ...@@ -809,9 +816,11 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
err = -ENOENT; err = -ENOENT;
goto __unlock; goto __unlock;
} }
if ((err = kctl->info(kctl, uinfo)) < 0) err = kctl->info(kctl, uinfo);
if (err < 0)
goto __unlock; goto __unlock;
if ((err = kctl->get(kctl, uctl)) < 0) err = kctl->get(kctl, uctl);
if (err < 0)
goto __unlock; goto __unlock;
for (idx = 0; idx < 32; idx++) { for (idx = 0; idx < 32; idx++) {
if (!(mixer->mask_recsrc & (1 << idx))) if (!(mixer->mask_recsrc & (1 << idx)))
...@@ -860,7 +869,8 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned ...@@ -860,7 +869,8 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
err = -ENOENT; err = -ENOENT;
goto __unlock; goto __unlock;
} }
if ((err = kctl->info(kctl, uinfo)) < 0) err = kctl->info(kctl, uinfo);
if (err < 0)
goto __unlock; goto __unlock;
for (idx = 0; idx < 32; idx++) { for (idx = 0; idx < 32; idx++) {
if (!(mixer->mask_recsrc & (1 << idx))) if (!(mixer->mask_recsrc & (1 << idx)))
...@@ -915,7 +925,8 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl ...@@ -915,7 +925,8 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return -ENOMEM; return -ENOMEM;
} }
if ((err = kcontrol->info(kcontrol, info)) < 0) { err = kcontrol->info(kcontrol, info);
if (err < 0) {
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
kfree(info); kfree(info);
return err; return err;
...@@ -1036,7 +1047,10 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, ...@@ -1036,7 +1047,10 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer,
if (snd_mixer_oss_build_test_all(mixer, ptr, &slot)) if (snd_mixer_oss_build_test_all(mixer, ptr, &slot))
return 0; return 0;
down_read(&mixer->card->controls_rwsem); down_read(&mixer->card->controls_rwsem);
if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) { kctl = NULL;
if (!ptr->index)
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
if (kctl) {
struct snd_ctl_elem_info *uinfo; struct snd_ctl_elem_info *uinfo;
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
...@@ -1343,9 +1357,10 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) ...@@ -1343,9 +1357,10 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
if (mixer == NULL) if (mixer == NULL)
return -ENOMEM; return -ENOMEM;
mutex_init(&mixer->reg_mutex); mutex_init(&mixer->reg_mutex);
if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
card, 0, card, 0,
&snd_mixer_oss_f_ops, card)) < 0) { &snd_mixer_oss_f_ops, card);
if (err < 0) {
dev_err(card->dev, dev_err(card->dev,
"unable to register OSS mixer device %i:%i\n", "unable to register OSS mixer device %i:%i\n",
card->number, 0); card->number, 0);
......
...@@ -955,9 +955,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) ...@@ -955,9 +955,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
if (!direct) { if (!direct) {
/* add necessary plugins */ /* add necessary plugins */
snd_pcm_oss_plugin_clear(substream); snd_pcm_oss_plugin_clear(substream);
if ((err = snd_pcm_plug_format_plugins(substream, err = snd_pcm_plug_format_plugins(substream, params, sparams);
params, if (err < 0) {
sparams)) < 0) {
pcm_dbg(substream->pcm, pcm_dbg(substream->pcm,
"snd_pcm_plug_format_plugins failed: %i\n", err); "snd_pcm_plug_format_plugins failed: %i\n", err);
snd_pcm_oss_plugin_clear(substream); snd_pcm_oss_plugin_clear(substream);
...@@ -965,7 +964,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) ...@@ -965,7 +964,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
} }
if (runtime->oss.plugin_first) { if (runtime->oss.plugin_first) {
struct snd_pcm_plugin *plugin; struct snd_pcm_plugin *plugin;
if ((err = snd_pcm_plugin_build_io(substream, sparams, &plugin)) < 0) { err = snd_pcm_plugin_build_io(substream, sparams, &plugin);
if (err < 0) {
pcm_dbg(substream->pcm, pcm_dbg(substream->pcm,
"snd_pcm_plugin_build_io failed: %i\n", err); "snd_pcm_plugin_build_io failed: %i\n", err);
snd_pcm_oss_plugin_clear(substream); snd_pcm_oss_plugin_clear(substream);
...@@ -1011,7 +1011,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) ...@@ -1011,7 +1011,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
sw_params->silence_size = frames; sw_params->silence_size = frames;
} }
if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params)) < 0) { err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params);
if (err < 0) {
pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err); pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err);
goto failure; goto failure;
} }
...@@ -1573,7 +1574,8 @@ static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1573,7 +1574,8 @@ static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file)
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
if (substream != NULL) { if (substream != NULL) {
if ((err = snd_pcm_oss_make_ready(substream)) < 0) err = snd_pcm_oss_make_ready(substream);
if (err < 0)
return err; return err;
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL); snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL);
} }
...@@ -1645,7 +1647,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1645,7 +1647,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
runtime = substream->runtime; runtime = substream->runtime;
if (atomic_read(&substream->mmap_count)) if (atomic_read(&substream->mmap_count))
goto __direct; goto __direct;
if ((err = snd_pcm_oss_make_ready(substream)) < 0) err = snd_pcm_oss_make_ready(substream);
if (err < 0)
return err; return err;
atomic_inc(&runtime->oss.rw_ref); atomic_inc(&runtime->oss.rw_ref);
if (mutex_lock_interruptible(&runtime->oss.params_lock)) { if (mutex_lock_interruptible(&runtime->oss.params_lock)) {
...@@ -1711,7 +1714,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1711,7 +1714,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
if (substream != NULL) { if (substream != NULL) {
if ((err = snd_pcm_oss_make_ready(substream)) < 0) err = snd_pcm_oss_make_ready(substream);
if (err < 0)
return err; return err;
runtime = substream->runtime; runtime = substream->runtime;
err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
...@@ -1758,7 +1762,8 @@ static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1758,7 +1762,8 @@ static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file)
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int err; int err;
if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
if (err < 0)
return err; return err;
return substream->runtime->oss.rate; return substream->runtime->oss.rate;
} }
...@@ -1795,7 +1800,8 @@ static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1795,7 +1800,8 @@ static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file)
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int err; int err;
if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
if (err < 0)
return err; return err;
return substream->runtime->oss.channels; return substream->runtime->oss.channels;
} }
...@@ -1805,7 +1811,8 @@ static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1805,7 +1811,8 @@ static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file)
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int err; int err;
if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
if (err < 0)
return err; return err;
return substream->runtime->oss.period_bytes; return substream->runtime->oss.period_bytes;
} }
...@@ -1820,7 +1827,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1820,7 +1827,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
const struct snd_mask *format_mask; const struct snd_mask *format_mask;
int fmt; int fmt;
if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
if (err < 0)
return err; return err;
if (atomic_read(&substream->mmap_count)) if (atomic_read(&substream->mmap_count))
direct = 1; direct = 1;
...@@ -1890,7 +1898,8 @@ static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -1890,7 +1898,8 @@ static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file)
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int err; int err;
if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream);
if (err < 0)
return err; return err;
return substream->runtime->oss.format; return substream->runtime->oss.format;
} }
...@@ -2050,11 +2059,13 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr ...@@ -2050,11 +2059,13 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
csubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; csubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
if (psubstream) { if (psubstream) {
if ((err = snd_pcm_oss_make_ready(psubstream)) < 0) err = snd_pcm_oss_make_ready(psubstream);
if (err < 0)
return err; return err;
} }
if (csubstream) { if (csubstream) {
if ((err = snd_pcm_oss_make_ready(csubstream)) < 0) err = snd_pcm_oss_make_ready(csubstream);
if (err < 0)
return err; return err;
} }
if (psubstream) { if (psubstream) {
...@@ -2141,7 +2152,8 @@ static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file) ...@@ -2141,7 +2152,8 @@ static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file)
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
if (substream == NULL) if (substream == NULL)
return -EINVAL; return -EINVAL;
if ((err = snd_pcm_oss_make_ready(substream)) < 0) err = snd_pcm_oss_make_ready(substream);
if (err < 0)
return err; return err;
runtime = substream->runtime; runtime = substream->runtime;
if (runtime->oss.params || runtime->oss.prepare) if (runtime->oss.params || runtime->oss.prepare)
...@@ -2168,7 +2180,8 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream ...@@ -2168,7 +2180,8 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
substream = pcm_oss_file->streams[stream]; substream = pcm_oss_file->streams[stream];
if (substream == NULL) if (substream == NULL)
return -EINVAL; return -EINVAL;
if ((err = snd_pcm_oss_make_ready(substream)) < 0) err = snd_pcm_oss_make_ready(substream);
if (err < 0)
return err; return err;
runtime = substream->runtime; runtime = substream->runtime;
if (runtime->oss.params || runtime->oss.prepare) { if (runtime->oss.params || runtime->oss.prepare) {
...@@ -2239,9 +2252,11 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre ...@@ -2239,9 +2252,11 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
return -EINVAL; return -EINVAL;
runtime = substream->runtime; runtime = substream->runtime;
if (runtime->oss.params && if (runtime->oss.params) {
(err = snd_pcm_oss_change_params(substream, false)) < 0) err = snd_pcm_oss_change_params(substream, false);
return err; if (err < 0)
return err;
}
info.fragsize = runtime->oss.period_bytes; info.fragsize = runtime->oss.period_bytes;
info.fragstotal = runtime->periods; info.fragstotal = runtime->periods;
...@@ -2601,7 +2616,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -2601,7 +2616,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
case SNDCTL_DSP_SPEED: case SNDCTL_DSP_SPEED:
if (get_user(res, p)) if (get_user(res, p))
return -EFAULT; return -EFAULT;
if ((res = snd_pcm_oss_set_rate(pcm_oss_file, res))<0) res = snd_pcm_oss_set_rate(pcm_oss_file, res);
if (res < 0)
return res; return res;
return put_user(res, p); return put_user(res, p);
case SOUND_PCM_READ_RATE: case SOUND_PCM_READ_RATE:
...@@ -2613,7 +2629,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -2613,7 +2629,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
if (get_user(res, p)) if (get_user(res, p))
return -EFAULT; return -EFAULT;
res = res > 0 ? 2 : 1; res = res > 0 ? 2 : 1;
if ((res = snd_pcm_oss_set_channels(pcm_oss_file, res)) < 0) res = snd_pcm_oss_set_channels(pcm_oss_file, res);
if (res < 0)
return res; return res;
return put_user(--res, p); return put_user(--res, p);
case SNDCTL_DSP_GETBLKSIZE: case SNDCTL_DSP_GETBLKSIZE:
...@@ -2829,7 +2846,8 @@ static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait) ...@@ -2829,7 +2846,8 @@ static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait)
snd_pcm_state_t ostate; snd_pcm_state_t ostate;
poll_wait(file, &runtime->sleep, wait); poll_wait(file, &runtime->sleep, wait);
snd_pcm_stream_lock_irq(csubstream); snd_pcm_stream_lock_irq(csubstream);
if ((ostate = runtime->status->state) != SNDRV_PCM_STATE_RUNNING || ostate = runtime->status->state;
if (ostate != SNDRV_PCM_STATE_RUNNING ||
snd_pcm_oss_capture_ready(csubstream)) snd_pcm_oss_capture_ready(csubstream))
mask |= EPOLLIN | EPOLLRDNORM; mask |= EPOLLIN | EPOLLRDNORM;
snd_pcm_stream_unlock_irq(csubstream); snd_pcm_stream_unlock_irq(csubstream);
...@@ -3043,7 +3061,8 @@ static void snd_pcm_oss_proc_init(struct snd_pcm *pcm) ...@@ -3043,7 +3061,8 @@ static void snd_pcm_oss_proc_init(struct snd_pcm *pcm)
struct snd_pcm_str *pstr = &pcm->streams[stream]; struct snd_pcm_str *pstr = &pcm->streams[stream];
if (pstr->substream_count == 0) if (pstr->substream_count == 0)
continue; continue;
if ((entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root)) != NULL) { entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root);
if (entry) {
entry->content = SNDRV_INFO_CONTENT_TEXT; entry->content = SNDRV_INFO_CONTENT_TEXT;
entry->mode = S_IFREG | 0644; entry->mode = S_IFREG | 0644;
entry->c.text.read = snd_pcm_oss_proc_read; entry->c.text.read = snd_pcm_oss_proc_read;
...@@ -3191,7 +3210,8 @@ static int __init alsa_pcm_oss_init(void) ...@@ -3191,7 +3210,8 @@ static int __init alsa_pcm_oss_init(void)
adsp_map[i] = 1; adsp_map[i] = 1;
} }
} }
if ((err = snd_pcm_notify(&snd_pcm_oss_notify, 0)) < 0) err = snd_pcm_notify(&snd_pcm_oss_notify, 0);
if (err < 0)
return err; return err;
return 0; return 0;
} }
......
...@@ -59,7 +59,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t ...@@ -59,7 +59,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
} else { } else {
format = &plugin->dst_format; format = &plugin->dst_format;
} }
if ((width = snd_pcm_format_physical_width(format->format)) < 0) width = snd_pcm_format_physical_width(format->format);
if (width < 0)
return width; return width;
size = frames * format->channels * width; size = frames * format->channels * width;
if (snd_BUG_ON(size % 8)) if (snd_BUG_ON(size % 8))
...@@ -572,7 +573,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu ...@@ -572,7 +573,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
} }
v = plugin->buf_channels; v = plugin->buf_channels;
*channels = v; *channels = v;
if ((width = snd_pcm_format_physical_width(format->format)) < 0) width = snd_pcm_format_physical_width(format->format);
if (width < 0)
return width; return width;
nchannels = format->channels; nchannels = format->channels;
if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
...@@ -600,16 +602,17 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st ...@@ -600,16 +602,17 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
while (plugin) { while (plugin) {
if (frames <= 0) if (frames <= 0)
return frames; return frames;
if ((next = plugin->next) != NULL) { next = plugin->next;
if (next) {
snd_pcm_sframes_t frames1 = frames; snd_pcm_sframes_t frames1 = frames;
if (plugin->dst_frames) { if (plugin->dst_frames) {
frames1 = plugin->dst_frames(plugin, frames); frames1 = plugin->dst_frames(plugin, frames);
if (frames1 <= 0) if (frames1 <= 0)
return frames1; return frames1;
} }
if ((err = next->client_channels(next, frames1, &dst_channels)) < 0) { err = next->client_channels(next, frames1, &dst_channels);
if (err < 0)
return err; return err;
}
if (err != frames1) { if (err != frames1) {
frames = err; frames = err;
if (plugin->src_frames) { if (plugin->src_frames) {
...@@ -621,7 +624,8 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st ...@@ -621,7 +624,8 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
} else } else
dst_channels = NULL; dst_channels = NULL;
pdprintf("write plugin: %s, %li\n", plugin->name, frames); pdprintf("write plugin: %s, %li\n", plugin->name, frames);
if ((frames = plugin->transfer(plugin, src_channels, dst_channels, frames)) < 0) frames = plugin->transfer(plugin, src_channels, dst_channels, frames);
if (frames < 0)
return frames; return frames;
src_channels = dst_channels; src_channels = dst_channels;
plugin = next; plugin = next;
...@@ -643,16 +647,18 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str ...@@ -643,16 +647,18 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str
src_channels = NULL; src_channels = NULL;
plugin = snd_pcm_plug_first(plug); plugin = snd_pcm_plug_first(plug);
while (plugin && frames > 0) { while (plugin && frames > 0) {
if ((next = plugin->next) != NULL) { next = plugin->next;
if ((err = plugin->client_channels(plugin, frames, &dst_channels)) < 0) { if (next) {
err = plugin->client_channels(plugin, frames, &dst_channels);
if (err < 0)
return err; return err;
}
frames = err; frames = err;
} else { } else {
dst_channels = dst_channels_final; dst_channels = dst_channels_final;
} }
pdprintf("read plugin: %s, %li\n", plugin->name, frames); pdprintf("read plugin: %s, %li\n", plugin->name, frames);
if ((frames = plugin->transfer(plugin, src_channels, dst_channels, frames)) < 0) frames = plugin->transfer(plugin, src_channels, dst_channels, frames);
if (frames < 0)
return frames; return frames;
plugin = next; plugin = next;
src_channels = dst_channels; src_channels = dst_channels;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment