Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15928
b: refs/heads/master
c: 47eaebf
h: refs/heads/master
v: v3
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Jan 3, 2006
1 parent 2035861 commit f5a4898
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 114 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 230b5c1a612ae903c560b55a15df287b0ff437ea
refs/heads/master: 47eaebfd31610d2a55fbaccd1e7c37690d42ce30
4 changes: 2 additions & 2 deletions trunk/sound/core/oss/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channels ATTRIBUTE_UNUSED,
snd_pcm_plugin_channel_t *dst_channels,
snd_pcm_uframes_t frames)
{
snd_assert(plugin != NULL, return -ENXIO);
Expand All @@ -59,7 +59,7 @@ static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin,
}

static snd_pcm_sframes_t io_capture_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED,
const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channels,
snd_pcm_uframes_t frames)
{
Expand Down
54 changes: 27 additions & 27 deletions trunk/sound/core/oss/pcm_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
#define snd_pcm_plug_last(plug) ((plug)->runtime->oss.plugin_last)

static int snd_pcm_plugin_src_channels_mask(snd_pcm_plugin_t *plugin,
bitset_t *dst_vmask,
bitset_t **src_vmask)
unsigned long *dst_vmask,
unsigned long **src_vmask)
{
bitset_t *vmask = plugin->src_vmask;
bitset_copy(vmask, dst_vmask, plugin->src_format.channels);
unsigned long *vmask = plugin->src_vmask;
bitmap_copy(vmask, dst_vmask, plugin->src_format.channels);
*src_vmask = vmask;
return 0;
}

static int snd_pcm_plugin_dst_channels_mask(snd_pcm_plugin_t *plugin,
bitset_t *src_vmask,
bitset_t **dst_vmask)
unsigned long *src_vmask,
unsigned long **dst_vmask)
{
bitset_t *vmask = plugin->dst_vmask;
bitset_copy(vmask, src_vmask, plugin->dst_format.channels);
unsigned long *vmask = plugin->dst_vmask;
bitmap_copy(vmask, src_vmask, plugin->dst_format.channels);
*dst_vmask = vmask;
return 0;
}
Expand Down Expand Up @@ -193,12 +193,12 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug,
snd_pcm_plugin_free(plugin);
return -ENOMEM;
}
plugin->src_vmask = bitset_alloc(src_format->channels);
plugin->src_vmask = bitmap_alloc(src_format->channels);
if (plugin->src_vmask == NULL) {
snd_pcm_plugin_free(plugin);
return -ENOMEM;
}
plugin->dst_vmask = bitset_alloc(dst_format->channels);
plugin->dst_vmask = bitmap_alloc(dst_format->channels);
if (plugin->dst_vmask == NULL) {
snd_pcm_plugin_free(plugin);
return -ENOMEM;
Expand Down Expand Up @@ -651,18 +651,18 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *plug,
}

