Skip to content

Commit

Permalink
Set response length in pcm_*
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Nov 2, 2024
1 parent f9834b2 commit 62869e4
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ static void virtio_snd_read_chmap_info_handler(
}

static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
const virtio_snd_query_info_t *query)
const virtio_snd_query_info_t *query,
uint32_t *plen)
{
virtio_snd_pcm_set_params_t *request = query;
uint32_t id = request->hdr.stream_id;
Expand All @@ -407,11 +408,13 @@ static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
vsnd_props[id].pp.rate = request->rate;
vsnd_props[id].pp.padding = request->padding;

*plen = 0;
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)
const virtio_snd_query_info_t *query,
uint32_t *plen)
{
virtio_snd_pcm_hdr_t *request = query;
uint32_t stream_id = request->stream_id;
Expand Down Expand Up @@ -440,11 +443,13 @@ static void virtio_snd_read_pcm_prepare(struct virtq_desc *vq_desc,
v.stream_id = 0;
pthread_mutex_unlock(&virtio_snd_mutex);

*plen = 0;
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)
const virtio_snd_query_info_t *query,
uint32_t *plen)
{
virtio_snd_pcm_hdr_t *request = query;
uint32_t stream_id = request->stream_id;
Expand All @@ -464,11 +469,13 @@ static void virtio_snd_read_pcm_start(struct virtq_desc *vq_desc,
v.guest_playing = true;
pthread_mutex_unlock(&virtio_snd_mutex);

*plen = 0;
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)
const virtio_snd_query_info_t *query,
uint32_t *plen)
{
virtio_snd_pcm_hdr_t *request = query;
uint32_t stream_id = request->stream_id;
Expand All @@ -487,11 +494,13 @@ static void virtio_snd_read_pcm_stop(struct virtq_desc *vq_desc,
v.guest_playing = false;
pthread_mutex_lock(&virtio_snd_mutex);

*plen = 0;
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)
const virtio_snd_query_info_t *query,
uint32_t *plen)
{
virtio_snd_pcm_hdr_t *request = query;
uint32_t stream_id = request->stream_id;
Expand All @@ -513,6 +522,7 @@ static void virtio_snd_read_pcm_release(struct virtq_desc *vq_desc,
CNFAClose(vsnd_props[stream_id].audio_host);
free(vsnd_props[stream_id].buf);

*plen = 0;
fprintf(stderr, "virtio_snd_read_pcm_release\n");
}

Expand Down Expand Up @@ -624,19 +634,19 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
virtio_snd_read_chmap_info_handler(info, query, plen);
break;
case VIRTIO_SND_R_PCM_SET_PARAMS:
virtio_snd_read_pcm_set_params(vq_desc, query);
virtio_snd_read_pcm_set_params(vq_desc, query, plen);
break;
case VIRTIO_SND_R_PCM_PREPARE:
virtio_snd_read_pcm_prepare(vq_desc, query);
virtio_snd_read_pcm_prepare(vq_desc, query, plen);
break;
case VIRTIO_SND_R_PCM_RELEASE:
virtio_snd_read_pcm_release(vq_desc, query);
virtio_snd_read_pcm_release(vq_desc, query, plen);
break;
case VIRTIO_SND_R_PCM_START:
virtio_snd_read_pcm_start(vq_desc, query);
virtio_snd_read_pcm_start(vq_desc, query, plen);
break;
case VIRTIO_SND_R_PCM_STOP:
virtio_snd_read_pcm_stop(vq_desc, query);
virtio_snd_read_pcm_stop(vq_desc, query, plen);
break;
default:
fprintf(stderr, "%d: unsupported virtio-snd operation!\n", type);
Expand Down

0 comments on commit 62869e4

Please sign in to comment.