I’ve got very basic problems for this function, about snd_ctl_elem_set_bytes.
I’m trying to write 512 bytes data using snd_ctl_elem_set_bytes functions.
But it’s failed.
/ \brief Set values to given data as an element of bytes type. \param obj Data of an element. \param data Pointer for byte array. \param size The number of bytes included in the memory block. /
void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t obj, void *data, size_t size)
{
assert(obj);
assert(size < ARRAY_SIZE(obj->value.bytes.data));
memcpy(obj->value.bytes.data, data, size);
}
I know ARRAY_SIZE(obj->value.bytes.data) is 512.
I know why the assert happened.
But I want to know why the code blocked to use full size of data.
And I want to write the 512 bytes data.
So I think it should be assert(size < (ARRAY_SIZE(obj->value.bytes.data) + 1));.
How do you think?
I trying to check why it done like that, But there is no more description for this, please Help me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I’ve got very basic problems for this function, about snd_ctl_elem_set_bytes.
I’m trying to write 512 bytes data using snd_ctl_elem_set_bytes functions.
But it’s failed.
/
\brief Set values to given data as an element of bytes type.
\param obj Data of an element.
\param data Pointer for byte array.
\param size The number of bytes included in the memory block.
/
void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t obj, void *data, size_t size)
{
assert(obj);
assert(size < ARRAY_SIZE(obj->value.bytes.data));
memcpy(obj->value.bytes.data, data, size);
}
I know ARRAY_SIZE(obj->value.bytes.data) is 512.
I know why the assert happened.
But I want to know why the code blocked to use full size of data.
And I want to write the 512 bytes data.
So I think it should be assert(size < (ARRAY_SIZE(obj->value.bytes.data) + 1));.
How do you think?
I trying to check why it done like that, But there is no more description for this, please Help me.
Is there any progress?
Or do I need to ask about this to another mail address?
I think no-one care these pages.
Fixed in http://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=fdc4c17e1c9f4f7591c7fb4f2bc2e0c399d2156e .
Oh!! Thanks!!