static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
bitset_t *client_vmask)
unsigned long *client_vmask)
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
if (plugin == NULL) {
return 0;
} else {
int schannels = plugin->dst_format.channels;
bitset_t bs[bitset_size(schannels)];
bitset_t *srcmask;
bitset_t *dstmask = bs;
DECLARE_BITMAP(bs, schannels);
unsigned long *srcmask;
unsigned long *dstmask = bs;
int err;
bitset_one(dstmask, schannels);
bitmap_fill(dstmask, schannels);

while (1) {
err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
Expand All @@ -673,7 +673,7 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
break;
plugin = plugin->prev;
}
bitset_and(client_vmask, dstmask, plugin->src_format.channels);
bitmap_and(client_vmask, client_vmask, dstmask, plugin->src_format.channels);
return 0;
}
}
Expand All @@ -683,21 +683,21 @@ static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug,
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug);
unsigned int nchannels = plugin->src_format.channels;
bitset_t bs[bitset_size(nchannels)];
bitset_t *srcmask = bs;
DECLARE_BITMAP(bs, nchannels);
unsigned long *srcmask = bs;
int err;
unsigned int channel;
for (channel = 0; channel < nchannels; channel++) {
if (src_channels[channel].enabled)
bitset_set(srcmask, channel);
set_bit(channel, srcmask);
else
bitset_reset(srcmask, channel);
clear_bit(channel, srcmask);
}
err = snd_pcm_plug_playback_channels_mask(plug, srcmask);
if (err < 0)
return err;
for (channel = 0; channel < nchannels; channel++) {
if (!bitset_get(srcmask, channel))
if (!test_bit(channel, srcmask))
src_channels[channel].enabled = 0;
}
return 0;
Expand All @@ -709,16 +709,16 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug,
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
unsigned int nchannels = plugin->dst_format.channels;
bitset_t bs[bitset_size(nchannels)];
bitset_t *dstmask = bs;
bitset_t *srcmask;
DECLARE_BITMAP(bs, nchannels);
unsigned long *dstmask = bs;
unsigned long *srcmask;
int err;
unsigned int channel;
for (channel = 0; channel < nchannels; channel++) {
if (client_channels[channel].enabled)
bitset_set(dstmask, channel);
set_bit(channel, dstmask);
else
bitset_reset(dstmask, channel);
clear_bit(channel, dstmask);
}
while (plugin) {
err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
Expand All @@ -730,7 +730,7 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug,
plugin = snd_pcm_plug_first(plug);
nchannels = plugin->src_format.channels;
for (channel = 0; channel < nchannels; channel++) {
if (!bitset_get(dstmask, channel))
if (!test_bit(channel, dstmask))
src_channels[channel].enabled = 0;
}
return 0;
Expand Down
78 changes: 9 additions & 69 deletions trunk/sound/core/oss/pcm_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,11 @@
*
*/

#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif

typedef unsigned int bitset_t;

static inline size_t bitset_size(int nbits)
{
return (nbits + sizeof(bitset_t) * 8 - 1) / (sizeof(bitset_t) * 8);
}

static inline bitset_t *bitset_alloc(int nbits)
{
return kcalloc(bitset_size(nbits), sizeof(bitset_t), GFP_KERNEL);
}

static inline void bitset_set(bitset_t *bitmap, unsigned int pos)
{
size_t bits = sizeof(*bitmap) * 8;
bitmap[pos / bits] |= 1 << (pos % bits);
}

static inline void bitset_reset(bitset_t *bitmap, unsigned int pos)
{
size_t bits = sizeof(*bitmap) * 8;
bitmap[pos / bits] &= ~(1 << (pos % bits));
}

static inline int bitset_get(bitset_t *bitmap, unsigned int pos)
{
size_t bits = sizeof(*bitmap) * 8;
return !!(bitmap[pos / bits] & (1 << (pos % bits)));
}

static inline void bitset_copy(bitset_t *dst, bitset_t *src, unsigned int nbits)
{
memcpy(dst, src, bitset_size(nbits) * sizeof(bitset_t));
}

static inline void bitset_and(bitset_t *dst, bitset_t *bs, unsigned int nbits)
{
bitset_t *end = dst + bitset_size(nbits);
while (dst < end)
*dst++ &= *bs++;
}

static inline void bitset_or(bitset_t *dst, bitset_t *bs, unsigned int nbits)
{
bitset_t *end = dst + bitset_size(nbits);
while (dst < end)
*dst++ |= *bs++;
}

static inline void bitset_zero(bitset_t *dst, unsigned int nbits)
{
bitset_t *end = dst + bitset_size(nbits);
while (dst < end)
*dst++ = 0;
}
#include <linux/bitmap.h>

static inline void bitset_one(bitset_t *dst, unsigned int nbits)
static inline unsigned long *bitmap_alloc(unsigned int nbits)
{
bitset_t *end = dst + bitset_size(nbits);
while (dst < end)
*dst++ = ~(bitset_t)0;
return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL);
}

