Skip to content

Commit bbe3c06

Browse files
committed
Hold settings into variable
1 parent acc2c7d commit bbe3c06

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

virtio-snd.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,21 @@ typedef struct {
223223
uint8_t positions[VIRTIO_SND_CHMAP_MAX_SIZE];
224224
} virtio_snd_chmap_info_t;
225225

226+
/* virtio-snd to hold the settings of each stream */
227+
typedef struct {
228+
virtio_snd_jack_info_t j;
229+
virtio_snd_pcm_info_t p;
230+
virtio_snd_chmap_info_t c;
231+
virtio_snd_pcm_set_params_t pp;
232+
struct CNFADriver *audio_host;
233+
bool is_guest_playing;
234+
} virtio_snd_prop_t;
235+
226236
static virtio_snd_config_t vsnd_configs[VSND_DEV_CNT_MAX];
237+
static virtio_snd_prop_t vsnd_props[VSND_DEV_CNT_MAX];
227238
static int vsnd_dev_cnt = 0;
228239

229-
static struct CNFADriver *audio_host = NULL;
240+
//static struct CNFADriver *audio_host = NULL;
230241

231242
static bool guest_playing = false;
232243

@@ -271,20 +282,29 @@ static void virtio_snd_read_jack_info_handler(
271282
virtio_snd_jack_info_t *info,
272283
const virtio_snd_query_info_t *query)
273284
{
285+
printf("jack info handler count %d\n", query->count);
274286
for (uint32_t i = 0; i < query->count; i++) {
275287
info[i].hdr.hda_fn_nid = 0;
276288
info[i].features = 0;
277289
info[i].hda_reg_defconf = 0;
278290
info[i].hda_reg_caps = 0;
279291
info[i].connected = 1;
280292
memset(&info[i].padding, 0, sizeof(info[i].padding));
293+
294+
vsnd_props[i].j.hdr.hda_fn_nid = 0;
295+
vsnd_props[i].j.features = 0;
296+
vsnd_props[i].j.hda_reg_defconf = 0;
297+
vsnd_props[i].j.hda_reg_caps = 0;
298+
vsnd_props[i].j.connected = 1;
299+
memset(&vsnd_props[i].j.padding, 0, sizeof(vsnd_props[i].j.padding));
281300
}
282301
}
283302

284303
static void virtio_snd_read_pcm_info_handler(
285304
virtio_snd_pcm_info_t *info,
286305
const virtio_snd_query_info_t *query)
287306
{
307+
printf("snd info handler count %d\n", query->count);
288308
for (uint32_t i = 0; i < query->count; i++) {
289309
info[i].hdr.hda_fn_nid = 0;
290310
info[i].features = 0;
@@ -294,18 +314,33 @@ static void virtio_snd_read_pcm_info_handler(
294314
info[i].channels_min = 1;
295315
info[i].channels_max = 1;
296316
memset(&info[i].padding, 0, sizeof(info[i].padding));
317+
318+
vsnd_props[i].p.hdr.hda_fn_nid = 0;
319+
vsnd_props[i].p.features = 0;
320+
vsnd_props[i].p.formats = (1 << VIRTIO_SND_PCM_FMT_S16);
321+
vsnd_props[i].p.rates = (1 << VIRTIO_SND_PCM_RATE_44100);
322+
vsnd_props[i].p.direction = VIRTIO_SND_D_OUTPUT;
323+
vsnd_props[i].p.channels_min = 1;
324+
vsnd_props[i].p.channels_max = 1;
325+
memset(&vsnd_props[i].p.padding, 0, sizeof(vsnd_props[i].p.padding));
297326
}
298327
}
299328

300329
static void virtio_snd_read_chmap_info_handler(
301330
virtio_snd_chmap_info_t *info,
302331
const virtio_snd_query_info_t *query)
303332
{
333+
printf("chmap info handler count %d\n", query->count);
304334
for (uint32_t i = 0; i < query->count; i++) {
305335
info[i].hdr.hda_fn_nid = 0;
306336
info[i].direction = VIRTIO_SND_D_OUTPUT;
307337
info[i].channels = 1;
308338
info[i].positions[0] = VIRTIO_SND_CHMAP_MONO;
339+
340+
vsnd_props[i].c.hdr.hda_fn_nid = 0;
341+
vsnd_props[i].c.direction = VIRTIO_SND_D_OUTPUT;
342+
vsnd_props[i].c.channels = 1;
343+
vsnd_props[i].c.positions[0] = VIRTIO_SND_CHMAP_MONO;
309344
}
310345
}
311346

@@ -734,12 +769,12 @@ bool virtio_snd_init(virtio_snd_state_t *vsnd)
734769
/* Allocate the memory of private member. */
735770
vsnd->priv = &vsnd_configs[vsnd_dev_cnt++];
736771

737-
audio_host = CNFAInit(NULL, "semu-virtio-snd", virtio_snd_cb, 44100, 0, 1,
772+
/*audio_host = CNFAInit(NULL, "semu-virtio-snd", virtio_snd_cb, 44100, 0, 1,
738773
0, 1024, NULL, NULL, &guest_playing);
739774
if (!audio_host) {
740775
fprintf(stderr, "virtio-snd driver initialization failed.\n");
741776
return false;
742-
}
777+
}*/
743778

744779
PRIV(vsnd)->jacks = 1;
745780
PRIV(vsnd)->streams = 1;

0 commit comments

Comments
 (0)