Skip to content

Commit

Permalink
Get invalid range
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Oct 6, 2024
1 parent 08404c7 commit 8284af3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,31 +267,34 @@ static void virtio_snd_read_pcm_info_handler(
struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
/* TODO: should read the config */
uint32_t cnt = query->count;
virtio_snd_pcm_info_t *info =
(virtio_snd_pcm_info_t *) ((uintptr_t) vq_desc[2].addr);
for (uint32_t i = 0; i < query->count; i++) {
info[0].features = 0;
info[0].formats = (1 << VIRTIO_SND_PCM_FMT_S16);
info[0].rates = (1 << VIRTIO_SND_PCM_RATE_44100);
info[0].direction = VIRTIO_SND_D_OUTPUT;
info[0].channels_min = 1;
info[0].channels_max = 1;
(virtio_snd_pcm_info_t *) malloc(sizeof(virtio_snd_pcm_info_t) * cnt);
for (uint32_t i = 0; i < cnt; i++) {
info[i].features = 0;
info[i].formats = (1 << VIRTIO_SND_PCM_FMT_S16);
info[i].rates = (1 << VIRTIO_SND_PCM_RATE_44100);
info[i].direction = VIRTIO_SND_D_OUTPUT;
info[i].channels_min = 1;
info[i].channels_max = 1;
memset(&info[i].padding, 0, sizeof(info[i].padding));
}
vq_desc[2].addr = (uintptr_t) info;
}

static void virtio_snd_read_chmap_info_handler(
struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
virtio_snd_chmap_info_t *info =
(virtio_snd_chmap_info_t *) ((uintptr_t) vq_desc[2].addr);
uint32_t cnt = query->count;
virtio_snd_chmap_info_t *info = (virtio_snd_chmap_info_t *) malloc(
sizeof(virtio_snd_chmap_info_t) * cnt);
for (uint32_t i = 0; i < query->count; i++) {
info[i].direction = VIRTIO_SND_D_OUTPUT;
info[i].channels = 1;
info[i].positions[0] = VIRTIO_SND_CHMAP_MONO;
}
vq_desc[2].addr = (uintptr_t) info;
}

static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
Expand Down

0 comments on commit 8284af3

Please sign in to comment.