mirror of
https://review.haiku-os.org/haiku
synced 2025-02-22 21:48:35 +01:00
AC97 driver: replace some usage of strcpy() by strlcpy()
CID 8921, CID 8920, CID 8919, CID 8922. Also fixes some coding style issues.
This commit is contained in:
parent
c7199625ef
commit
fbbed9473f
@ -43,6 +43,7 @@
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
|
||||
static void
|
||||
auvia_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
auvia_dev *dev = (auvia_dev*)card;
|
||||
@ -50,28 +51,28 @@ auvia_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
uint16 value, mask;
|
||||
float gain;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case B_MIX_GAIN:
|
||||
value = auvia_codec_read(&dev->config, info->reg);
|
||||
//PRINT(("B_MIX_GAIN value : %u\n", value));
|
||||
if(info->type & B_MIX_STEREO) {
|
||||
if (info->type & B_MIX_STEREO) {
|
||||
mask = ((1 << (info->bits + 1)) - 1) << 8;
|
||||
gain = ((value & mask) >> 8) * info->granularity;
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
values[0] = info->max_gain - gain;
|
||||
else
|
||||
values[0] = gain - info->min_gain;
|
||||
|
||||
mask = ((1 << (info->bits + 1)) - 1);
|
||||
gain = (value & mask) * info->granularity;
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
values[1] = info->max_gain - gain;
|
||||
else
|
||||
values[1] = gain - info->min_gain;
|
||||
} else {
|
||||
mask = ((1 << (info->bits + 1)) - 1);
|
||||
gain = (value & mask) * info->granularity;
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
values[0] = info->max_gain - gain;
|
||||
else
|
||||
values[0] = gain - info->min_gain;
|
||||
@ -108,14 +109,14 @@ auvia_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
uint16 value, mask;
|
||||
float gain;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case B_MIX_GAIN:
|
||||
value = auvia_codec_read(&dev->config, info->reg);
|
||||
if(info->type & B_MIX_STEREO) {
|
||||
if (info->type & B_MIX_STEREO) {
|
||||
mask = ((1 << (info->bits + 1)) - 1) << 8;
|
||||
value &= ~mask;
|
||||
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
gain = info->max_gain - values[0];
|
||||
else
|
||||
gain = values[0] - info->min_gain;
|
||||
@ -123,7 +124,7 @@ auvia_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
|
||||
mask = ((1 << (info->bits + 1)) - 1);
|
||||
value &= ~mask;
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
gain = info->max_gain - values[1];
|
||||
else
|
||||
gain = values[1] - info->min_gain;
|
||||
@ -131,7 +132,7 @@ auvia_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
} else {
|
||||
mask = ((1 << (info->bits + 1)) - 1);
|
||||
value &= ~mask;
|
||||
if(info->polarity == 1)
|
||||
if (info->polarity == 1)
|
||||
gain = info->max_gain - values[0];
|
||||
else
|
||||
gain = values[0] - info->min_gain;
|
||||
@ -145,7 +146,7 @@ auvia_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
value = auvia_codec_read(&dev->config, info->reg);
|
||||
value &= ~mask;
|
||||
value |= ((values[0] == 1.0 ? 1 : 0 ) << 15 & mask);
|
||||
if(info->reg == AC97_SURR_VOLUME) {
|
||||
if (info->reg == AC97_SURR_VOLUME) {
|
||||
// there is a independent mute for each channel
|
||||
mask = ((1 << 1) - 1) << 7;
|
||||
value &= ~mask;
|
||||
@ -173,9 +174,11 @@ auvia_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
auvia_create_group_control(multi_dev *multi, int32 *index, int32 parent,
|
||||
int32 string, const char* name) {
|
||||
int32 string, const char* name)
|
||||
{
|
||||
int32 i = *index;
|
||||
(*index)++;
|
||||
multi->controls[i].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + i;
|
||||
@ -183,12 +186,14 @@ auvia_create_group_control(multi_dev *multi, int32 *index, int32 parent,
|
||||
multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP;
|
||||
multi->controls[i].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
multi->controls[i].mix_control.string = string;
|
||||
if(name)
|
||||
strcpy(multi->controls[i].mix_control.name, name);
|
||||
if (name)
|
||||
strlcpy(multi->controls[i].mix_control.name, name,
|
||||
sizeof(multi->controls[i].mix_control.name));
|
||||
|
||||
return multi->controls[i].mix_control.id;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_create_controls_list(multi_dev *multi)
|
||||
{
|
||||
@ -204,8 +209,8 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
|
||||
parent2 = auvia_create_group_control(multi, &index, parent, 0, info->name);
|
||||
|
||||
if(info->type & B_MIX_GAIN) {
|
||||
if(info->type & B_MIX_MUTE) {
|
||||
if (info->type & B_MIX_GAIN) {
|
||||
if (info->type & B_MIX_MUTE) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE;
|
||||
multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
@ -222,7 +227,8 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN;
|
||||
multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
multi->controls[index].mix_control.parent = parent2;
|
||||
strcpy(multi->controls[index].mix_control.name, info->name);
|
||||
strlcpy(multi->controls[index].mix_control.name, info->name,
|
||||
sizeof(multi->controls[index].mix_control.name));
|
||||
multi->controls[index].mix_control.u.gain.min_gain = info->min_gain;
|
||||
multi->controls[index].mix_control.u.gain.max_gain = info->max_gain;
|
||||
multi->controls[index].mix_control.u.gain.granularity = info->granularity;
|
||||
@ -233,12 +239,13 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
id = multi->controls[index].mix_control.id;
|
||||
index++;
|
||||
|
||||
if(info->type & B_MIX_STEREO) {
|
||||
if (info->type & B_MIX_STEREO) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN;
|
||||
multi->controls[index].mix_control.master = id;
|
||||
multi->controls[index].mix_control.parent = parent2;
|
||||
strcpy(multi->controls[index].mix_control.name, info->name);
|
||||
strlcpy(multi->controls[index].mix_control.name, info->name,
|
||||
sizeof(multi->controls[index].mix_control.name));
|
||||
multi->controls[index].mix_control.u.gain.min_gain = info->min_gain;
|
||||
multi->controls[index].mix_control.u.gain.max_gain = info->max_gain;
|
||||
multi->controls[index].mix_control.u.gain.granularity = info->granularity;
|
||||
@ -249,7 +256,7 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
index++;
|
||||
}
|
||||
|
||||
if(info->type & B_MIX_RECORDMUX) {
|
||||
if (info->type & B_MIX_RECORDMUX) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX;
|
||||
multi->controls[index].mix_control.parent = parent2;
|
||||
@ -309,14 +316,14 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
count = source_info_size;
|
||||
count--;
|
||||
|
||||
for(i = 1; i < count ; i++) {
|
||||
for (i = 1; i < count ; i++) {
|
||||
info = &source_info[i];
|
||||
PRINT(("name : %s\n", info->name));
|
||||
|
||||
parent2 = auvia_create_group_control(multi, &index, parent, 0, info->name);
|
||||
|
||||
if(info->type & B_MIX_GAIN) {
|
||||
if(info->type & B_MIX_MUTE) {
|
||||
if (info->type & B_MIX_GAIN) {
|
||||
if (info->type & B_MIX_MUTE) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE;
|
||||
multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
@ -333,7 +340,8 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN;
|
||||
multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
multi->controls[index].mix_control.parent = parent2;
|
||||
strcpy(multi->controls[index].mix_control.name, info->name);
|
||||
strlcpy(multi->controls[index].mix_control.name, info->name,
|
||||
sizeof(multi->controls[index].mix_control.name));
|
||||
multi->controls[index].mix_control.u.gain.min_gain = info->min_gain;
|
||||
multi->controls[index].mix_control.u.gain.max_gain = info->max_gain;
|
||||
multi->controls[index].mix_control.u.gain.granularity = info->granularity;
|
||||
@ -344,12 +352,13 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
id = multi->controls[index].mix_control.id;
|
||||
index++;
|
||||
|
||||
if(info->type & B_MIX_STEREO) {
|
||||
if (info->type & B_MIX_STEREO) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN;
|
||||
multi->controls[index].mix_control.master = id;
|
||||
multi->controls[index].mix_control.parent = parent2;
|
||||
strcpy(multi->controls[index].mix_control.name, info->name);
|
||||
strlcpy(multi->controls[index].mix_control.name, info->name,
|
||||
sizeof(multi->controls[index].mix_control.name));
|
||||
multi->controls[index].mix_control.u.gain.min_gain = info->min_gain;
|
||||
multi->controls[index].mix_control.u.gain.max_gain = info->max_gain;
|
||||
multi->controls[index].mix_control.u.gain.granularity = info->granularity;
|
||||
@ -367,7 +376,7 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
/* AC97 20db Boost Mic */
|
||||
info = &source_info[6];
|
||||
|
||||
if(info->type & B_MIX_GAIN && info->type & B_MIX_MICBOOST) {
|
||||
if (info->type & B_MIX_GAIN && info->type & B_MIX_MICBOOST) {
|
||||
multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index;
|
||||
multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE;
|
||||
multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID;
|
||||
@ -385,37 +394,38 @@ auvia_create_controls_list(multi_dev *multi)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_get_mix(auvia_dev *card, multi_mix_value_info * mmvi)
|
||||
{
|
||||
int32 i, id;
|
||||
multi_mixer_control *control = NULL;
|
||||
for(i = 0; i < mmvi->item_count; i++) {
|
||||
for (i = 0; i < mmvi->item_count; i++) {
|
||||
id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID;
|
||||
if(id < 0 || id >= card->multi.control_count) {
|
||||
if (id < 0 || id >= card->multi.control_count) {
|
||||
PRINT(("auvia_get_mix : invalid control id requested : %li\n", id));
|
||||
continue;
|
||||
}
|
||||
control = &card->multi.controls[id];
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
||||
if(control->get) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
||||
if (control->get) {
|
||||
float values[2];
|
||||
control->get(card, control->cookie, control->type, values);
|
||||
if(control->mix_control.master == EMU_MULTI_CONTROL_MASTERID)
|
||||
if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID)
|
||||
mmvi->values[i].u.gain = values[0];
|
||||
else
|
||||
mmvi->values[i].u.gain = values[1];
|
||||
}
|
||||
}
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) {
|
||||
float values[1];
|
||||
control->get(card, control->cookie, control->type, values);
|
||||
mmvi->values[i].u.enable = (values[0] == 1.0);
|
||||
}
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_MUX && control->get) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_MUX && control->get) {
|
||||
float values[1];
|
||||
control->get(card, control->cookie, control->type, values);
|
||||
mmvi->values[i].u.mux = (int32)values[0];
|
||||
@ -424,60 +434,61 @@ auvia_get_mix(auvia_dev *card, multi_mix_value_info * mmvi)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_set_mix(auvia_dev *card, multi_mix_value_info * mmvi)
|
||||
{
|
||||
int32 i, id;
|
||||
multi_mixer_control *control = NULL;
|
||||
for(i = 0; i < mmvi->item_count; i++) {
|
||||
for (i = 0; i < mmvi->item_count; i++) {
|
||||
id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID;
|
||||
if(id < 0 || id >= card->multi.control_count) {
|
||||
if (id < 0 || id >= card->multi.control_count) {
|
||||
PRINT(("auvia_set_mix : invalid control id requested : %li\n", id));
|
||||
continue;
|
||||
}
|
||||
control = &card->multi.controls[id];
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_GAIN) {
|
||||
multi_mixer_control *control2 = NULL;
|
||||
if(i+1<mmvi->item_count) {
|
||||
if (i + 1 < mmvi->item_count) {
|
||||
id = mmvi->values[i + 1].id - EMU_MULTI_CONTROL_FIRSTID;
|
||||
if(id < 0 || id >= card->multi.control_count) {
|
||||
if (id < 0 || id >= card->multi.control_count) {
|
||||
PRINT(("auvia_set_mix : invalid control id requested : %li\n", id));
|
||||
} else {
|
||||
control2 = &card->multi.controls[id];
|
||||
if(control2->mix_control.master != control->mix_control.id)
|
||||
if (control2->mix_control.master != control->mix_control.id)
|
||||
control2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(control->set) {
|
||||
if (control->set) {
|
||||
float values[2];
|
||||
values[0] = 0.0;
|
||||
values[1] = 0.0;
|
||||
|
||||
if(control->mix_control.master == EMU_MULTI_CONTROL_MASTERID)
|
||||
if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID)
|
||||
values[0] = mmvi->values[i].u.gain;
|
||||
else
|
||||
values[1] = mmvi->values[i].u.gain;
|
||||
|
||||
if(control2 && control2->mix_control.master != EMU_MULTI_CONTROL_MASTERID)
|
||||
values[1] = mmvi->values[i+1].u.gain;
|
||||
if (control2 && control2->mix_control.master != EMU_MULTI_CONTROL_MASTERID)
|
||||
values[1] = mmvi->values[i + 1].u.gain;
|
||||
|
||||
control->set(card, control->cookie, control->type, values);
|
||||
}
|
||||
|
||||
if(control2)
|
||||
if (control2)
|
||||
i++;
|
||||
}
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) {
|
||||
float values[1];
|
||||
|
||||
values[0] = mmvi->values[i].u.enable ? 1.0 : 0.0;
|
||||
control->set(card, control->cookie, control->type, values);
|
||||
}
|
||||
|
||||
if(control->mix_control.flags & B_MULTI_MIX_MUX && control->set) {
|
||||
if (control->mix_control.flags & B_MULTI_MIX_MUX && control->set) {
|
||||
float values[1];
|
||||
|
||||
values[0] = (float)mmvi->values[i].u.mux;
|
||||
@ -487,6 +498,7 @@ auvia_set_mix(auvia_dev *card, multi_mix_value_info * mmvi)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_list_mix_controls(auvia_dev *card, multi_mix_control_info * mmci)
|
||||
{
|
||||
@ -494,12 +506,12 @@ auvia_list_mix_controls(auvia_dev *card, multi_mix_control_info * mmci)
|
||||
int32 i;
|
||||
|
||||
mmc = mmci->controls;
|
||||
if(mmci->control_count < 24)
|
||||
if (mmci->control_count < 24)
|
||||
return B_ERROR;
|
||||
|
||||
if(auvia_create_controls_list(&card->multi) < B_OK)
|
||||
if (auvia_create_controls_list(&card->multi) < B_OK)
|
||||
return B_ERROR;
|
||||
for(i = 0; i < card->multi.control_count; i++) {
|
||||
for (i = 0; i < card->multi.control_count; i++) {
|
||||
mmc[i] = card->multi.controls[i].mix_control;
|
||||
}
|
||||
|
||||
@ -507,12 +519,14 @@ auvia_list_mix_controls(auvia_dev *card, multi_mix_control_info * mmci)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_list_mix_connections(auvia_dev *card, multi_mix_connection_info * data)
|
||||
{
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_list_mix_channels(auvia_dev *card, multi_mix_channel_info *data)
|
||||
{
|
||||
@ -570,18 +584,18 @@ auvia_create_channels_list(multi_dev *multi)
|
||||
chans = multi->chans;
|
||||
index = 0;
|
||||
|
||||
for(mode=AUVIA_USE_PLAY; mode!=-1;
|
||||
for (mode = AUVIA_USE_PLAY; mode != -1;
|
||||
mode = (mode == AUVIA_USE_PLAY) ? AUVIA_USE_RECORD : -1) {
|
||||
LIST_FOREACH(stream, &((auvia_dev*)multi->card)->streams, next) {
|
||||
if ((stream->use & mode) == 0)
|
||||
continue;
|
||||
|
||||
if(stream->channels == 2)
|
||||
if (stream->channels == 2)
|
||||
designations = B_CHANNEL_STEREO_BUS;
|
||||
else
|
||||
designations = B_CHANNEL_SURROUND_BUS;
|
||||
|
||||
for(i = 0; i < stream->channels; i++) {
|
||||
for (i = 0; i < stream->channels; i++) {
|
||||
chans[index].channel_id = index;
|
||||
chans[index].kind = (mode == AUVIA_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL;
|
||||
chans[index].designations = designations | chan_designations[i];
|
||||
@ -590,7 +604,7 @@ auvia_create_channels_list(multi_dev *multi)
|
||||
}
|
||||
}
|
||||
|
||||
if(mode==AUVIA_USE_PLAY) {
|
||||
if (mode == AUVIA_USE_PLAY) {
|
||||
multi->output_channel_count = index;
|
||||
} else {
|
||||
multi->input_channel_count = index - multi->output_channel_count;
|
||||
@ -639,10 +653,10 @@ auvia_get_description(auvia_dev *card, multi_description *data)
|
||||
data->interface_version = B_CURRENT_INTERFACE_VERSION;
|
||||
data->interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
||||
|
||||
if(IS_686(&card->config))
|
||||
if (IS_686(&card->config))
|
||||
strncpy(data->friendly_name, FRIENDLY_NAME_686, 32);
|
||||
else if(IS_8233(&card->config)) {
|
||||
switch(card->info.revision) {
|
||||
else if (IS_8233(&card->config)) {
|
||||
switch (card->info.revision) {
|
||||
case VIATECH_8233_AC97_REV_8233_10:
|
||||
strncpy(data->friendly_name, FRIENDLY_NAME_8233, 32);
|
||||
break;
|
||||
@ -709,11 +723,12 @@ auvia_get_description(auvia_dev *card, multi_description *data)
|
||||
data->interface_flags = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD;
|
||||
data->start_latency = 3000;
|
||||
|
||||
strcpy(data->control_panel,"");
|
||||
strcpy(data->control_panel, "");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_get_enabled_channels(auvia_dev *card, multi_channel_enable *data)
|
||||
{
|
||||
@ -731,6 +746,7 @@ auvia_get_enabled_channels(auvia_dev *card, multi_channel_enable *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_set_enabled_channels(auvia_dev *card, multi_channel_enable *data)
|
||||
{
|
||||
@ -741,6 +757,7 @@ auvia_set_enabled_channels(auvia_dev *card, multi_channel_enable *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_get_global_format(auvia_dev *card, multi_format_info *data)
|
||||
{
|
||||
@ -762,6 +779,7 @@ auvia_get_global_format(auvia_dev *card, multi_format_info *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_get_buffers(auvia_dev *card, multi_buffer_list *data)
|
||||
{
|
||||
@ -794,8 +812,8 @@ auvia_get_buffers(auvia_dev *card, multi_buffer_list *data)
|
||||
data->return_playback_channels = pchannels; /* playback_buffers[][c] */
|
||||
data->return_playback_buffer_size = BUFFER_FRAMES; /* frames */
|
||||
|
||||
for(i = 0; i < BUFFER_COUNT; i++)
|
||||
for(j=0; j<pchannels; j++)
|
||||
for (i = 0; i < BUFFER_COUNT; i++)
|
||||
for (j = 0; j < pchannels; j++)
|
||||
auvia_stream_get_nth_buffer(card->pstream, j, i,
|
||||
&data->playback_buffers[i][j].base,
|
||||
&data->playback_buffers[i][j].stride);
|
||||
@ -804,8 +822,8 @@ auvia_get_buffers(auvia_dev *card, multi_buffer_list *data)
|
||||
data->return_record_channels = rchannels;
|
||||
data->return_record_buffer_size = BUFFER_FRAMES; /* frames */
|
||||
|
||||
for(i = 0; i < BUFFER_COUNT; i++)
|
||||
for(j=0; j<rchannels; j++)
|
||||
for (i = 0; i < BUFFER_COUNT; i++)
|
||||
for (j = 0; j<rchannels; j++)
|
||||
auvia_stream_get_nth_buffer(card->rstream, j, i,
|
||||
&data->record_buffers[i][j].base,
|
||||
&data->record_buffers[i][j].stride);
|
||||
@ -826,7 +844,7 @@ auvia_play_inth(void* inthparams)
|
||||
stream->real_time = system_time();
|
||||
stream->frames_count += BUFFER_FRAMES;
|
||||
stream->buffer_cycle = (stream->trigblk
|
||||
+ stream->blkmod -1) % stream->blkmod;
|
||||
+ stream->blkmod - 1) % stream->blkmod;
|
||||
stream->update_needed = true;
|
||||
release_spinlock(&slock);
|
||||
|
||||
@ -835,6 +853,7 @@ auvia_play_inth(void* inthparams)
|
||||
release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auvia_record_inth(void* inthparams)
|
||||
{
|
||||
@ -847,7 +866,7 @@ auvia_record_inth(void* inthparams)
|
||||
stream->real_time = system_time();
|
||||
stream->frames_count += BUFFER_FRAMES;
|
||||
stream->buffer_cycle = (stream->trigblk
|
||||
+ stream->blkmod -1) % stream->blkmod;
|
||||
+ stream->blkmod - 1) % stream->blkmod;
|
||||
stream->update_needed = true;
|
||||
release_spinlock(&slock);
|
||||
|
||||
@ -856,6 +875,7 @@ auvia_record_inth(void* inthparams)
|
||||
release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_buffer_exchange(auvia_dev *card, multi_buffer_info *data)
|
||||
{
|
||||
@ -878,7 +898,7 @@ auvia_buffer_exchange(auvia_dev *card, multi_buffer_info *data)
|
||||
if (!(card->rstream->state & AUVIA_STATE_STARTED))
|
||||
auvia_stream_start(card->rstream, auvia_record_inth, card->rstream);
|
||||
|
||||
if(acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000)
|
||||
if (acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000)
|
||||
== B_TIMED_OUT) {
|
||||
LOG(("buffer_exchange timeout ff\n"));
|
||||
}
|
||||
@ -889,7 +909,7 @@ auvia_buffer_exchange(auvia_dev *card, multi_buffer_info *data)
|
||||
if ((pstream->use & AUVIA_USE_PLAY) == 0 ||
|
||||
(pstream->state & AUVIA_STATE_STARTED) == 0)
|
||||
continue;
|
||||
if(pstream->update_needed)
|
||||
if (pstream->update_needed)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -897,13 +917,13 @@ auvia_buffer_exchange(auvia_dev *card, multi_buffer_info *data)
|
||||
if ((rstream->use & AUVIA_USE_RECORD) == 0 ||
|
||||
(rstream->state & AUVIA_STATE_STARTED) == 0)
|
||||
continue;
|
||||
if(rstream->update_needed)
|
||||
if (rstream->update_needed)
|
||||
break;
|
||||
}
|
||||
|
||||
if(!pstream)
|
||||
if (!pstream)
|
||||
pstream = card->pstream;
|
||||
if(!rstream)
|
||||
if (!rstream)
|
||||
rstream = card->rstream;
|
||||
|
||||
/* do playback */
|
||||
@ -932,6 +952,7 @@ auvia_buffer_exchange(auvia_dev *card, multi_buffer_info *data)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_buffer_force_stop(auvia_dev *card)
|
||||
{
|
||||
@ -939,6 +960,7 @@ auvia_buffer_force_stop(auvia_dev *card)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_multi_control(void *cookie, uint32 op, void *data, size_t length)
|
||||
{
|
||||
@ -1032,6 +1054,7 @@ device_hooks multi_hooks = {
|
||||
NULL /* scatter-gather write to the device */
|
||||
};
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_open(const char *name, uint32 flags, void** cookie)
|
||||
{
|
||||
@ -1046,7 +1069,7 @@ auvia_open(const char *name, uint32 flags, void** cookie)
|
||||
}
|
||||
}
|
||||
|
||||
if(card == NULL) {
|
||||
if (card == NULL) {
|
||||
LOG(("open() card not found %s\n", name));
|
||||
for (ix=0; ix<num_cards; ix++) {
|
||||
LOG(("open() card available %s\n", cards[ix].name));
|
||||
@ -1056,9 +1079,9 @@ auvia_open(const char *name, uint32 flags, void** cookie)
|
||||
|
||||
LOG(("open() got card\n"));
|
||||
|
||||
if(card->pstream !=NULL)
|
||||
if (card->pstream !=NULL)
|
||||
return B_ERROR;
|
||||
if(card->rstream !=NULL)
|
||||
if (card->rstream !=NULL)
|
||||
return B_ERROR;
|
||||
|
||||
*cookie = card;
|
||||
@ -1087,6 +1110,7 @@ auvia_open(const char *name, uint32 flags, void** cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_close(void* cookie)
|
||||
{
|
||||
@ -1096,6 +1120,7 @@ auvia_close(void* cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_free(void* cookie)
|
||||
{
|
||||
@ -1110,7 +1135,7 @@ auvia_free(void* cookie)
|
||||
auvia_stream_halt(stream);
|
||||
}
|
||||
|
||||
while(!LIST_EMPTY(&card->streams)) {
|
||||
while (!LIST_EMPTY(&card->streams)) {
|
||||
auvia_stream_delete(LIST_FIRST(&card->streams));
|
||||
}
|
||||
|
||||
@ -1120,12 +1145,14 @@ auvia_free(void* cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_control(void* cookie, uint32 op, void* arg, size_t len)
|
||||
{
|
||||
return auvia_multi_control(cookie, op, arg, len);
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||
{
|
||||
@ -1133,6 +1160,7 @@ auvia_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||
return B_IO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
auvia_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user