~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/core/oss/copy.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  Linear conversion Plug-In
  3  *  Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
  4  *
  5  *
  6  *   This library is free software; you can redistribute it and/or modify
  7  *   it under the terms of the GNU Library General Public License as
  8  *   published by the Free Software Foundation; either version 2 of
  9  *   the License, or (at your option) any later version.
 10  *
 11  *   This program is distributed in the hope that it will be useful,
 12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  *   GNU Library General Public License for more details.
 15  *
 16  *   You should have received a copy of the GNU Library General Public
 17  *   License along with this library; if not, write to the Free Software
 18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 19  *
 20  */
 21 
 22 #include <linux/time.h>
 23 #include <sound/core.h>
 24 #include <sound/pcm.h>
 25 #include "pcm_plugin.h"
 26 
 27 static snd_pcm_sframes_t copy_transfer(struct snd_pcm_plugin *plugin,
 28                              const struct snd_pcm_plugin_channel *src_channels,
 29                              struct snd_pcm_plugin_channel *dst_channels,
 30                              snd_pcm_uframes_t frames)
 31 {
 32         unsigned int channel;
 33         unsigned int nchannels;
 34 
 35         if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
 36                 return -ENXIO;
 37         if (frames == 0)
 38                 return 0;
 39         nchannels = plugin->src_format.channels;
 40         for (channel = 0; channel < nchannels; channel++) {
 41                 if (snd_BUG_ON(src_channels->area.first % 8 ||
 42                                src_channels->area.step % 8))
 43                         return -ENXIO;
 44                 if (snd_BUG_ON(dst_channels->area.first % 8 ||
 45                                dst_channels->area.step % 8))
 46                         return -ENXIO;
 47                 if (!src_channels->enabled) {
 48                         if (dst_channels->wanted)
 49                                 snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format);
 50                         dst_channels->enabled = 0;
 51                         continue;
 52                 }
 53                 dst_channels->enabled = 1;
 54                 snd_pcm_area_copy(&src_channels->area, 0, &dst_channels->area, 0, frames, plugin->src_format.format);
 55                 src_channels++;
 56                 dst_channels++;
 57         }
 58         return frames;
 59 }
 60 
 61 int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug,
 62                               struct snd_pcm_plugin_format *src_format,
 63                               struct snd_pcm_plugin_format *dst_format,
 64                               struct snd_pcm_plugin **r_plugin)
 65 {
 66         int err;
 67         struct snd_pcm_plugin *plugin;
 68         int width;
 69 
 70         if (snd_BUG_ON(!r_plugin))
 71                 return -ENXIO;
 72         *r_plugin = NULL;
 73 
 74         if (snd_BUG_ON(src_format->format != dst_format->format))
 75                 return -ENXIO;
 76         if (snd_BUG_ON(src_format->rate != dst_format->rate))
 77                 return -ENXIO;
 78         if (snd_BUG_ON(src_format->channels != dst_format->channels))
 79                 return -ENXIO;
 80 
 81         width = snd_pcm_format_physical_width(src_format->format);
 82         if (snd_BUG_ON(width <= 0))
 83                 return -ENXIO;
 84 
 85         err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format,
 86                                    0, &plugin);
 87         if (err < 0)
 88                 return err;
 89         plugin->transfer = copy_transfer;
 90         *r_plugin = plugin;
 91         return 0;
 92 }
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php