#define snd_pcm_plug_t snd_pcm_substream_t
Expand Down Expand Up @@ -131,11 +71,11 @@ struct _snd_pcm_plugin {
snd_pcm_uframes_t frames,
snd_pcm_plugin_channel_t **channels);
int (*src_channels_mask)(snd_pcm_plugin_t *plugin,
bitset_t *dst_vmask,
bitset_t **src_vmask);
unsigned long *dst_vmask,
unsigned long **src_vmask);
int (*dst_channels_mask)(snd_pcm_plugin_t *plugin,
bitset_t *src_vmask,
bitset_t **dst_vmask);
unsigned long *src_vmask,
unsigned long **dst_vmask);
snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channels,
Expand All @@ -151,8 +91,8 @@ struct _snd_pcm_plugin {
char *buf;
snd_pcm_uframes_t buf_frames;
snd_pcm_plugin_channel_t *buf_channels;
bitset_t *src_vmask;
bitset_t *dst_vmask;
unsigned long *src_vmask;
unsigned long *dst_vmask;
char extra_data[0];
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/sound/core/oss/rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static snd_pcm_sframes_t rate_transfer(snd_pcm_plugin_t *plugin,

static int rate_action(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_action_t action,
unsigned long udata ATTRIBUTE_UNUSED)
unsigned long udata)
{
snd_assert(plugin != NULL, return -ENXIO);
switch (action) {
Expand Down
28 changes: 14 additions & 14 deletions trunk/sound/core/oss/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ typedef union {


static void route_to_channel_from_zero(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED,
const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channel,
ttable_dst_t* ttable ATTRIBUTE_UNUSED, snd_pcm_uframes_t frames)
ttable_dst_t* ttable, snd_pcm_uframes_t frames)
{
if (dst_channel->wanted)
snd_pcm_area_silence(&dst_channel->area, 0, frames, plugin->dst_format.format);
Expand Down Expand Up @@ -298,46 +298,46 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
}

static int route_src_channels_mask(snd_pcm_plugin_t *plugin,
bitset_t *dst_vmask,
bitset_t **src_vmask)
unsigned long *dst_vmask,
unsigned long **src_vmask)
{
route_t *data = (route_t *)plugin->extra_data;
int schannels = plugin->src_format.channels;
int dchannels = plugin->dst_format.channels;
bitset_t *vmask = plugin->src_vmask;
unsigned long *vmask = plugin->src_vmask;
int channel;
ttable_dst_t *dp = data->ttable;
bitset_zero(vmask, schannels);
bitmap_zero(vmask, schannels);
for (channel = 0; channel < dchannels; channel++, dp++) {
unsigned int src;
ttable_src_t *sp;
if (!bitset_get(dst_vmask, channel))
if (!test_bit(channel, dst_vmask))
continue;
sp = dp->srcs;
for (src = 0; src < dp->nsrcs; src++, sp++)
bitset_set(vmask, sp->channel);
set_bit(sp->channel, vmask);
}
*src_vmask = vmask;
return 0;
}

static int route_dst_channels_mask(snd_pcm_plugin_t *plugin,
bitset_t *src_vmask,
bitset_t **dst_vmask)
unsigned long *src_vmask,
unsigned long **dst_vmask)
{
route_t *data = (route_t *)plugin->extra_data;
int dchannels = plugin->dst_format.channels;
bitset_t *vmask = plugin->dst_vmask;
unsigned long *vmask = plugin->dst_vmask;
int channel;
ttable_dst_t *dp = data->ttable;
bitset_zero(vmask, dchannels);
bitmap_zero(vmask, dchannels);
for (channel = 0; channel < dchannels; channel++, dp++) {
unsigned int src;
ttable_src_t *sp;
sp = dp->srcs;
for (src = 0; src < dp->nsrcs; src++, sp++) {
if (bitset_get(src_vmask, sp->channel)) {
bitset_set(vmask, channel);
if (test_bit(sp->channel, src_vmask)) {
set_bit(channel, vmask);
break;
}
}
Expand Down

0 comments on commit f5a4898

Please sign in to comment.