Skip to content

Commit

Permalink
speaker-test fail at unknown op type
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Oct 10, 2024
1 parent b4ad757 commit 509387e
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,63 +308,51 @@ static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
info->rate = (1 << VIRTIO_SND_PCM_RATE_44100);
info->padding = 0;
#endif
fprintf(stderr, "virtio_snd_read_pcm_set_params");
fprintf(stderr, "virtio_snd_read_pcm_set_params\n");
}

static void virtio_snd_read_pcm_prepare(struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
virtio_snd_pcm_hdr_t *hdr =
(virtio_snd_pcm_hdr_t *) ((uintptr_t) vq_desc[2].addr);

/* TODO: let application to set stream_id at will */
hdr->hdr.code = VIRTIO_SND_R_PCM_PREPARE;
hdr->stream_id = 0;

/* Control the callback to prepare the buffer */
/* TODO: add lock to avoid race condition */
guest_playing = false;

fprintf(stderr, "virtio_snd_read_pcm_prepare\n");
}

static void virtio_snd_read_pcm_start(struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
virtio_snd_pcm_hdr_t *hdr =
(virtio_snd_pcm_hdr_t *) ((uintptr_t) vq_desc[2].addr);

/* TODO: let application to set stream_id at will */
hdr->hdr.code = VIRTIO_SND_R_PCM_START;
hdr->stream_id = 0;

/* Control the callback to start playing */
/* TODO: add lock to avoid race condition */
guest_playing = true;

fprintf(stderr, "virtio_snd_read_pcm_start\n");
}

static void virtio_snd_read_pcm_stop(struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
virtio_snd_pcm_hdr_t *hdr =
(virtio_snd_pcm_hdr_t *) ((uintptr_t) vq_desc[2].addr);

/* TODO: let application to set stream_id at will */
hdr->hdr.code = VIRTIO_SND_R_PCM_STOP;
hdr->stream_id = 0;

/* Control the callback to stop playing */
/* TODO: add lock to avoid race condition */
guest_playing = false;

fprintf(stderr, "virtio_snd_read_pcm_stop\n");
}

static void virtio_snd_read_pcm_release(struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
{
virtio_snd_pcm_hdr_t *hdr =
(virtio_snd_pcm_hdr_t *) ((uintptr_t) vq_desc[2].addr);

/* TODO: let application to set stream_id at will */
hdr->hdr.code = VIRTIO_SND_R_PCM_RELEASE;
hdr->stream_id = 0;

fprintf(stderr, "virtio_snd_read_pcm_release\n");
}

static void virtio_snd_cb(struct CNFADriver *dev,
Expand Down Expand Up @@ -466,7 +454,7 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
virtio_snd_read_pcm_stop(vq_desc, query);
break;
default:
fprintf(stderr, "unsupported virtio-snd operation!\n");
fprintf(stderr, "%d: unsupported virtio-snd operation!\n", type);
response->code = VIRTIO_SND_S_NOT_SUPP;
*plen = 0;
return -1;
Expand Down

0 comments on commit 509387e

Please sign in to comment.