Skip to content

QEMU Extended Audio Support#1457

Closed
tinyzimmer wants to merge 1 commit intonovnc:masterfrom
tinyzimmer:qemu-extended-audio-support
Closed

QEMU Extended Audio Support#1457
tinyzimmer wants to merge 1 commit intonovnc:masterfrom
tinyzimmer:qemu-extended-audio-support

Conversation

@tinyzimmer
Copy link
Copy Markdown

I opened a fresh draft because I had way too many mistakes on my first branch 😛

I have not yet tested these changes and obviously documentation will need to be updated. This is mainly intended to continue the discussion from #302.

Forgive me if I made some mistakes, since this is my first time really digging into the underlying protocol, but this is my first draft attempt at implementing handling for the QEMU Audio Server Message and public methods wrapping the QEMU Audio Client Message.

I'm trying to figure out the best way I could go about testing these changes and fine tuning them. In my current project where I'm using noVNC I am simply proxying the data from an Xvnc server, so I would need to find a good one to use that supports the extended protocol.

@tinyzimmer
Copy link
Copy Markdown
Author

tinyzimmer commented Aug 27, 2020

For starters, one thing that I know will need to be changed here is how the audio is being played. I assume it's raw PCM data coming over the socket. And I am not sure if the MediaSource API can handle that, but I believe window.AudioContext can.

EDIT: https://github.com/samirkumardas/pcm-player might be an interesting way to playback the data. It's an MIT license. I imagine the implementation could look something like this:

    _handleQEMUExtAudioMsg() {
        if (this._sock.rQwait("QEMU extended audio message", 3, 1)) { return false; }

        this._sock.rQshift8(); // for now there is only a single submessage type 1
        const operation = this._sock.rQshift16();

        if (operation === 1) { // stream is starting
            this._player = new PCMPlayer(this._audio_opts);  // set when RFB.enableAudio() is called
        } else if (operation === 0) { // stream is stopping
            this._player.destroy()
        } else {  // stream data
            const length = this._sock.rQshift32();
            const data = this._sock.rQshiftBytes(length);
            this._player.feed(data);
        }

        return true;
    }

@alectrocute
Copy link
Copy Markdown

Hey all. For what it's worth, another OSS project called Neko managed to implement pulseaudio playback elegantly. May be worth checking out how they play back audio (which I assume is PCM?): https://github.com/nurdism/neko/search?q=pulseaudio&unscoped_q=pulseaudio

@tinyzimmer
Copy link
Copy Markdown
Author

Hey all. For what it's worth, another OSS project called Neko managed to implement pulseaudio playback elegantly. May be worth checking out how they play back audio (which I assume is PCM?): https://github.com/nurdism/neko/search?q=pulseaudio&unscoped_q=pulseaudio

That actually looks interesting. I'm surprised I didn't come across it when I was working on my side project which is very similar. I'll poke through the code later, but on the README they mention that it uses WebRTC. If that is the case for the audio as well, I am not sure if it would be a good example for implementing here.

WebRTC is definitely the easiest way to do something like this, but there are infrastructure requirements that I don't think would be available in most use cases.

@samhed
Copy link
Copy Markdown
Member

samhed commented Aug 31, 2020

Thanks for the PR!

Regarding a server for testing - from what I can gather it seems only the built in VNC server in libvirt/QEMU supports this.

@samhed samhed added the feature label Aug 31, 2020
@samhed samhed marked this pull request as draft August 31, 2020 12:45
@samhed samhed changed the title [WIP] QEMU Extended Audio Support QEMU Extended Audio Support Aug 31, 2020
@tinyzimmer
Copy link
Copy Markdown
Author

tinyzimmer commented Sep 1, 2020

Yea that's what I gathered too from searching about. So in the context of the project where I am using noVNC, I was either going to try to figure out a way to "proxy" the protocol and inject audio messages...or just spin up some qemu VMs at some point and start tinkering. I spent like an hour trying to conceptualize the former and at the time just said "nah" 😛.

@tinyzimmer
Copy link
Copy Markdown
Author

Just chiming in that I haven't completely forgotten about this. I may try out some testing in the coming weeks.

@samhed
Copy link
Copy Markdown
Member

samhed commented Oct 8, 2020

Good to hear @tinyzimmer

@jgforbes
Copy link
Copy Markdown

@tinyzimmer: Any progress on getting qemu sound channel to work with noVNC? Anything I can do to help?

@tinyzimmer
Copy link
Copy Markdown
Author

@jgforbes I've been all over the place between starting new jobs and personal crises so I haven't had a chance to play with it extensively yet. If you want to jump it at any point by all means, but I promise I will try to get back to this eventually. Some considerations I've already encountered.

The code in it's current state will not work I know that. Not without either refactoring the client to take raw PCM (lots of data), or implementing a server that can encode the audio to webm. If it's just the raw QEMU support we want to consider including anyway, then the code in this PR that calls the browser Audio APIs needs to be refactored accordingly, but the protocol stuff should be okay so far.

Then it's just a matter of testing. Which basically using qemu is the only option it seems. I started down a path of implementing a sorta libvncserver in go just for kicks, but also thinking it could eventually be another option out in the wild for having a server that supports audio. That project is very far from completion though lol.

@jeffforbes
Copy link
Copy Markdown

@tinyzimmer Would it be possible to contact you about your QEMU VNC audio channel work outside of github?

@tinyzimmer
Copy link
Copy Markdown
Author

tinyzimmer commented Dec 9, 2020 via email

@jgforbes
Copy link
Copy Markdown

jgforbes commented Dec 10, 2020 via email

@jeffforbes
Copy link
Copy Markdown

@tinyzimmer Did you receive the email I sent to the address in your profile?

@tinyzimmer
Copy link
Copy Markdown
Author

@jeffforbes I must have missed it, sorry. That is the correct address though. In all fairness, I haven't had time, and not sure when or if I will, to continue work on this PR in the near future 😢

@tinyzimmer
Copy link
Copy Markdown
Author

I'm tempted to close this PR. If anything because if I do approach it again I'd like to do so from a fresh slate.

But also I am getting to the point in my project where I am adding support for QEMU machines on the server side. When I then wanted a dynamic display resolution, it made more sense to try to use Spice for those instances then to continue with noVNC. Though I think I'll try to keep support for both.

If and when I do have that finished, I'll actually have a decent test environment for if I do want to play with this again. And, at least for me, it'll make more sense to pick it back up then.

@samhed
Copy link
Copy Markdown
Member

samhed commented Feb 16, 2021

Understandable. Note however that noVNC does have support for dynamic display resolution using the ExtendedDesktopSize pseudo-encoding. I don't know if QEMU's VNC server has support for that though.

@tinyzimmer
Copy link
Copy Markdown
Author

I am actually using that already for the current functionality I have that doesn't use QEMU.

But to my understanding, I don't think the QEMU VNC server supports it. I think that's where they push you towards SPICE instead.

@tinyzimmer tinyzimmer closed this Feb 16, 2021
@jgforbes
Copy link
Copy Markdown

jgforbes commented Feb 16, 2021 via email

@tinyzimmer
Copy link
Copy Markdown
Author

Yea I am noticing that as I try to integrate it. Will see where this journey takes me.

@Neustradamus
Copy link
Copy Markdown

It replaces:

This was referenced Nov 20, 2025
@Neustradamus
Copy link
Copy Markdown

Neustradamus commented Nov 20, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants