mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Changed other static checks in assert
This commit is contained in:
		
							parent
							
								
									ef2a9bdd88
								
							
						
					
					
						commit
						a44c94959e
					
				
					 15 changed files with 258 additions and 473 deletions
				
			
		| 
						 | 
					@ -25,7 +25,6 @@
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <sys/poll.h>
 | 
					#include <sys/poll.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include "pcm_local.h"
 | 
					#include "pcm_local.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int snd_pcm_abstract_open(snd_pcm_t **handle, int mode,
 | 
					int snd_pcm_abstract_open(snd_pcm_t **handle, int mode,
 | 
				
			||||||
| 
						 | 
					@ -125,7 +124,7 @@ int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
 | 
				
			||||||
		if (pcm->stream[stream].open)
 | 
							if (pcm->stream[stream].open)
 | 
				
			||||||
			return pcm->ops->info(pcm, stream, info);
 | 
								return pcm->ops->info(pcm, stream, info);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return -EBADFD;
 | 
						assert(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int snd_pcm_stream_info(snd_pcm_t *pcm, snd_pcm_stream_info_t *info)
 | 
					int snd_pcm_stream_info(snd_pcm_t *pcm, snd_pcm_stream_info_t *info)
 | 
				
			||||||
| 
						 | 
					@ -285,7 +284,7 @@ int snd_pcm_sync_go(snd_pcm_t *pcm, snd_pcm_sync_t *sync)
 | 
				
			||||||
		if (pcm->stream[stream].open)
 | 
							if (pcm->stream[stream].open)
 | 
				
			||||||
			return pcm->ops->sync_go(pcm, stream, sync);
 | 
								return pcm->ops->sync_go(pcm, stream, sync);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return -EBADFD;
 | 
						assert(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int snd_pcm_stream_drain(snd_pcm_t *pcm, int stream)
 | 
					int snd_pcm_stream_drain(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,14 +81,12 @@ static ssize_t snd_pcm_plugin_side_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	if ((width = snd_pcm_format_physical_width(format->format)) < 0)
 | 
						if ((width = snd_pcm_format_physical_width(format->format)) < 0)
 | 
				
			||||||
		return width;	
 | 
							return width;	
 | 
				
			||||||
	size = format->channels * frames * width;
 | 
						size = format->channels * frames * width;
 | 
				
			||||||
	if ((size % 8) != 0)
 | 
						assert(size % 8 == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	size /= 8;
 | 
						size /= 8;
 | 
				
			||||||
	ptr = (char *)snd_pcm_plug_buf_alloc(plugin->handle, plugin->stream, size);
 | 
						ptr = (char *)snd_pcm_plug_buf_alloc(plugin->handle, plugin->stream, size);
 | 
				
			||||||
	if (ptr == NULL)
 | 
						if (ptr == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	if ((size % format->channels) != 0)
 | 
						assert(size % format->channels == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	size /= format->channels;
 | 
						size /= format->channels;
 | 
				
			||||||
	for (channel = 0; channel < format->channels; channel++, v++) {
 | 
						for (channel = 0; channel < format->channels; channel++, v++) {
 | 
				
			||||||
		v->enabled = 1;
 | 
							v->enabled = 1;
 | 
				
			||||||
| 
						 | 
					@ -127,19 +125,14 @@ int snd_pcm_plugin_build(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
			 const char *name,
 | 
								 const char *name,
 | 
				
			||||||
			 snd_pcm_format_t *src_format,
 | 
								 snd_pcm_format_t *src_format,
 | 
				
			||||||
			 snd_pcm_format_t *dst_format,
 | 
								 snd_pcm_format_t *dst_format,
 | 
				
			||||||
			 int extra,
 | 
								 size_t extra,
 | 
				
			||||||
			 snd_pcm_plugin_t **ret)
 | 
								 snd_pcm_plugin_t **ret)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!handle)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (extra < 0)
 | 
						assert(src_format && dst_format);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (!src_format || !dst_format)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	plugin = (snd_pcm_plugin_t *)calloc(1, sizeof(*plugin) + extra);
 | 
						plugin = (snd_pcm_plugin_t *)calloc(1, sizeof(*plugin) + extra);
 | 
				
			||||||
	if (plugin == NULL)
 | 
						if (plugin == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					@ -147,11 +140,11 @@ int snd_pcm_plugin_build(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	plugin->handle = handle;
 | 
						plugin->handle = handle;
 | 
				
			||||||
	plugin->stream = stream;
 | 
						plugin->stream = stream;
 | 
				
			||||||
	memcpy(&plugin->src_format, src_format, sizeof(snd_pcm_format_t));
 | 
						memcpy(&plugin->src_format, src_format, sizeof(snd_pcm_format_t));
 | 
				
			||||||
	if ((plugin->src_width = snd_pcm_format_physical_width(src_format->format)) < 0)
 | 
						plugin->src_width = snd_pcm_format_physical_width(src_format->format);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(plugin->src_width > 0);
 | 
				
			||||||
	memcpy(&plugin->dst_format, dst_format, sizeof(snd_pcm_format_t));
 | 
						memcpy(&plugin->dst_format, dst_format, sizeof(snd_pcm_format_t));
 | 
				
			||||||
	if ((plugin->dst_width = snd_pcm_format_physical_width(dst_format->format)) < 0)
 | 
						plugin->dst_width = snd_pcm_format_physical_width(dst_format->format);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(plugin->dst_width > 0);
 | 
				
			||||||
	plugin->src_channels = calloc(src_format->channels, sizeof(snd_pcm_plugin_channel_t));
 | 
						plugin->src_channels = calloc(src_format->channels, sizeof(snd_pcm_plugin_channel_t));
 | 
				
			||||||
	if (plugin->src_channels == NULL) {
 | 
						if (plugin->src_channels == NULL) {
 | 
				
			||||||
		free(plugin);
 | 
							free(plugin);
 | 
				
			||||||
| 
						 | 
					@ -205,11 +198,9 @@ ssize_t snd_pcm_plugin_src_frames_to_size(snd_pcm_plugin_t *plugin, size_t frame
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	result = frames * plugin->src_format.channels * plugin->src_width;
 | 
						result = frames * plugin->src_format.channels * plugin->src_width;
 | 
				
			||||||
	if (result % 8 != 0)
 | 
						assert(result % 8 == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	return result / 8;
 | 
						return result / 8;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -217,11 +208,9 @@ ssize_t snd_pcm_plugin_dst_frames_to_size(snd_pcm_plugin_t *plugin, size_t frame
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	result = frames * plugin->dst_format.channels * plugin->dst_width;
 | 
						result = frames * plugin->dst_format.channels * plugin->dst_width;
 | 
				
			||||||
	if (result % 8 != 0)
 | 
						assert(result % 8 == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	return result / 8;
 | 
						return result / 8;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -230,12 +219,10 @@ ssize_t snd_pcm_plugin_src_size_to_frames(snd_pcm_plugin_t *plugin, size_t size)
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
	long tmp;
 | 
						long tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	result = size * 8;
 | 
						result = size * 8;
 | 
				
			||||||
	tmp = plugin->src_format.channels * plugin->src_width;
 | 
						tmp = plugin->src_format.channels * plugin->src_width;
 | 
				
			||||||
	if (result % tmp != 0)
 | 
						assert(result % tmp == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	return result / tmp;
 | 
						return result / tmp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,12 +231,10 @@ ssize_t snd_pcm_plugin_dst_size_to_frames(snd_pcm_plugin_t *plugin, size_t size)
 | 
				
			||||||
	ssize_t result;
 | 
						ssize_t result;
 | 
				
			||||||
	long tmp;
 | 
						long tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	result = size * 8;
 | 
						result = size * 8;
 | 
				
			||||||
	tmp = plugin->dst_format.channels * plugin->dst_width;
 | 
						tmp = plugin->dst_format.channels * plugin->dst_width;
 | 
				
			||||||
	if (result % tmp != 0)
 | 
						assert(result % tmp == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	return result / tmp;
 | 
						return result / tmp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -257,11 +242,7 @@ ssize_t snd_pcm_plug_client_frames(snd_pcm_plugin_handle_t *handle, int stream,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
 | 
						snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (handle == NULL)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream != SND_PCM_STREAM_PLAYBACK &&
 | 
					 | 
				
			||||||
	    stream != SND_PCM_STREAM_CAPTURE)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (drv_frames == 0)
 | 
						if (drv_frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
| 
						 | 
					@ -280,7 +261,8 @@ ssize_t snd_pcm_plug_client_frames(snd_pcm_plugin_handle_t *handle, int stream,
 | 
				
			||||||
				drv_frames = plugin->dst_frames(plugin, drv_frames);
 | 
									drv_frames = plugin->dst_frames(plugin, drv_frames);
 | 
				
			||||||
			plugin = plugin_next;
 | 
								plugin = plugin_next;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						} else
 | 
				
			||||||
 | 
							assert(0);
 | 
				
			||||||
	return drv_frames;
 | 
						return drv_frames;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -289,11 +271,7 @@ ssize_t snd_pcm_plug_slave_frames(snd_pcm_plugin_handle_t *handle, int stream, s
 | 
				
			||||||
	snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
 | 
						snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
 | 
				
			||||||
	ssize_t frames;
 | 
						ssize_t frames;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (handle == NULL)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream != SND_PCM_STREAM_PLAYBACK &&
 | 
					 | 
				
			||||||
	    stream != SND_PCM_STREAM_CAPTURE)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (clt_frames == 0)
 | 
						if (clt_frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	frames = clt_frames;
 | 
						frames = clt_frames;
 | 
				
			||||||
| 
						 | 
					@ -319,7 +297,8 @@ ssize_t snd_pcm_plug_slave_frames(snd_pcm_plugin_handle_t *handle, int stream, s
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			plugin = plugin_prev;
 | 
								plugin = plugin_prev;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} 
 | 
						} else
 | 
				
			||||||
 | 
							assert(0);
 | 
				
			||||||
	return frames;
 | 
						return frames;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -328,11 +307,7 @@ ssize_t snd_pcm_plug_client_size(snd_pcm_plugin_handle_t *handle, int stream, si
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	ssize_t result = 0;
 | 
						ssize_t result = 0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (handle == NULL)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream != SND_PCM_STREAM_PLAYBACK &&
 | 
					 | 
				
			||||||
	    stream != SND_PCM_STREAM_CAPTURE)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (drv_size == 0)
 | 
						if (drv_size == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
| 
						 | 
					@ -359,7 +334,8 @@ ssize_t snd_pcm_plug_client_size(snd_pcm_plugin_handle_t *handle, int stream, si
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		plugin = snd_pcm_plug_last(handle, SND_PCM_STREAM_CAPTURE);
 | 
							plugin = snd_pcm_plug_last(handle, SND_PCM_STREAM_CAPTURE);
 | 
				
			||||||
		result = snd_pcm_plugin_dst_frames_to_size(plugin, result);
 | 
							result = snd_pcm_plugin_dst_frames_to_size(plugin, result);
 | 
				
			||||||
	}
 | 
						} else
 | 
				
			||||||
 | 
							assert(0);
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -368,11 +344,7 @@ ssize_t snd_pcm_plug_slave_size(snd_pcm_plugin_handle_t *handle, int stream, siz
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	ssize_t result = 0;
 | 
						ssize_t result = 0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (handle == NULL)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream != SND_PCM_STREAM_PLAYBACK &&
 | 
					 | 
				
			||||||
	    stream != SND_PCM_STREAM_CAPTURE)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (clt_size == 0)
 | 
						if (clt_size == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
| 
						 | 
					@ -399,7 +371,8 @@ ssize_t snd_pcm_plug_slave_size(snd_pcm_plugin_handle_t *handle, int stream, siz
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		plugin = snd_pcm_plug_first(handle, SND_PCM_STREAM_CAPTURE);
 | 
							plugin = snd_pcm_plug_first(handle, SND_PCM_STREAM_CAPTURE);
 | 
				
			||||||
		result = snd_pcm_plugin_src_frames_to_size(plugin, result);
 | 
							result = snd_pcm_plugin_src_frames_to_size(plugin, result);
 | 
				
			||||||
	} 
 | 
						} else
 | 
				
			||||||
 | 
							assert(0);
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -548,6 +521,7 @@ int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		memcpy(srcparams, slave_params, sizeof(*slave_params));
 | 
							memcpy(srcparams, slave_params, sizeof(*slave_params));
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
 | 
							assert(0);
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	memcpy(&tmpparams, srcparams, sizeof(*srcparams));
 | 
						memcpy(&tmpparams, srcparams, sizeof(*srcparams));
 | 
				
			||||||
| 
						 | 
					@ -808,8 +782,7 @@ ssize_t snd_pcm_plug_client_channels_buf(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_format_t *format;
 | 
						snd_pcm_format_t *format;
 | 
				
			||||||
	int width, nchannels, channel;
 | 
						int width, nchannels, channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (buf == NULL)
 | 
						assert(buf);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
		plugin = snd_pcm_plug_first(handle, stream);
 | 
							plugin = snd_pcm_plug_first(handle, stream);
 | 
				
			||||||
		format = &plugin->src_format;
 | 
							format = &plugin->src_format;
 | 
				
			||||||
| 
						 | 
					@ -823,22 +796,18 @@ ssize_t snd_pcm_plug_client_channels_buf(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	*channels = v;
 | 
						*channels = v;
 | 
				
			||||||
	if ((width = snd_pcm_format_physical_width(format->format)) < 0)
 | 
						if ((width = snd_pcm_format_physical_width(format->format)) < 0)
 | 
				
			||||||
		return width;
 | 
							return width;
 | 
				
			||||||
	if ((count * 8) % width != 0)
 | 
						assert(count * 8 % width == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	nchannels = format->channels;
 | 
						nchannels = format->channels;
 | 
				
			||||||
	if (format->interleave ||
 | 
						assert(format->interleave || format->channels == 1);
 | 
				
			||||||
	    format->channels == 1) {
 | 
						for (channel = 0; channel < nchannels; channel++, v++) {
 | 
				
			||||||
		for (channel = 0; channel < nchannels; channel++, v++) {
 | 
							v->enabled = 1;
 | 
				
			||||||
			v->enabled = 1;
 | 
							v->wanted = (stream == SND_PCM_STREAM_CAPTURE);
 | 
				
			||||||
			v->wanted = (stream == SND_PCM_STREAM_CAPTURE);
 | 
							v->aptr = NULL;
 | 
				
			||||||
			v->aptr = NULL;
 | 
							v->area.addr = buf;
 | 
				
			||||||
			v->area.addr = buf;
 | 
							v->area.first = channel * width;
 | 
				
			||||||
			v->area.first = channel * width;
 | 
							v->area.step = nchannels * width;
 | 
				
			||||||
			v->area.step = nchannels * width;
 | 
						}
 | 
				
			||||||
		}
 | 
						return count;
 | 
				
			||||||
		return count;
 | 
					 | 
				
			||||||
	} else
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ssize_t snd_pcm_plug_client_channels_iovec(snd_pcm_plugin_handle_t *handle,
 | 
					ssize_t snd_pcm_plug_client_channels_iovec(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
| 
						 | 
					@ -868,9 +837,8 @@ ssize_t snd_pcm_plug_client_channels_iovec(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		return width;
 | 
							return width;
 | 
				
			||||||
	nchannels = format->channels;
 | 
						nchannels = format->channels;
 | 
				
			||||||
	if (format->interleave) {
 | 
						if (format->interleave) {
 | 
				
			||||||
		if (count != 1 || vector->iov_base == NULL ||
 | 
							assert(count == 1 && vector->iov_base &&
 | 
				
			||||||
		    (vector->iov_len * 8) % width != 0)
 | 
							       vector->iov_len * 8 % width == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		for (channel = 0; channel < nchannels; channel++, v++) {
 | 
							for (channel = 0; channel < nchannels; channel++, v++) {
 | 
				
			||||||
			v->enabled = 1;
 | 
								v->enabled = 1;
 | 
				
			||||||
| 
						 | 
					@ -883,14 +851,11 @@ ssize_t snd_pcm_plug_client_channels_iovec(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		return vector->iov_len;
 | 
							return vector->iov_len;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		size_t len;
 | 
							size_t len;
 | 
				
			||||||
		if (count != nchannels)
 | 
							assert(count == nchannels);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		len = vector->iov_len;
 | 
							len = vector->iov_len;
 | 
				
			||||||
		if ((len * 8) % width != 0)
 | 
							assert(len * 8 % width == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		for (channel = 0; channel < nchannels; channel++, v++, vector++) {
 | 
							for (channel = 0; channel < nchannels; channel++, v++, vector++) {
 | 
				
			||||||
			if (vector->iov_len != len)
 | 
								assert(vector->iov_len == len);
 | 
				
			||||||
				return -EINVAL;
 | 
					 | 
				
			||||||
			v->enabled = (vector->iov_base != NULL);
 | 
								v->enabled = (vector->iov_base != NULL);
 | 
				
			||||||
			v->wanted = (v->enabled && (stream == SND_PCM_STREAM_CAPTURE));
 | 
								v->wanted = (v->enabled && (stream == SND_PCM_STREAM_CAPTURE));
 | 
				
			||||||
			v->aptr = NULL;
 | 
								v->aptr = NULL;
 | 
				
			||||||
| 
						 | 
					@ -1234,7 +1199,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, size_t dst_offs
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1370,7 +1335,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *src_area, size_t src_offset,
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,17 +54,6 @@ static int snd_pcm_hw_stream_close(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int snd_pcm_hw_stream_fd(snd_pcm_t *pcm, int stream)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	snd_pcm_hw_t *hw;
 | 
					 | 
				
			||||||
	if (!pcm)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	hw = (snd_pcm_hw_t*) &pcm->private;
 | 
					 | 
				
			||||||
	return hw->stream[stream].fd;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int snd_pcm_hw_stream_nonblock(snd_pcm_t *pcm, int stream, int nonblock)
 | 
					static int snd_pcm_hw_stream_nonblock(snd_pcm_t *pcm, int stream, int nonblock)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	long flags;
 | 
						long flags;
 | 
				
			||||||
| 
						 | 
					@ -377,7 +366,7 @@ static int snd_pcm_hw_open_stream(int card, int device, int stream, int subdevic
 | 
				
			||||||
		filefmt = SND_FILE_PCM_CAPTURE;
 | 
							filefmt = SND_FILE_PCM_CAPTURE;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if ((err = snd_ctl_pcm_stream_prefer_subdevice(ctl, device, stream, subdevice)) < 0)
 | 
						if ((err = snd_ctl_pcm_stream_prefer_subdevice(ctl, device, stream, subdevice)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
| 
						 | 
					@ -424,12 +413,10 @@ int snd_pcm_open_subdevice(snd_pcm_t **handle, int card, int device, int subdevi
 | 
				
			||||||
	snd_ctl_t *ctl;
 | 
						snd_ctl_t *ctl;
 | 
				
			||||||
	int pfd = -1, cfd = -1;
 | 
						int pfd = -1, cfd = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!handle)
 | 
						assert(handle);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	*handle = NULL;
 | 
						*handle = NULL;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (card < 0 || card >= SND_CARDS)
 | 
						assert(card >= 0 && card < SND_CARDS);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if ((err = snd_ctl_open(&ctl, card)) < 0)
 | 
						if ((err = snd_ctl_open(&ctl, card)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	if (mode & SND_PCM_OPEN_PLAYBACK) {
 | 
						if (mode & SND_PCM_OPEN_PLAYBACK) {
 | 
				
			||||||
| 
						 | 
					@ -457,8 +444,7 @@ int snd_pcm_open_subdevice(snd_pcm_t **handle, int card, int device, int subdevi
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	snd_ctl_close(ctl);
 | 
						snd_ctl_close(ctl);
 | 
				
			||||||
	if (pfd < 0 && cfd < 0)
 | 
						assert(pfd >= 0 || cfd >= 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_abstract_open(handle, mode, SND_PCM_TYPE_HW, sizeof(snd_pcm_hw_t));
 | 
						err = snd_pcm_abstract_open(handle, mode, SND_PCM_TYPE_HW, sizeof(snd_pcm_hw_t));
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pthread.h>
 | 
					#include <assert.h>
 | 
				
			||||||
#include "asoundlib.h"
 | 
					#include "asoundlib.h"
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
struct snd_pcm_ops {
 | 
					struct snd_pcm_ops {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,6 @@
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <malloc.h>
 | 
					#include <malloc.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include <sys/poll.h>
 | 
					#include <sys/poll.h>
 | 
				
			||||||
#include <sys/uio.h>
 | 
					#include <sys/uio.h>
 | 
				
			||||||
#include "pcm_local.h"
 | 
					#include "pcm_local.h"
 | 
				
			||||||
| 
						 | 
					@ -43,13 +42,10 @@ static size_t snd_pcm_mmap_capture_frames_avail(snd_pcm_t *pcm)
 | 
				
			||||||
int snd_pcm_frames_avail(snd_pcm_t *pcm, int stream, ssize_t *frames)
 | 
					int snd_pcm_frames_avail(snd_pcm_t *pcm, int stream, ssize_t *frames)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
        if (!pcm)
 | 
					        assert(pcm);
 | 
				
			||||||
                return -EFAULT;
 | 
					        assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
        if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
                return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_control)
 | 
						assert(str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK)
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK)
 | 
				
			||||||
		*frames = snd_pcm_mmap_playback_frames_avail(pcm);
 | 
							*frames = snd_pcm_mmap_playback_frames_avail(pcm);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -85,16 +81,12 @@ int snd_pcm_mmap_ready(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	snd_pcm_mmap_control_t *ctrl;
 | 
						snd_pcm_mmap_control_t *ctrl;
 | 
				
			||||||
        if (!pcm)
 | 
					        assert(pcm);
 | 
				
			||||||
                return -EFAULT;
 | 
					        assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
        if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
                return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_control)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	ctrl = str->mmap_control;
 | 
						ctrl = str->mmap_control;
 | 
				
			||||||
	if (ctrl->status < SND_PCM_STATUS_PREPARED)
 | 
						assert(ctrl);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(ctrl->status >= SND_PCM_STATUS_PREPARED);
 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
		return snd_pcm_mmap_playback_ready(pcm);
 | 
							return snd_pcm_mmap_playback_ready(pcm);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					@ -149,13 +141,10 @@ static ssize_t snd_pcm_mmap_capture_frames_xfer(snd_pcm_t *pcm, size_t frames)
 | 
				
			||||||
ssize_t snd_pcm_mmap_frames_xfer(snd_pcm_t *pcm, int stream, size_t frames)
 | 
					ssize_t snd_pcm_mmap_frames_xfer(snd_pcm_t *pcm, int stream, size_t frames)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
        if (!pcm)
 | 
					        assert(pcm);
 | 
				
			||||||
                return -EFAULT;
 | 
					        assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
        if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
                return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_control)
 | 
						assert(str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (stream == SND_PCM_STREAM_PLAYBACK)
 | 
						if (stream == SND_PCM_STREAM_PLAYBACK)
 | 
				
			||||||
		return snd_pcm_mmap_playback_frames_xfer(pcm, frames);
 | 
							return snd_pcm_mmap_playback_frames_xfer(pcm, frames);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -166,16 +155,11 @@ ssize_t snd_pcm_mmap_frames_offset(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	snd_pcm_mmap_control_t *ctrl;
 | 
						snd_pcm_mmap_control_t *ctrl;
 | 
				
			||||||
        if (!pcm)
 | 
					        assert(pcm);
 | 
				
			||||||
                return -EFAULT;
 | 
					        assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
        if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
                return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_control)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	ctrl = str->mmap_control;
 | 
						ctrl = str->mmap_control;
 | 
				
			||||||
	if (!ctrl)
 | 
						assert(ctrl);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	return (ctrl->byte_data % str->setup.buffer_size) * 8 / str->bits_per_frame;
 | 
						return (ctrl->byte_data % str->setup.buffer_size) * 8 / str->bits_per_frame;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,11 +249,9 @@ ssize_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_channel_area_t *channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
						str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
				
			||||||
	ctrl = str->mmap_control;
 | 
						ctrl = str->mmap_control;
 | 
				
			||||||
	if (ctrl->status < SND_PCM_STATUS_PREPARED)
 | 
						assert(ctrl->status >= SND_PCM_STATUS_PREPARED);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (str->setup.mode == SND_PCM_MODE_FRAGMENT) {
 | 
						if (str->setup.mode == SND_PCM_MODE_FRAGMENT) {
 | 
				
			||||||
		if (frames % str->frames_per_frag != 0)
 | 
							assert(frames % str->frames_per_frag == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (ctrl->status == SND_PCM_STATUS_RUNNING &&
 | 
							if (ctrl->status == SND_PCM_STATUS_RUNNING &&
 | 
				
			||||||
		    str->mode & SND_PCM_NONBLOCK)
 | 
							    str->mode & SND_PCM_NONBLOCK)
 | 
				
			||||||
| 
						 | 
					@ -322,16 +304,12 @@ ssize_t snd_pcm_mmap_write_frames(snd_pcm_t *pcm, const void *buffer, size_t fra
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
						str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(frames == 0 || buffer);
 | 
				
			||||||
	if (frames > 0 && !buffer)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (!str->setup.format.interleave && nchannels > 1)
 | 
						assert(str->setup.format.interleave || nchannels == 1);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		snd_pcm_channel_area_t channels[nchannels];
 | 
							snd_pcm_channel_area_t channels[nchannels];
 | 
				
			||||||
		unsigned int channel;
 | 
							unsigned int channel;
 | 
				
			||||||
| 
						 | 
					@ -349,16 +327,12 @@ ssize_t snd_pcm_mmap_write(snd_pcm_t *pcm, const void *buffer, size_t bytes)
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	ssize_t frames;
 | 
						ssize_t frames;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
						str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(bytes == 0 || buffer);
 | 
				
			||||||
	if (bytes > 0 && !buffer)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (!str->setup.format.interleave && nchannels > 1)
 | 
						assert(str->setup.format.interleave || nchannels == 1);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	frames = bytes * 8 / str->bits_per_frame;
 | 
						frames = bytes * 8 / str->bits_per_frame;
 | 
				
			||||||
	frames = snd_pcm_mmap_write_frames(pcm, buffer, frames);
 | 
						frames = snd_pcm_mmap_write_frames(pcm, buffer, frames);
 | 
				
			||||||
	if (frames <= 0)
 | 
						if (frames <= 0)
 | 
				
			||||||
| 
						 | 
					@ -371,13 +345,10 @@ ssize_t snd_pcm_mmap_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	size_t result = 0;
 | 
						size_t result = 0;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
						str = &pcm->stream[SND_PCM_STREAM_PLAYBACK];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(vcount == 0 || vector);
 | 
				
			||||||
	if (vcount > 0 && !vector)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (str->setup.format.interleave) {
 | 
						if (str->setup.format.interleave) {
 | 
				
			||||||
		unsigned int b;
 | 
							unsigned int b;
 | 
				
			||||||
| 
						 | 
					@ -396,8 +367,7 @@ ssize_t snd_pcm_mmap_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
		snd_pcm_channel_area_t channels[nchannels];
 | 
							snd_pcm_channel_area_t channels[nchannels];
 | 
				
			||||||
		unsigned long bcount;
 | 
							unsigned long bcount;
 | 
				
			||||||
		unsigned int b;
 | 
							unsigned int b;
 | 
				
			||||||
		if (vcount % nchannels)
 | 
							assert(vcount % nchannels == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		bcount = vcount / nchannels;
 | 
							bcount = vcount / nchannels;
 | 
				
			||||||
		for (b = 0; b < bcount; b++) {
 | 
							for (b = 0; b < bcount; b++) {
 | 
				
			||||||
			unsigned int v;
 | 
								unsigned int v;
 | 
				
			||||||
| 
						 | 
					@ -406,8 +376,7 @@ ssize_t snd_pcm_mmap_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
			size_t frames;
 | 
								size_t frames;
 | 
				
			||||||
			bytes = vector[0].iov_len;
 | 
								bytes = vector[0].iov_len;
 | 
				
			||||||
			for (v = 0; v < nchannels; ++v) {
 | 
								for (v = 0; v < nchannels; ++v) {
 | 
				
			||||||
				if (vector[v].iov_len != bytes)
 | 
									assert(vector[v].iov_len == bytes);
 | 
				
			||||||
					return -EINVAL;
 | 
					 | 
				
			||||||
				channels[v].addr = vector[v].iov_base;
 | 
									channels[v].addr = vector[v].iov_base;
 | 
				
			||||||
				channels[v].first = 0;
 | 
									channels[v].first = 0;
 | 
				
			||||||
				channels[v].step = str->sample_width;
 | 
									channels[v].step = str->sample_width;
 | 
				
			||||||
| 
						 | 
					@ -438,11 +407,9 @@ ssize_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_channel_area_t *channels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
						str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
				
			||||||
	ctrl = str->mmap_control;
 | 
						ctrl = str->mmap_control;
 | 
				
			||||||
	if (ctrl->status < SND_PCM_STATUS_PREPARED)
 | 
						assert(ctrl->status >= SND_PCM_STATUS_PREPARED);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (str->setup.mode == SND_PCM_MODE_FRAGMENT) {
 | 
						if (str->setup.mode == SND_PCM_MODE_FRAGMENT) {
 | 
				
			||||||
		if (frames % str->frames_per_frag != 0)
 | 
							assert(frames % str->frames_per_frag == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (ctrl->status == SND_PCM_STATUS_RUNNING &&
 | 
							if (ctrl->status == SND_PCM_STATUS_RUNNING &&
 | 
				
			||||||
		    str->mode & SND_PCM_NONBLOCK)
 | 
							    str->mode & SND_PCM_NONBLOCK)
 | 
				
			||||||
| 
						 | 
					@ -494,16 +461,12 @@ ssize_t snd_pcm_mmap_read_frames(snd_pcm_t *pcm, const void *buffer, size_t fram
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
						str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(frames == 0 || buffer);
 | 
				
			||||||
	if (frames > 0 && !buffer)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (!str->setup.format.interleave && nchannels > 1)
 | 
						assert(str->setup.format.interleave || nchannels == 1);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		snd_pcm_channel_area_t channels[nchannels];
 | 
							snd_pcm_channel_area_t channels[nchannels];
 | 
				
			||||||
		unsigned int channel;
 | 
							unsigned int channel;
 | 
				
			||||||
| 
						 | 
					@ -521,16 +484,12 @@ ssize_t snd_pcm_mmap_read(snd_pcm_t *pcm, void *buffer, size_t bytes)
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	ssize_t frames;
 | 
						ssize_t frames;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
						str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(bytes == 0 || buffer);
 | 
				
			||||||
	if (bytes > 0 && !buffer)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (!str->setup.format.interleave && nchannels > 1)
 | 
						assert(str->setup.format.interleave || nchannels == 1);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	frames = bytes * 8 / str->bits_per_frame;
 | 
						frames = bytes * 8 / str->bits_per_frame;
 | 
				
			||||||
	frames = snd_pcm_mmap_read_frames(pcm, buffer, frames);
 | 
						frames = snd_pcm_mmap_read_frames(pcm, buffer, frames);
 | 
				
			||||||
	if (frames <= 0)
 | 
						if (frames <= 0)
 | 
				
			||||||
| 
						 | 
					@ -543,13 +502,10 @@ ssize_t snd_pcm_mmap_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	size_t result = 0;
 | 
						size_t result = 0;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
						str = &pcm->stream[SND_PCM_STREAM_CAPTURE];
 | 
				
			||||||
	if (!str->mmap_data || !str->mmap_control)
 | 
						assert(str->mmap_data && str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
						assert(vcount == 0 || vector);
 | 
				
			||||||
	if (vcount > 0 && !vector)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	nchannels = str->setup.format.channels;
 | 
						nchannels = str->setup.format.channels;
 | 
				
			||||||
	if (str->setup.format.interleave) {
 | 
						if (str->setup.format.interleave) {
 | 
				
			||||||
		unsigned int b;
 | 
							unsigned int b;
 | 
				
			||||||
| 
						 | 
					@ -568,8 +524,7 @@ ssize_t snd_pcm_mmap_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
		snd_pcm_channel_area_t channels[nchannels];
 | 
							snd_pcm_channel_area_t channels[nchannels];
 | 
				
			||||||
		unsigned long bcount;
 | 
							unsigned long bcount;
 | 
				
			||||||
		unsigned int b;
 | 
							unsigned int b;
 | 
				
			||||||
		if (vcount % nchannels)
 | 
							assert(vcount % nchannels == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		bcount = vcount / nchannels;
 | 
							bcount = vcount / nchannels;
 | 
				
			||||||
		for (b = 0; b < bcount; b++) {
 | 
							for (b = 0; b < bcount; b++) {
 | 
				
			||||||
			unsigned int v;
 | 
								unsigned int v;
 | 
				
			||||||
| 
						 | 
					@ -578,8 +533,7 @@ ssize_t snd_pcm_mmap_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
			size_t frames;
 | 
								size_t frames;
 | 
				
			||||||
			bytes = vector[0].iov_len;
 | 
								bytes = vector[0].iov_len;
 | 
				
			||||||
			for (v = 0; v < nchannels; ++v) {
 | 
								for (v = 0; v < nchannels; ++v) {
 | 
				
			||||||
				if (vector[v].iov_len != bytes)
 | 
									assert(vector[v].iov_len == bytes);
 | 
				
			||||||
					return -EINVAL;
 | 
					 | 
				
			||||||
				channels[v].addr = vector[v].iov_base;
 | 
									channels[v].addr = vector[v].iov_base;
 | 
				
			||||||
				channels[v].first = 0;
 | 
									channels[v].first = 0;
 | 
				
			||||||
				channels[v].step = str->sample_width;
 | 
									channels[v].step = str->sample_width;
 | 
				
			||||||
| 
						 | 
					@ -605,22 +559,21 @@ int snd_pcm_mmap_control(snd_pcm_t *pcm, int stream, snd_pcm_mmap_control_t **co
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	size_t csize;
 | 
						size_t csize;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	if (!pcm || !control)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->valid_setup)
 | 
						assert(str->valid_setup);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (str->mmap_control) {
 | 
						if (str->mmap_control) {
 | 
				
			||||||
		*control = str->mmap_control;
 | 
							if (control)
 | 
				
			||||||
 | 
								*control = str->mmap_control;
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	csize = sizeof(snd_pcm_mmap_control_t);
 | 
						csize = sizeof(snd_pcm_mmap_control_t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((err = pcm->ops->mmap_control(pcm, stream, control, csize)) < 0)
 | 
						if ((err = pcm->ops->mmap_control(pcm, stream, &str->mmap_control, csize)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	str->mmap_control = *control;
 | 
						if (control)
 | 
				
			||||||
 | 
							*control = str->mmap_control;
 | 
				
			||||||
	str->mmap_control_size = csize;
 | 
						str->mmap_control_size = csize;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -633,13 +586,10 @@ int snd_pcm_mmap_get_areas(snd_pcm_t *pcm, int stream, snd_pcm_channel_area_t *a
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
	int interleaved = 1, noninterleaved = 1;
 | 
						int interleaved = 1, noninterleaved = 1;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_data)
 | 
						assert(str->mmap_data);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	a = calloc(str->setup.format.channels, sizeof(*areas));
 | 
						a = calloc(str->setup.format.channels, sizeof(*areas));
 | 
				
			||||||
	for (channel = 0, ap = a; channel < str->setup.format.channels; ++channel, ++ap) {
 | 
						for (channel = 0, ap = a; channel < str->setup.format.channels; ++channel, ++ap) {
 | 
				
			||||||
		s.channel = channel;
 | 
							s.channel = channel;
 | 
				
			||||||
| 
						 | 
					@ -674,15 +624,13 @@ int snd_pcm_mmap_data(snd_pcm_t *pcm, int stream, void **data)
 | 
				
			||||||
	snd_pcm_stream_info_t info;
 | 
						snd_pcm_stream_info_t info;
 | 
				
			||||||
	size_t bsize;
 | 
						size_t bsize;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	if (!pcm || !data)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->valid_setup)
 | 
						assert(str->valid_setup);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if (str->mmap_data) {
 | 
						if (str->mmap_data) {
 | 
				
			||||||
		*data = str->mmap_data;
 | 
							if (data)
 | 
				
			||||||
 | 
								*data = str->mmap_data;
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -693,9 +641,10 @@ int snd_pcm_mmap_data(snd_pcm_t *pcm, int stream, void **data)
 | 
				
			||||||
	bsize = info.mmap_size;
 | 
						bsize = info.mmap_size;
 | 
				
			||||||
	if (!(info.flags & SND_PCM_STREAM_INFO_MMAP))
 | 
						if (!(info.flags & SND_PCM_STREAM_INFO_MMAP))
 | 
				
			||||||
		return -ENXIO;
 | 
							return -ENXIO;
 | 
				
			||||||
	if ((err = pcm->ops->mmap_data(pcm, stream, data, bsize)) < 0)
 | 
						if ((err = pcm->ops->mmap_data(pcm, stream, (void**)&str->mmap_data, bsize)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	str->mmap_data = *data;
 | 
						if (data) 
 | 
				
			||||||
 | 
							*data = str->mmap_data;
 | 
				
			||||||
	str->mmap_data_size = bsize;
 | 
						str->mmap_data_size = bsize;
 | 
				
			||||||
	err = snd_pcm_mmap_get_areas(pcm, stream, NULL);
 | 
						err = snd_pcm_mmap_get_areas(pcm, stream, NULL);
 | 
				
			||||||
	if (err < 0)
 | 
						if (err < 0)
 | 
				
			||||||
| 
						 | 
					@ -721,13 +670,10 @@ int snd_pcm_munmap_control(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_control)
 | 
						assert(str->mmap_control);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if ((err = pcm->ops->munmap_control(pcm, stream, str->mmap_control, str->mmap_control_size)) < 0)
 | 
						if ((err = pcm->ops->munmap_control(pcm, stream, str->mmap_control, str->mmap_control_size)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	str->mmap_control = 0;
 | 
						str->mmap_control = 0;
 | 
				
			||||||
| 
						 | 
					@ -739,13 +685,10 @@ int snd_pcm_munmap_data(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &pcm->stream[stream];
 | 
						str = &pcm->stream[stream];
 | 
				
			||||||
	if (!str->mmap_data)
 | 
						assert(str->mmap_data);
 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
	if ((err = pcm->ops->munmap_data(pcm, stream, str->mmap_data, str->mmap_data_size)) < 0)
 | 
						if ((err = pcm->ops->munmap_data(pcm, stream, str->mmap_data, str->mmap_data_size)) < 0)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	free(str->channels);
 | 
						free(str->channels);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,8 +86,7 @@ int snd_pcm_plugin_insert(snd_pcm_plugin_t *plugin)
 | 
				
			||||||
	snd_pcm_plug_t *plug;
 | 
						snd_pcm_plug_t *plug;
 | 
				
			||||||
	snd_pcm_plug_stream_t *plugstr;
 | 
						snd_pcm_plug_stream_t *plugstr;
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
	if (!plugin)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	pcm = plugin->handle;
 | 
						pcm = plugin->handle;
 | 
				
			||||||
	plug = (snd_pcm_plug_t*) &pcm->private;
 | 
						plug = (snd_pcm_plug_t*) &pcm->private;
 | 
				
			||||||
	plugstr = &plug->stream[plugin->stream];
 | 
						plugstr = &plug->stream[plugin->stream];
 | 
				
			||||||
| 
						 | 
					@ -108,8 +107,7 @@ int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin)
 | 
				
			||||||
	snd_pcm_plug_t *plug;
 | 
						snd_pcm_plug_t *plug;
 | 
				
			||||||
	snd_pcm_plug_stream_t *plugstr;
 | 
						snd_pcm_plug_stream_t *plugstr;
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
	if (!plugin)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	pcm = plugin->handle;
 | 
						pcm = plugin->handle;
 | 
				
			||||||
	plug = (snd_pcm_plug_t*) &pcm->private;
 | 
						plug = (snd_pcm_plug_t*) &pcm->private;
 | 
				
			||||||
	plugstr = &plug->stream[plugin->stream];
 | 
						plugstr = &plug->stream[plugin->stream];
 | 
				
			||||||
| 
						 | 
					@ -133,8 +131,7 @@ int snd_pcm_plugin_remove_to(snd_pcm_plugin_t *plugin)
 | 
				
			||||||
	snd_pcm_plug_t *plug;
 | 
						snd_pcm_plug_t *plug;
 | 
				
			||||||
	snd_pcm_t *pcm;
 | 
						snd_pcm_t *pcm;
 | 
				
			||||||
	snd_pcm_plug_stream_t *plugstr;
 | 
						snd_pcm_plug_stream_t *plugstr;
 | 
				
			||||||
	if (!plugin)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	pcm = plugin->handle;
 | 
						pcm = plugin->handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plug = (snd_pcm_plug_t*) &pcm->private;
 | 
						plug = (snd_pcm_plug_t*) &pcm->private;
 | 
				
			||||||
| 
						 | 
					@ -161,12 +158,9 @@ int snd_pcm_plug_remove_first(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	snd_pcm_plug_t *plug;
 | 
						snd_pcm_plug_t *plug;
 | 
				
			||||||
	snd_pcm_plug_stream_t *plugstr;
 | 
						snd_pcm_plug_stream_t *plugstr;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EFAULT;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
						assert(pcm->stream[stream].open);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (!pcm->stream[stream].open)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plug = (snd_pcm_plug_t*) &pcm->private;
 | 
						plug = (snd_pcm_plug_t*) &pcm->private;
 | 
				
			||||||
	plugstr = &plug->stream[stream];
 | 
						plugstr = &plug->stream[stream];
 | 
				
			||||||
| 
						 | 
					@ -190,12 +184,9 @@ int snd_pcm_plug_clear(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
	snd_pcm_plug_stream_t *plugstr;
 | 
						snd_pcm_plug_stream_t *plugstr;
 | 
				
			||||||
	int idx;
 | 
						int idx;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(stream >= 0 && stream <= 1);
 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
						assert(pcm->stream[stream].open);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (!pcm->stream[stream].open)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plug = (snd_pcm_plug_t*) &pcm->private;
 | 
						plug = (snd_pcm_plug_t*) &pcm->private;
 | 
				
			||||||
	plugstr = &plug->stream[stream];
 | 
						plugstr = &plug->stream[stream];
 | 
				
			||||||
| 
						 | 
					@ -257,40 +248,6 @@ int snd_pcm_plug_direct(snd_pcm_t *pcm, int stream)
 | 
				
			||||||
	return snd_pcm_plug_first(pcm, stream) == NULL;
 | 
						return snd_pcm_plug_first(pcm, stream) == NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
double snd_pcm_plug_client_ratio(snd_pcm_t *pcm, int stream)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ssize_t client;
 | 
					 | 
				
			||||||
	if (!pcm)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (!pcm->stream[stream].open)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	client = snd_pcm_plug_client_size(pcm, stream, 1000000);
 | 
					 | 
				
			||||||
	if (client < 0)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	return (double)client / (double)1000000;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
double snd_pcm_plug_slave_ratio(snd_pcm_t *pcm, int stream)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ssize_t slave;
 | 
					 | 
				
			||||||
	if (!pcm)
 | 
					 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (stream < 0 || stream > 1)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (!pcm->stream[stream].open)
 | 
					 | 
				
			||||||
		return -EBADFD;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	slave = snd_pcm_plug_slave_size(pcm, stream, 1000000);
 | 
					 | 
				
			||||||
	if (slave < 0)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	return (double)slave / (double)1000000;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -377,6 +334,7 @@ static int snd_pcm_plug_stream_params(snd_pcm_t *pcm, snd_pcm_stream_params_t *p
 | 
				
			||||||
	snd_pcm_stream_info_t slave_info;
 | 
						snd_pcm_stream_info_t slave_info;
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	snd_pcm_plug_t *plug;
 | 
						snd_pcm_plug_t *plug;
 | 
				
			||||||
 | 
						size_t bytes_per_frame;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
	int stream = params->stream;
 | 
						int stream = params->stream;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -408,12 +366,21 @@ static int snd_pcm_plug_stream_params(snd_pcm_t *pcm, snd_pcm_stream_params_t *p
 | 
				
			||||||
		return snd_pcm_stream_params(plug->slave, params);
 | 
							return snd_pcm_stream_params(plug->slave, params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* compute right sizes */
 | 
						/* compute right sizes */
 | 
				
			||||||
	slave_params.frag_size = snd_pcm_plug_slave_size(pcm, stream, params->frag_size);
 | 
						bytes_per_frame = snd_pcm_format_size(params->format.format, params->format.channels);
 | 
				
			||||||
	slave_params.buffer_size = snd_pcm_plug_slave_size(pcm, stream, params->buffer_size);
 | 
						if (bytes_per_frame == 0)
 | 
				
			||||||
	slave_params.bytes_fill_max = snd_pcm_plug_slave_size(pcm, stream, params->bytes_fill_max);
 | 
							bytes_per_frame = 1;
 | 
				
			||||||
	slave_params.bytes_min = snd_pcm_plug_slave_size(pcm, stream, params->bytes_min);
 | 
						params1.frag_size -= params1.frag_size % bytes_per_frame;
 | 
				
			||||||
	slave_params.bytes_xrun_max = snd_pcm_plug_slave_size(pcm, stream, params->bytes_xrun_max);
 | 
						slave_params.frag_size = snd_pcm_plug_slave_size(pcm, stream, params1.frag_size);
 | 
				
			||||||
	slave_params.bytes_align = snd_pcm_plug_slave_size(pcm, stream, params->bytes_align);
 | 
						params1.buffer_size -= params1.buffer_size % bytes_per_frame;
 | 
				
			||||||
 | 
						slave_params.buffer_size = snd_pcm_plug_slave_size(pcm, stream, params1.buffer_size);
 | 
				
			||||||
 | 
						params1.bytes_fill_max -= params1.bytes_fill_max % bytes_per_frame;
 | 
				
			||||||
 | 
						slave_params.bytes_fill_max = snd_pcm_plug_slave_size(pcm, stream, params1.bytes_fill_max);
 | 
				
			||||||
 | 
						params1.bytes_min -= params1.bytes_min % bytes_per_frame;
 | 
				
			||||||
 | 
						slave_params.bytes_min = snd_pcm_plug_slave_size(pcm, stream, params1.bytes_min);
 | 
				
			||||||
 | 
						params1.bytes_xrun_max -= params1.bytes_xrun_max % bytes_per_frame;
 | 
				
			||||||
 | 
						slave_params.bytes_xrun_max = snd_pcm_plug_slave_size(pcm, stream, params1.bytes_xrun_max);
 | 
				
			||||||
 | 
						params1.bytes_align -= params1.bytes_align % bytes_per_frame;
 | 
				
			||||||
 | 
						slave_params.bytes_align = snd_pcm_plug_slave_size(pcm, stream, params1.bytes_align);
 | 
				
			||||||
	if (slave_params.byte_boundary == 0 || slave_params.byte_boundary > INT_MAX)
 | 
						if (slave_params.byte_boundary == 0 || slave_params.byte_boundary > INT_MAX)
 | 
				
			||||||
		slave_params.byte_boundary = INT_MAX;
 | 
							slave_params.byte_boundary = INT_MAX;
 | 
				
			||||||
	slave_params.byte_boundary /= params->buffer_size;
 | 
						slave_params.byte_boundary /= params->buffer_size;
 | 
				
			||||||
| 
						 | 
					@ -625,8 +592,7 @@ ssize_t snd_pcm_plug_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
		step = 1;
 | 
							step = 1;
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		step = channels;
 | 
							step = channels;
 | 
				
			||||||
		if (count % channels != 0)
 | 
							assert(count % channels == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for (k = 0; k < count; k += step, vector += step) {
 | 
						for (k = 0; k < count; k += step, vector += step) {
 | 
				
			||||||
		snd_pcm_plugin_channel_t *channels;
 | 
							snd_pcm_plugin_channel_t *channels;
 | 
				
			||||||
| 
						 | 
					@ -660,8 +626,7 @@ ssize_t snd_pcm_plug_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned
 | 
				
			||||||
		step = 1;
 | 
							step = 1;
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		step = channels;
 | 
							step = channels;
 | 
				
			||||||
		if (count % channels != 0)
 | 
							assert(count % channels == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for (k = 0; k < count; k += step) {
 | 
						for (k = 0; k < count; k += step) {
 | 
				
			||||||
		snd_pcm_plugin_channel_t *channels;
 | 
							snd_pcm_plugin_channel_t *channels;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,23 +333,20 @@ static ssize_t adpcm_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	adpcm_t *data;
 | 
						adpcm_t *data;
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
						for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
				
			||||||
		if (plugin->src_format.format == SND_PCM_SFMT_IMA_ADPCM) {
 | 
							if (plugin->src_format.format == SND_PCM_SFMT_IMA_ADPCM) {
 | 
				
			||||||
			if (src_channels[channel].area.first % 4 != 0 ||
 | 
								assert(src_channels[channel].area.first % 4 == 0 &&
 | 
				
			||||||
			    src_channels[channel].area.step % 4 != 0 ||
 | 
								       src_channels[channel].area.step % 4 == 0 &&
 | 
				
			||||||
			    dst_channels[channel].area.first % 8 != 0 ||
 | 
								       dst_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
			    dst_channels[channel].area.step % 8 != 0)
 | 
								       dst_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
				return -EINVAL;
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if (src_channels[channel].area.first % 8 != 0 ||
 | 
								assert(src_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
			    src_channels[channel].area.step % 8 != 0 ||
 | 
								       src_channels[channel].area.step % 8 == 0 &&
 | 
				
			||||||
			    dst_channels[channel].area.first % 4 != 0 ||
 | 
								       dst_channels[channel].area.first % 4 == 0 &&
 | 
				
			||||||
			    dst_channels[channel].area.step % 4 != 0)
 | 
								       dst_channels[channel].area.step % 4 == 0);
 | 
				
			||||||
				return -EINVAL;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	data = (adpcm_t *)plugin->extra_data;
 | 
						data = (adpcm_t *)plugin->extra_data;
 | 
				
			||||||
| 
						 | 
					@ -361,8 +358,7 @@ static int adpcm_action(snd_pcm_plugin_t * plugin,
 | 
				
			||||||
			snd_pcm_plugin_action_t action,
 | 
								snd_pcm_plugin_action_t action,
 | 
				
			||||||
			unsigned long udata UNUSED)
 | 
								unsigned long udata UNUSED)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	switch (action) {
 | 
						switch (action) {
 | 
				
			||||||
	case INIT:
 | 
						case INIT:
 | 
				
			||||||
	case PREPARE:
 | 
						case PREPARE:
 | 
				
			||||||
| 
						 | 
					@ -388,14 +384,11 @@ int snd_pcm_plugin_build_adpcm(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_format_t *format;
 | 
						snd_pcm_format_t *format;
 | 
				
			||||||
	adpcm_f func;
 | 
						adpcm_f func;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dst_format->format == SND_PCM_SFMT_IMA_ADPCM) {
 | 
						if (dst_format->format == SND_PCM_SFMT_IMA_ADPCM) {
 | 
				
			||||||
		format = src_format;
 | 
							format = src_format;
 | 
				
			||||||
| 
						 | 
					@ -406,9 +399,8 @@ int snd_pcm_plugin_build_adpcm(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		func = adpcm_decode;
 | 
							func = adpcm_decode;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	if (!snd_pcm_format_linear(format->format))
 | 
						assert(snd_pcm_format_linear(format->format));
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "Ima-ADPCM<->linear conversion",
 | 
									   "Ima-ADPCM<->linear conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -234,17 +234,14 @@ static ssize_t alaw_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	alaw_t *data;
 | 
						alaw_t *data;
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
						for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
				
			||||||
		if (src_channels[channel].area.first % 8 != 0 || 
 | 
							assert(src_channels[channel].area.first % 8 == 0 && 
 | 
				
			||||||
		    src_channels[channel].area.step % 8 != 0)
 | 
							       src_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
							assert(dst_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		if (dst_channels[channel].area.first % 8 != 0 || 
 | 
							       dst_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
		    dst_channels[channel].area.step % 8 != 0)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	data = (alaw_t *)plugin->extra_data;
 | 
						data = (alaw_t *)plugin->extra_data;
 | 
				
			||||||
	data->func(plugin, src_channels, dst_channels, frames);
 | 
						data->func(plugin, src_channels, dst_channels, frames);
 | 
				
			||||||
| 
						 | 
					@ -263,14 +260,11 @@ int snd_pcm_plugin_build_alaw(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_format_t *format;
 | 
						snd_pcm_format_t *format;
 | 
				
			||||||
	alaw_f func;
 | 
						alaw_f func;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dst_format->format == SND_PCM_SFMT_A_LAW) {
 | 
						if (dst_format->format == SND_PCM_SFMT_A_LAW) {
 | 
				
			||||||
		format = src_format;
 | 
							format = src_format;
 | 
				
			||||||
| 
						 | 
					@ -281,9 +275,8 @@ int snd_pcm_plugin_build_alaw(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		func = alaw_decode;
 | 
							func = alaw_decode;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	if (!snd_pcm_format_linear(format->format))
 | 
						assert(snd_pcm_format_linear(format->format));
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "A-Law<->linear conversion",
 | 
									   "A-Law<->linear conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,18 +42,15 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
	unsigned int nchannels;
 | 
						unsigned int nchannels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	nchannels = plugin->src_format.channels;
 | 
						nchannels = plugin->src_format.channels;
 | 
				
			||||||
	for (channel = 0; channel < nchannels; channel++) {
 | 
						for (channel = 0; channel < nchannels; channel++) {
 | 
				
			||||||
		if (src_channels->area.first % 8 != 0 || 
 | 
							assert(src_channels->area.first % 8 == 0 &&
 | 
				
			||||||
		    src_channels->area.step % 8 != 0)
 | 
							       src_channels->area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
							assert(dst_channels->area.first % 8 == 0 &&
 | 
				
			||||||
		if (dst_channels->area.first % 8 != 0 || 
 | 
							       dst_channels->area.step % 8 == 0);
 | 
				
			||||||
		    dst_channels->area.step % 8 != 0)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		if (!src_channels->enabled) {
 | 
							if (!src_channels->enabled) {
 | 
				
			||||||
			if (dst_channels->wanted)
 | 
								if (dst_channels->wanted)
 | 
				
			||||||
				snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format);
 | 
									snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format);
 | 
				
			||||||
| 
						 | 
					@ -78,20 +75,15 @@ int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	int width;
 | 
						int width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->format != dst_format->format)
 | 
						assert(src_format->format == dst_format->format);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	width = snd_pcm_format_physical_width(src_format->format);
 | 
						width = snd_pcm_format_physical_width(src_format->format);
 | 
				
			||||||
	if (width < 0)
 | 
						assert(width > 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "copy",
 | 
									   "copy",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,15 +55,12 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	struct iovec *vec;
 | 
						struct iovec *vec;
 | 
				
			||||||
	int count, channel;
 | 
						int count, channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	data = (io_t *)plugin->extra_data;
 | 
						data = (io_t *)plugin->extra_data;
 | 
				
			||||||
	if (data == NULL)
 | 
						assert(data);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	vec = (struct iovec *)((char *)data + sizeof(*data));
 | 
						vec = (struct iovec *)((char *)data + sizeof(*data));
 | 
				
			||||||
	if (plugin->stream == SND_PCM_STREAM_PLAYBACK) {
 | 
						if (plugin->stream == SND_PCM_STREAM_PLAYBACK) {
 | 
				
			||||||
		if (src_channels == NULL)
 | 
							assert(src_channels);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		if ((result = snd_pcm_plugin_src_frames_to_size(plugin, frames)) < 0)
 | 
							if ((result = snd_pcm_plugin_src_frames_to_size(plugin, frames)) < 0)
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		count = plugin->src_format.channels;
 | 
							count = plugin->src_format.channels;
 | 
				
			||||||
| 
						 | 
					@ -84,8 +81,7 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		return snd_pcm_plugin_src_size_to_frames(plugin, result);
 | 
							return snd_pcm_plugin_src_size_to_frames(plugin, result);
 | 
				
			||||||
	} else if (plugin->stream == SND_PCM_STREAM_CAPTURE) {
 | 
						} else if (plugin->stream == SND_PCM_STREAM_CAPTURE) {
 | 
				
			||||||
		if (dst_channels == NULL)
 | 
							assert(dst_channels);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
		if ((result = snd_pcm_plugin_dst_frames_to_size(plugin, frames)) < 0)
 | 
							if ((result = snd_pcm_plugin_dst_frames_to_size(plugin, frames)) < 0)
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		count = plugin->dst_format.channels;
 | 
							count = plugin->dst_format.channels;
 | 
				
			||||||
| 
						 | 
					@ -110,8 +106,9 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
			return result;
 | 
								return result;
 | 
				
			||||||
		return snd_pcm_plugin_dst_size_to_frames(plugin, result);
 | 
							return snd_pcm_plugin_dst_size_to_frames(plugin, result);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
static ssize_t io_src_channels(snd_pcm_plugin_t *plugin,
 | 
					static ssize_t io_src_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
| 
						 | 
					@ -140,11 +137,9 @@ int snd_pcm_plugin_build_io(snd_pcm_plugin_handle_t *pcm,
 | 
				
			||||||
	io_t *data;
 | 
						io_t *data;
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
	if (pcm == NULL || format == NULL)
 | 
						assert(pcm && format);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	err = snd_pcm_plugin_build(pcm, stream,
 | 
						err = snd_pcm_plugin_build(pcm, stream,
 | 
				
			||||||
				   "I/O io",
 | 
									   "I/O io",
 | 
				
			||||||
				   format, format,
 | 
									   format, format,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,18 +92,15 @@ static ssize_t linear_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	linear_t *data;
 | 
						linear_t *data;
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	data = (linear_t *)plugin->extra_data;
 | 
						data = (linear_t *)plugin->extra_data;
 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
						for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
				
			||||||
		if (src_channels[channel].area.first % 8 != 0 || 
 | 
							assert(src_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		    src_channels[channel].area.step % 8 != 0)
 | 
							       src_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
							assert(dst_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		if (dst_channels[channel].area.first % 8 != 0 || 
 | 
							       dst_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
		    dst_channels[channel].area.step % 8 != 0)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	convert(plugin, src_channels, dst_channels, frames);
 | 
						convert(plugin, src_channels, dst_channels, frames);
 | 
				
			||||||
	return frames;
 | 
						return frames;
 | 
				
			||||||
| 
						 | 
					@ -144,17 +141,13 @@ int snd_pcm_plugin_build_linear(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	struct linear_private_data *data;
 | 
						struct linear_private_data *data;
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
						assert(snd_pcm_format_linear(src_format->format) &&
 | 
				
			||||||
		return -EINVAL;
 | 
						       snd_pcm_format_linear(dst_format->format));
 | 
				
			||||||
	if (!(snd_pcm_format_linear(src_format->format) &&
 | 
					 | 
				
			||||||
	      snd_pcm_format_linear(dst_format->format)))
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "linear format conversion",
 | 
									   "linear format conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,8 +57,7 @@ static ssize_t mmap_src_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	int ready;
 | 
						int ready;
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || channels == NULL)
 | 
						assert(plugin && channels);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	data = (mmap_t *)plugin->extra_data;
 | 
						data = (mmap_t *)plugin->extra_data;
 | 
				
			||||||
	ctrl = data->control;
 | 
						ctrl = data->control;
 | 
				
			||||||
	stream = &data->slave->stream[plugin->stream];
 | 
						stream = &data->slave->stream[plugin->stream];
 | 
				
			||||||
| 
						 | 
					@ -86,8 +85,7 @@ static ssize_t mmap_src_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
		assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
 | 
							assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pos = ctrl->byte_data % setup->buffer_size;
 | 
						pos = ctrl->byte_data % setup->buffer_size;
 | 
				
			||||||
	if ((pos * 8) % stream->bits_per_frame != 0)
 | 
						assert((pos * 8) % stream->bits_per_frame == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	pos = (pos * 8) / stream->bits_per_frame;
 | 
						pos = (pos * 8) / stream->bits_per_frame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sv = plugin->src_channels;
 | 
						sv = plugin->src_channels;
 | 
				
			||||||
| 
						 | 
					@ -125,8 +123,7 @@ static ssize_t mmap_dst_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	size_t pos;
 | 
						size_t pos;
 | 
				
			||||||
	int ready;
 | 
						int ready;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || channels == NULL)
 | 
						assert(plugin && channels);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	data = (mmap_t *)plugin->extra_data;
 | 
						data = (mmap_t *)plugin->extra_data;
 | 
				
			||||||
	stream = &data->slave->stream[plugin->stream];
 | 
						stream = &data->slave->stream[plugin->stream];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -159,8 +156,7 @@ static ssize_t mmap_dst_channels(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
		assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
 | 
							assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pos = ctrl->byte_data % setup->buffer_size;
 | 
						pos = ctrl->byte_data % setup->buffer_size;
 | 
				
			||||||
	if ((pos * 8) % stream->bits_per_frame != 0)
 | 
						assert((pos * 8) % stream->bits_per_frame == 0);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	pos = (pos * 8) / stream->bits_per_frame;
 | 
						pos = (pos * 8) / stream->bits_per_frame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sv = stream->channels;
 | 
						sv = stream->channels;
 | 
				
			||||||
| 
						 | 
					@ -190,16 +186,11 @@ static ssize_t mmap_playback_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin && plugin->prev);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_channels);
 | 
				
			||||||
	data = (mmap_t *)plugin->extra_data;
 | 
						data = (mmap_t *)plugin->extra_data;
 | 
				
			||||||
	if (src_channels == NULL)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (plugin->prev == NULL)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	ctrl = data->control;
 | 
						ctrl = data->control;
 | 
				
			||||||
	if (ctrl == NULL)
 | 
						assert(ctrl);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &data->slave->stream[SND_PCM_STREAM_PLAYBACK];
 | 
						str = &data->slave->stream[SND_PCM_STREAM_PLAYBACK];
 | 
				
			||||||
	setup = &str->setup;
 | 
						setup = &str->setup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,15 +222,10 @@ static ssize_t mmap_capture_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	snd_pcm_mmap_control_t *ctrl;
 | 
						snd_pcm_mmap_control_t *ctrl;
 | 
				
			||||||
	snd_pcm_stream_t *str;
 | 
						snd_pcm_stream_t *str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin && plugin->next);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	data = (mmap_t *)plugin->extra_data;
 | 
						data = (mmap_t *)plugin->extra_data;
 | 
				
			||||||
	if (plugin->next == NULL)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ctrl = data->control;
 | 
						ctrl = data->control;
 | 
				
			||||||
	if (ctrl == NULL)
 | 
						assert(ctrl);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	str = &data->slave->stream[SND_PCM_STREAM_CAPTURE];
 | 
						str = &data->slave->stream[SND_PCM_STREAM_CAPTURE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* FIXME: not here the increment */
 | 
						/* FIXME: not here the increment */
 | 
				
			||||||
| 
						 | 
					@ -254,8 +240,7 @@ static int mmap_action(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct mmap_private_data *data;
 | 
						struct mmap_private_data *data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	data = (mmap_t *)plugin->extra_data;
 | 
						data = (mmap_t *)plugin->extra_data;
 | 
				
			||||||
	if (action == INIT) {
 | 
						if (action == INIT) {
 | 
				
			||||||
		snd_pcm_stream_setup_t *setup;
 | 
							snd_pcm_stream_setup_t *setup;
 | 
				
			||||||
| 
						 | 
					@ -305,11 +290,9 @@ int snd_pcm_plugin_build_mmap(snd_pcm_plugin_handle_t *pcm,
 | 
				
			||||||
	mmap_t *data;
 | 
						mmap_t *data;
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
	if (!pcm)
 | 
						assert(pcm);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	err = snd_pcm_plugin_build(pcm, stream,
 | 
						err = snd_pcm_plugin_build(pcm, stream,
 | 
				
			||||||
				   "I/O mmap",
 | 
									   "I/O mmap",
 | 
				
			||||||
				   format, format,
 | 
									   format, format,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -250,17 +250,14 @@ static ssize_t mulaw_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	mulaw_t *data;
 | 
						mulaw_t *data;
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
						for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
				
			||||||
		if (src_channels[channel].area.first % 8 != 0 || 
 | 
							assert(src_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		    src_channels[channel].area.step % 8 != 0)
 | 
							       src_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
							assert(dst_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		if (dst_channels[channel].area.first % 8 != 0 || 
 | 
							       dst_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
		    dst_channels[channel].area.step % 8 != 0)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	data = (mulaw_t *)plugin->extra_data;
 | 
						data = (mulaw_t *)plugin->extra_data;
 | 
				
			||||||
	data->func(plugin, src_channels, dst_channels, frames);
 | 
						data->func(plugin, src_channels, dst_channels, frames);
 | 
				
			||||||
| 
						 | 
					@ -279,14 +276,11 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_format_t *format;
 | 
						snd_pcm_format_t *format;
 | 
				
			||||||
	mulaw_f func;
 | 
						mulaw_f func;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (dst_format->format == SND_PCM_SFMT_MU_LAW) {
 | 
						if (dst_format->format == SND_PCM_SFMT_MU_LAW) {
 | 
				
			||||||
		format = src_format;
 | 
							format = src_format;
 | 
				
			||||||
| 
						 | 
					@ -296,10 +290,11 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
		format = dst_format;
 | 
							format = dst_format;
 | 
				
			||||||
		func = mulaw_decode;
 | 
							func = mulaw_decode;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else {
 | 
				
			||||||
		return -EINVAL;
 | 
							assert(0);
 | 
				
			||||||
	if (!snd_pcm_format_linear(format->format))
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						assert(snd_pcm_format_linear(format->format));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "Mu-Law<->linear conversion",
 | 
									   "Mu-Law<->linear conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -241,8 +241,9 @@ static ssize_t rate_src_frames(snd_pcm_plugin_t *plugin, size_t frames)
 | 
				
			||||||
	rate_t *data;
 | 
						rate_t *data;
 | 
				
			||||||
	ssize_t res;
 | 
						ssize_t res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || frames <= 0)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
						if (frames == 0)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
	data = (rate_t *)plugin->extra_data;
 | 
						data = (rate_t *)plugin->extra_data;
 | 
				
			||||||
	if (plugin->src_format.rate < plugin->dst_format.rate) {
 | 
						if (plugin->src_format.rate < plugin->dst_format.rate) {
 | 
				
			||||||
		res = (((frames * data->pitch) + (BITS/2)) >> SHIFT);
 | 
							res = (((frames * data->pitch) + (BITS/2)) >> SHIFT);
 | 
				
			||||||
| 
						 | 
					@ -272,8 +273,9 @@ static ssize_t rate_dst_frames(snd_pcm_plugin_t *plugin, size_t frames)
 | 
				
			||||||
	rate_t *data;
 | 
						rate_t *data;
 | 
				
			||||||
	ssize_t res;
 | 
						ssize_t res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || frames <= 0)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
						if (frames == 0)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
	data = (rate_t *)plugin->extra_data;
 | 
						data = (rate_t *)plugin->extra_data;
 | 
				
			||||||
	if (plugin->src_format.rate < plugin->dst_format.rate) {
 | 
						if (plugin->src_format.rate < plugin->dst_format.rate) {
 | 
				
			||||||
		res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch);
 | 
							res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch);
 | 
				
			||||||
| 
						 | 
					@ -307,17 +309,14 @@ static ssize_t rate_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	unsigned int channel;
 | 
						unsigned int channel;
 | 
				
			||||||
	rate_t *data;
 | 
						rate_t *data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
						for (channel = 0; channel < plugin->src_format.channels; channel++) {
 | 
				
			||||||
		if (src_channels[channel].area.first % 8 != 0 || 
 | 
							assert(src_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		    src_channels[channel].area.step % 8 != 0)
 | 
							       src_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
							assert(dst_channels[channel].area.first % 8 == 0 &&
 | 
				
			||||||
		if (dst_channels[channel].area.first % 8 != 0 || 
 | 
							       dst_channels[channel].area.step % 8 == 0);
 | 
				
			||||||
		    dst_channels[channel].area.step % 8 != 0)
 | 
					 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dst_frames = rate_dst_frames(plugin, frames);
 | 
						dst_frames = rate_dst_frames(plugin, frames);
 | 
				
			||||||
| 
						 | 
					@ -330,8 +329,7 @@ static int rate_action(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
		       snd_pcm_plugin_action_t action,
 | 
							       snd_pcm_plugin_action_t action,
 | 
				
			||||||
		       unsigned long udata UNUSED)
 | 
							       unsigned long udata UNUSED)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (plugin == NULL)
 | 
						assert(plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	switch (action) {
 | 
						switch (action) {
 | 
				
			||||||
	case INIT:
 | 
						case INIT:
 | 
				
			||||||
	case PREPARE:
 | 
						case PREPARE:
 | 
				
			||||||
| 
						 | 
					@ -355,20 +353,14 @@ int snd_pcm_plugin_build_rate(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	rate_t *data;
 | 
						rate_t *data;
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (r_plugin == NULL)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (src_format->channels != dst_format->channels)
 | 
						assert(src_format->channels == dst_format->channels);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(src_format->channels > 0);
 | 
				
			||||||
	if (src_format->channels < 1)
 | 
						assert(snd_pcm_format_linear(src_format->format) > 0);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(snd_pcm_format_linear(dst_format->format) > 0);
 | 
				
			||||||
	if (snd_pcm_format_linear(src_format->format) <= 0)
 | 
						assert(src_format->rate != dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (snd_pcm_format_linear(dst_format->format) <= 0)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	if (src_format->rate == dst_format->rate)
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "rate conversion",
 | 
									   "rate conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -438,8 +438,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
		int nsrcs = 0;
 | 
							int nsrcs = 0;
 | 
				
			||||||
		ttable_src_t srcs[plugin->src_format.channels];
 | 
							ttable_src_t srcs[plugin->src_format.channels];
 | 
				
			||||||
		for (src_channel = 0; src_channel < plugin->src_format.channels; ++src_channel) {
 | 
							for (src_channel = 0; src_channel < plugin->src_format.channels; ++src_channel) {
 | 
				
			||||||
			if (*sptr < 0 || *sptr > FULL)
 | 
								assert(*sptr >= 0 && *sptr <= FULL);
 | 
				
			||||||
				return -EINVAL;
 | 
					 | 
				
			||||||
			if (*sptr != 0) {
 | 
								if (*sptr != 0) {
 | 
				
			||||||
				srcs[nsrcs].channel = src_channel;
 | 
									srcs[nsrcs].channel = src_channel;
 | 
				
			||||||
#if ROUTE_PLUGIN_USE_FLOAT
 | 
					#if ROUTE_PLUGIN_USE_FLOAT
 | 
				
			||||||
| 
						 | 
					@ -457,8 +456,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
			sptr++;
 | 
								sptr++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
		if (t > FULL)
 | 
							assert(t <= FULL);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		dptr->att = att;
 | 
							dptr->att = att;
 | 
				
			||||||
		dptr->nsrcs = nsrcs;
 | 
							dptr->nsrcs = nsrcs;
 | 
				
			||||||
| 
						 | 
					@ -494,24 +492,21 @@ static ssize_t route_transfer(snd_pcm_plugin_t *plugin,
 | 
				
			||||||
	ttable_dst_t *ttp;
 | 
						ttable_dst_t *ttp;
 | 
				
			||||||
	snd_pcm_plugin_channel_t *dvp;
 | 
						snd_pcm_plugin_channel_t *dvp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
 | 
						assert(plugin && src_channels && dst_channels);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	if (frames == 0)
 | 
						if (frames == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	data = (route_t *)plugin->extra_data;
 | 
						data = (route_t *)plugin->extra_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	src_nchannels = plugin->src_format.channels;
 | 
						src_nchannels = plugin->src_format.channels;
 | 
				
			||||||
	for (src_channel = 0; src_channel < src_nchannels; ++src_channel) {
 | 
						for (src_channel = 0; src_channel < src_nchannels; ++src_channel) {
 | 
				
			||||||
		if (src_channels[src_channel].area.first % 8 != 0 || 
 | 
							assert(src_channels[src_channel].area.first % 8 == 0 &&
 | 
				
			||||||
		    src_channels[src_channel].area.step % 8 != 0)
 | 
							       src_channels[src_channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dst_nchannels = plugin->dst_format.channels;
 | 
						dst_nchannels = plugin->dst_format.channels;
 | 
				
			||||||
	for (dst_channel = 0; dst_channel < dst_nchannels; ++dst_channel) {
 | 
						for (dst_channel = 0; dst_channel < dst_nchannels; ++dst_channel) {
 | 
				
			||||||
		if (dst_channels[dst_channel].area.first % 8 != 0 || 
 | 
							assert(dst_channels[dst_channel].area.first % 8 == 0 &&
 | 
				
			||||||
		    dst_channels[dst_channel].area.step % 8 != 0)
 | 
							       dst_channels[dst_channel].area.step % 8 == 0);
 | 
				
			||||||
			return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ttp = data->ttable;
 | 
						ttp = data->ttable;
 | 
				
			||||||
| 
						 | 
					@ -550,14 +545,11 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
 | 
				
			||||||
	snd_pcm_plugin_t *plugin;
 | 
						snd_pcm_plugin_t *plugin;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!r_plugin)
 | 
						assert(r_plugin);
 | 
				
			||||||
		return -EFAULT;
 | 
					 | 
				
			||||||
	*r_plugin = NULL;
 | 
						*r_plugin = NULL;
 | 
				
			||||||
	if (src_format->rate != dst_format->rate)
 | 
						assert(src_format->rate == dst_format->rate);
 | 
				
			||||||
		return -EINVAL;
 | 
						assert(snd_pcm_format_linear(src_format->format) &&
 | 
				
			||||||
	if (!(snd_pcm_format_linear(src_format->format) &&
 | 
						       snd_pcm_format_linear(dst_format->format));
 | 
				
			||||||
	      snd_pcm_format_linear(dst_format->format)))
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = snd_pcm_plugin_build(handle, stream,
 | 
						err = snd_pcm_plugin_build(handle, stream,
 | 
				
			||||||
				   "attenuated route conversion",
 | 
									   "attenuated route conversion",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue