Skip to content

Commit

Permalink
Add prorotypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Sep 18, 2024
1 parent de49607 commit 1c8bd5e
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,39 @@ static void virtio_snd_read_pcm_prepare(struct virtq_desc *vq_desc,
hdr->stream_id = 0;
}

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;
}

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;
}

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;
}

static void virtio_snd_cb(struct CNFADriver *dev,
short *out,
short *in,
Expand Down Expand Up @@ -394,11 +427,14 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
virtio_snd_read_pcm_prepare(vq_desc, query);
break;
case VIRTIO_SND_R_PCM_RELEASE:
virtio_snd_read_pcm_release(vq_desc, query);
break;
case VIRTIO_SND_R_PCM_START:
virtio_snd_read_pcm_start(vq_desc, query);
break;
case VIRTIO_SND_R_PCM_STOP:
fprintf(stderr, "currently not suppored by virtio-snd\n");
*status = VIRTIO_SND_S_NOT_SUPP;
return -1;
virtio_snd_read_pcm_stop(vq_desc, query);
break;
default:
fprintf(stderr, "unsupported virtio-snd operation!\n");
*status = VIRTIO_SND_S_NOT_SUPP;
Expand Down

0 comments on commit 1c8bd5e

Please sign in to comment.