Skip to content

Commit bd3e192

Browse files
committed
Remove comments
1 parent 298f7da commit bd3e192

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

virtio-snd.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,8 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
940940
cnt++;
941941

942942
/* Leave the loop if next-flag is not set */
943-
if (!(desc[3] & VIRTIO_DESC_F_NEXT)) {
944-
// fprintf(stderr, "index %" PRIu32 " no next flag\n", cnt);
943+
if (!(desc[3] & VIRTIO_DESC_F_NEXT))
945944
break;
946-
}
947945
}
948946

949947
int idx = 0;
@@ -953,30 +951,23 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
953951
list_for_each_entry (node, &q, q) {
954952
uint32_t addr = node->vq_desc.addr;
955953
uint32_t len = node->vq_desc.len;
956-
// fprintf(stderr, "idx %d addr %" PRIu32 " len %" PRIu32 "\n", idx,
957-
// addr, len);
958-
if (idx == 0) { // the first descriptor
954+
if (idx == 0) { /* the first descriptor */
959955
const virtio_snd_pcm_xfer_t *request =
960956
(virtio_snd_pcm_xfer_t *) (base + addr);
961957
stream_id = request->stream_id;
962-
// fprintf(stderr, "stream_id %" PRIu32 "\n", stream_id);
963958
goto early_continue;
964-
} else if (idx == cnt - 1) { // the last descriptor
959+
} else if (idx == cnt - 1) { /* the last descriptor */
965960
virtio_snd_pcm_status_t *response =
966961
(virtio_snd_pcm_status_t *) (base + addr);
967962
response->status = VIRTIO_SND_S_OK;
968963
response->latency_bytes = ret_len;
969964
*plen = sizeof(*response);
970-
// fprintf(stderr, "TX response\n");
971965
goto early_continue;
972966
}
973967

974968
/* TODO: ring buffer copy here */
975969
void *payload = (void *) (base + addr);
976970
__virtio_snd_frame_enqueue(payload, len, stream_id);
977-
/* XXX: test only */
978-
/*fprintf(stderr, "prod tail: %" PRIu32 "\n",
979-
vsnd_props[stream_id].ring.prod.tail);*/
980971
ret_len += len;
981972

982973
early_continue:
@@ -1040,7 +1031,6 @@ static void virtio_queue_notify_handler(
10401031
*/
10411032
uint32_t len = 0;
10421033
int result = handler(vsnd, queue, buffer_idx, &len);
1043-
// fprintf(stderr, "len: %" PRIu32 "\n", len);
10441034
if (result != 0)
10451035
return virtio_snd_set_fail(vsnd);
10461036

@@ -1052,40 +1042,29 @@ static void virtio_queue_notify_handler(
10521042
ram[vq_used_addr + 1] = len; /* virtq_used_elem.len (le32) */
10531043
queue->last_avail++;
10541044
new_used++;
1055-
1056-
// fprintf(stderr, "last_avail %d new_avail %d\n", queue->last_avail,
1057-
// new_avail);
10581045
}
10591046

10601047
/* Check le32 len field of struct virtq_used_elem on the spec */
10611048
vsnd->ram[queue->QueueUsed] &= MASK(16); /* Reset low 16 bits to zero */
10621049
vsnd->ram[queue->QueueUsed] |= ((uint32_t) new_used) << 16; /* len */
10631050

10641051
/* Send interrupt, unless VIRTQ_AVAIL_F_NO_INTERRUPT is set */
1065-
if (!(ram[queue->QueueAvail] & 1)) {
1066-
// fprintf(stderr, "send interrupt\n");
1052+
if (!(ram[queue->QueueAvail] & 1))
10671053
vsnd->InterruptStatus |= VIRTIO_INT__USED_RING;
1068-
}
10691054
}
10701055

1071-
/* TX thread context
1072-
* TODO: need to let this thread become a daemon.
1073-
*/
1056+
/* TX thread context */
10741057
static void *func(void *args)
10751058
{
10761059
virtio_snd_state_t *vsnd = (virtio_snd_state_t *) args;
10771060
for (;;) {
1078-
// fprintf(stderr, "*** tx desc handler is called ***\n");
10791061
pthread_mutex_lock(&virtio_snd_mutex);
1080-
while (tx_ev_notify <= 0) {
1062+
while (tx_ev_notify <= 0)
10811063
pthread_cond_wait(&virtio_snd_tx_cond, &virtio_snd_mutex);
1082-
// fprintf(stderr, "wait for cond\n");
1083-
}
1084-
// fprintf(stderr, "*** start tx critical section ***\n");
1064+
10851065
tx_ev_notify--;
1086-
// fprintf(stderr, "*** tx desc handler ***\n");
10871066
virtio_queue_notify_handler(vsnd, 2, virtio_snd_tx_desc_handler);
1088-
// fprintf(stderr, "*** end tx cirtical section ***\n");
1067+
10891068
pthread_mutex_unlock(&virtio_snd_mutex);
10901069
}
10911070
pthread_exit(NULL);

0 commit comments

Comments
 (0)