summaryrefslogtreecommitdiffstats
path: root/server/snd_worker.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused snd_get_playback_compression() methodChristophe Fergeau2015-08-111-5/+0
|
* sound: do not modify client state on migrationMarc-André Lureau2015-06-041-1/+4
| | | | | | | | | | | | | During migration, a volume jump is observed by the client. This is due to qemu setting up destination server with default sound state, and the server sending it after the client is connected. The volume is later restored after migration is finished so there is no need to send this default state values on connection. Tested with both AC97 & HDA devices. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1012868
* Rename mm_timer/mm_timeMarc-André Lureau2014-11-271-4/+4
| | | | As suggested by Christophe on the mailing list.
* Remove guest side video time-stampingMarc-André Lureau2014-11-271-1/+0
| | | | | | | | | | | | | | | | | The multimedia time is defined by the server side monotonic time [1], but the drawing time-stamp is done in guest side, so it requires synchronization between host and guest. This is expensive, when no audio is playing, there is a ~30x/sec wakeup to update the qxl device mmtime, and it requires marking dirty the rom region. Instead, the video timestamping can be done more efficiently on server side, without visible drawbacks. [1] a better timestamp could be the audio time, since audio players are usually sync with audio time) Related to: https://bugzilla.redhat.com/show_bug.cgi?id=912763
* server: don't assert on invalid client messageMarc-André Lureau2014-07-251-1/+1
| | | | | | | | | | | Some users have been reaching this error: snd_receive: ASSERT n failed A misbehaving client could easily hit that condition by sending too big messages. Instead of assert(), replace with a warning. When a message too big to fit is received, it will simply disconnect the channel. https://bugzilla.redhat.com/show_bug.cgi?id=962187
* Add support for the Opus codecJeremy White2014-01-021-27/+94
| | | | Signed-off-by: Jeremy White <jwhite@codeweavers.com>
* Revise the spice client and server to use the new snd_codec functions in ↵Jeremy White2014-01-021-120/+85
| | | | | | | | spice-common. This makes celt optional, and paves the way to readily add additional codecs. Signed-off-by: Jeremy White <jwhite@codeweavers.com>
* Fix PlaybackeCommand typoChristophe Fergeau2013-10-091-1/+1
|
* Fix 'recive' typo throughout the code baseChristophe Fergeau2013-10-081-20/+20
| | | | 'receive' was mispelt 'recive' in multiple places.
* Namespace RECEIVE_BUF_SIZEChristophe Fergeau2013-10-081-3/+3
|
* log: improve debug information related to client disconnectionYonit Halperin2013-07-291-3/+4
|
* snd_worker/snd_disconnect_channel: don't call snd_channel_put if the channel ↵Yonit Halperin2013-07-291-10/+10
| | | | | | | | | | | has already been disconnected The snd channels has one reference as long as their socket is active. The playback channel has an additional reference for each frame that is currently filled by the sound device. Once the channel is disconnected (the socket has been freed and the first reference is released) snd_disconnect_channel shouldn't release a reference again.
* snd_worker: fix memory leak of PlaybackChannelYonit Halperin2013-07-291-5/+4
| | | | | | | | | | When the sequence of calls bellow occurs, the PlaybackChannel is not released (snd_channel_put is not called for the samples that refer to the channel). spice_server_playback_get_buffer snd_channel_disconnect spice_server_playback_put_samples
* snd_worker: support sending SPICE_MSG_PLAYBACK_LATENCYYonit Halperin2013-04-221-0/+44
| | | | also update spice-common submodule
* snd_worker: Make sure we never send an empty volume messageHans de Goede2013-04-191-3/+7
| | | | | | | | | | | | My commit 71315b2e "snd_worker: Don't send empty audio-volume messages", fixes only one case of sending an empty volume message, if the client connects to a vm early during its boot sequence, while the snd hardware is being reset by the guest driver, qemu will call spice_server_playback_set_volume() with 0 channels from the reset handler. This patch also applies both fixes to the record channel. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* snd_worker: Don't send empty audio-volume messagesHans de Goede2013-04-011-1/+4
| | | | | | | | | | | If no volume has been set it, we end up sending a volume message with audio-volume for 0 channels (iow an empty message). This is not useful and triggers the following warning in spice-gtk: (remote-viewer:8726): GSpice-WARNING **: set_sink_input_volume() failed: Invalid argument Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* snd channel: fix accessing freed memoryYonit Halperin2012-10-111-2/+2
| | | | | snd_channel_put freed "channel", and then channel->worker was accessed. It caused segmentation faults during connections and disconnections of the client.
* Fix PlaybackChannel forward declarationChristophe Fergeau2012-10-011-3/+2
| | | | | | | This caused a jenkins build failure: snd_worker.c:148: error: redefinition of typedef 'PlaybackChannel' snd_worker.c:126: note: previous declaration of 'PlaybackChannel' was here
* server: Access the correct SndChannel for a given AudioFrameAndrew Eikum2012-10-011-5/+11
| | | | | | The client of _get_buffer() holds a ref to the SndChannel, and we should access that SndChannel when _put_samples() is called, not the one that happens to currently be attached to the Interface.
* server: Don't release SndChannel twice from worker referenceAndrew Eikum2012-10-011-1/+1
| | | | | | | | When we release the SndChannel reference during snd_disconnect_channel(), we need to set the pointer to NULL so it doesn't get released again on client reconnect during snd_set_playback_peer(). This can happen when a reference is held from _playback_get_buffer().
* red_channel: remove unused migrate flag from RedChannelYonit Halperin2012-08-271-7/+3
| | | | The relevant flags reside in RedChannelClient and RedClient
* snd_worker: handling migrationYonit Halperin2012-08-271-61/+17
| | | | | | | | | | The playback and record channel send SPICE_MSG_MIGRATE to the client. Both playback and record channel does not have a state to restore: while in the legacy migration implementation the record channel used to restore the mode and start time, it looks unnecessary since the client receives from the src MSG_RECORD_STOP before the migration completion notification (when the vm is stopped). Afterwards, when the vm starts on the dest side, the client receives MSG_RECORD_START.
* snd_channel: fix double releaseYonit Halperin2012-08-271-10/+17
| | | | | | | | Due to the fix in the previous patch, snd_disconnect_channel can be called both when there is write/read error in the channel, or from red_client_destroy (which calls client_cbs.disconnect). Multiple calls to snd_disconnect_channel resulted in calling channel->cleanup(channel) more than once (double release).
* red_channel (dummy): fix not adding dummy RedChannelClient to the clientYonit Halperin2012-08-271-1/+1
| | | | | | | | | | | snd channel wasn't added to be part of the client's channels list. As a result, when the client was destroyed, or migrated, snd channel client wasn't destroy, or its migration callback wasn't called. However, due to adding dummy channels to the client, we need special handling for calls to disconnecting dummy channel clients. TODO: we need to refactor snd_worker to use red_channel
* server: handle red_channel_client_create returning NULLYonit Halperin2012-05-211-0/+3
|
* fix error-path return in snd_set_record_peer()Michael Tokarev2012-04-181-2/+2
| | | | | | The error_{1,2} labels in this functions are backwards. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* Use the spice-common logging functionsMarc-André Lureau2012-03-251-49/+49
| | | | | It will abort by default for critical level messages. That behaviour can be tuned at runtime.
* Use the spice-common submoduleMarc-André Lureau2012-03-251-2/+3
| | | | | | | | | | | | | | | | | | This patch will replace the common/ directory with the spice-common project. It is for now a simple project subdirectory shared with spice-gtk, but the goal is to make it a proper library later on. With this change, the spice-server build is broken. The following commits fix the build, and have been seperated to ease the review. v2 - moves all the generated marshallers to spice-common library - don't attempt to fix windows VS build, which should somehow be splitted with spice-common (or built from tarball only to avoid generation tools/libs deps) v3 - uses libspice-common-client - fix a mutex.h inclusion reported by Alon
* Ensure all members of ChannelCbs and ClientCbs are either assigned or NULLHans de Goede2012-03-101-2/+2
| | | | | | | | | | | | | | | While git-bisecting another issue I ended up hitting and not recognizing the bug fixed by commit 7a079b452b026d6ce38f95dcc397fa64b059fffb. While fixing this (again) I noticed that (even after the fix) not all users of ChannelCbs first zero it. So this patch ensures that all users of ChannelCbs first zero it, and does the same for ClientCbs while at it. Since before this patch there were multiple zero-ing styles, some using memset and other using a zero initializer this patch also unifies all the zero-ing to use a NULL initializer for the first element. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Use standard IOV_MAX definition where applicableDan McGee2012-02-211-3/+6
| | | | | | | | This is provided by <limits.h> on all platforms as long as _XOPEN_SOURCE is defined. On Linux, this is 1024, on Solaris, this is 16, and on any other platform, we now respect the value supported by the OS. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Remove extra '\n' from red_printf() callsDan McGee2012-02-141-1/+1
| | | | | | | red_printf() takes care of adding a newline to all messages; remove the extra newline from all messages and macros that were doubling them up. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* server: don't complain if setsockopt(SO_PRIORITY) call failsNahum Shalman2012-01-231-1/+7
| | | | | | | | | | dc7855967f4e did this for the TCP_NODELAY and IP_TOS calls; we should do it for priority as well if necessary. We also #ifdef the setting of the low-level socket priority based on whether we have a definition of SO_PRIORITY available. This option is not available on Illumos/Solaris platforms; however, since we set IP_TOS anyway it is not a big deal to omit it here.
* server: Don't complain if setsockopt NODELAY fails on unix socketsHans de Goede2012-01-181-2/+6
| | | | | | | | | | | | With Daniel P. Berrange's patches to allow use of pre-supplied fd's as channels, we can no longer be sure that our connections are TCP sockets, so it makes no sense to complain if a TCP/IP specific setsockopt fails with an errno of ENOTSUP. Note that this extends Daniel's commit 492ddb5d1d595e2d12208f4602b18e4432f4e6b4 which already added the same check to server/inputs_channel.c Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Remove trailing blank linesDaniel P. Berrange2012-01-131-1/+0
| | | | Remove any blank lines at the end of all source files
* server: add support for SPICE_COMMON_CAP_MINI_HEADERYonit Halperin2012-01-121-35/+58
| | | | | | | | | Support for a header without a serial and without sub list. red_channel: Support the two types of headers. Keep a consistent consecutive messages serial. red_worker: use urgent marshaller instead of sub list. snd_worker: Sound channels need special support since they still don't use red_channel for sending & receiving.
* server: set & test channel capabilities in red_channelYonit Halperin2011-11-021-41/+25
| | | | | | | The code for setting and testing channel capabilities was unnecessarily duplicated. Now it is in red_channel. RedsChannel was dropped from Reds; It was used only for holding the channels common capabilities, which are now held in RedChannel.
* server/snd_worker.c: add reference counting to SndChannelAlon Levy2011-08-231-3/+28
| | | | | | | | | | Fixes a valgrind discovered possible bug in spice-server - valgrind on test_playback saw it, didn't see it happen with qemu. The problem is that the frames buffers returned by spice_server_playback_get_buffer are part of the malloc'ed SndChannel, whose lifetime is smaller then that of SndWorker. As a result a pointer to a previously returned spice_server_playback_get_buffer could remain and be used after SndChannel has been freed because the client disconnected.
* server/snd_worker.c: add red_channel_client_destroy_dummyAlon Levy2011-08-231-0/+1
|
* server: registering RedChannel in reds, instead of ChannelYonit Halperin2011-08-231-60/+97
| | | | | | | | | | | | | | | | | | | | | | | Merging the functionality of reds::channel, into RedChannel. In addition, cleanup and fix disconnection code: before this patch, red_dispatcher_disconnect_display_client could have been called from the red_worker thread (and it must be called only from the io thread). RedChannel holds only connected channel clients. RedClient holds all the channel clients that were created till it is destroyed (and then it destroys them as well). Note: snd_channel still doesn't use red_channel, however it creates dummy channel and channel clients, in order to register itself in reds. server/red_channel.c: a channel is connected if it holds at least one channel client Previously I changed RedChannel to hold only connected channel clients and RedClient, to hold all the channel clients as long as it is not destroyed. usbredir: multichannel has not been tested, it just compiles.
* server/main_channel: move latency and bitrate to channel clientAlon Levy2011-08-231-1/+11
| | | | | | | | | | | | They were globals before. This introduces api for other channels to query the low bandwidth status. The queries themselves are still done from the wrong context (channel and not channel client) but that's because the decoupling of channel and channel client will be done in the following patches. Note that snd_worker.c got two copied function declarations that belong to main_channel.h but can't be easily dragged into snd_worker.c since it still uses it's own RedChannel struct.
* server: Add RedClientAlon Levy2011-08-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That means RedClient tracks a ring of channels. Right now there will be only a single client because of the disconnection mechanism - whenever a new client comes we disconnect all existing clients. But this patch adds already a ring of clients to reds.c (stored in RedServer). There is a known problem handling many connections and disconnections at the same time, trigerrable easily by the following script: export NEW_DISPLAY=:3.0 Xephyr $NEW_DISPLAY -noreset & for ((i = 0 ; i < 5; ++i)); do for ((j = 0 ; j < 10; ++j)); do DISPLAY=$NEW_DISPLAY c_win7x86_qxl_tests & done sleep 2; done I fixed a few of the problems resulting from this in the same patch. This required already introducing a few other changes: * make sure all removal of channels happens in the main thread, for that two additional dispatcher calls are added to remove a specific channel client (RED_WORKER_MESSAGE_CURSOR_DISCONNECT_CLIENT and RED_WORKER_MESSAGE_DISPLAY_DISCONNECT_CLIENT). * change some asserts in input channel. * make main channel disconnect not recursive * introduce disconnect call back to red_channel_create_parser The remaining abort is from a double free in the main channel, still can't find it (doesn't happen when running under valgrind - probably due to the slowness resulting from that), but is easy to see when running under gdb.
* s/__visible__/SPICE_GNUC_VISIBLEChristophe Fergeau2011-06-221-13/+13
| | | | | The C specification reserves use of identifiers starting with __ to the compiler so we shouldn't use one such symbol.
* sndworker: check the caps before sending volume messagesMarc-André Lureau2011-06-221-10/+46
|
* sndworker: add AudioVolume/AudioMute messagesMarc-André Lureau2011-06-221-2/+170
| | | | | | | | | | | | | | | | | | | These messages allow the guest to send the audio device volume to the client. It uses an arbitrary scale of 16bits, which works good enough for now. Save VolumeState in {Playback,Record}State, so that we can send the current volume on channel connection. Note about future improvements: - add exact dB support - add client to guest volume change Updated since v2: - bumped record and playback interface minor version to allow conditional compilation Updated since v1: - sync record volume on connection too
* add #include <config.h> to all source filesChristophe Fergeau2011-05-031-0/+3
| | | | | | | | When using config.h, it must be the very first include in all source files since it contains #define that may change the compilation process (eg libc structure layout changes when it's used to enable large file support on 32 bit x86 archs). This commit adds it at the beginning of all .c and .cpp files
* server: s/desable/disableChristophe Fergeau2011-05-021-2/+2
| | | | | This fixes a typo in some function names, there should be no functional change.
* use foo(void) instead of foo() in prototypesChristophe Fergeau2011-05-021-1/+1
| | | | | In C, the latter isn't a prototype for a function with no arg, but declares a function with an undefined number of args.
* server: add reds_channel_dispose()Marc-André Lureau2011-02-281-2/+1
| | | | | | | | | | Try to have a common base dispose() method for channels. For now, it just free the caps. Make use of it in snd_worker, and in sync_write() - sync_write() is going to have default caps later on. https://bugs.freedesktop.org/show_bug.cgi?id=34795
* server: rename s/peer/streamMarc-André Lureau2011-02-281-22/+22
| | | | | | | | This is stylish change again. We are talking about a RedStream object, so let's just name the variable "stream" everywhere, to avoid confusion with a non existent RedPeer object. https://bugs.freedesktop.org/show_bug.cgi?id=34795
* server: use the new reds_stream_{read,write}Marc-André Lureau2011-02-281-2/+4
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=34795