Jaroslav Kysela [Mon, 14 Jun 2021 14:35:17 +0000 (16:35 +0200)]
a52: handle the source sample format correctly
The recent a52 encoder in ffmpeg accepts planar S32 (fixed encoder)
or planar float (normal encoder) only. Extend the routines to support
all combinations of 16-bit, 32-bit and float source samples.
James Almer [Sun, 6 Jun 2021 17:55:08 +0000 (14:55 -0300)]
a52: support the new libavcodec encode API
ffmpeg 4.4 is the last version with avcodec_encode_audio2(). Starting from the
next release the new decoupled input-output API will be the only one available.
The output buffer will never be appended, but a new a52 frame will always
be written in its entirety to outbuf. Therefore we don't need to move
bytes that were not yet sent to the slave to the beginning of the output
buffer.
Also don't overwrite the output buffer when there are still frames
to be sent.
pcm_a52: Don't pass EAGAIN errors from the slave to the caller
EAGAIN can happen when we already could have passed frames to the slave.
If we then return EAGAIN to our caller it wrongly indicates that no frames
were send. Therefore return the processed frames instead.
pcm_a52: Determine virtual hardware pointer upon slave pointer
Calculate the pointer upon the hardware pointer of the slave by
querying its available frames. Thereby we can guarantee that our
transfer routine will accept as many frames as the pointer indicates.
Andreas Pape [Tue, 24 Nov 2020 15:48:03 +0000 (16:48 +0100)]
jack: add option to allow non-jack-aligned period size
Commit 72337f1dcb2df6a2b7fdae93e88d7dd3a7e97ab4 forces ALSA period size
to be exact multiple of the JACK daemon period size.
There are good reasons to align the period size, but completely disallowing non aligned periods is too restrictive.
This patch adds an option "align_psize" which allows to optionally revert to original behavior.
Signed-off-by: Andreas Pape <apape@de.adit-jv.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Benedek Kupper [Thu, 21 Nov 2019 15:28:51 +0000 (16:28 +0100)]
upmix: generalize format, code cleanup
The main purpose of this change is to be able to change the format to
e.g. S32 instead of S16 by changing only two lines on the top of the source.
So a new symbol UPMIX_PCM_FORMAT is added to hide the actual format,
and a special type upmix_sample_t marks the sample type, instead of
fixed short.
The average_copy function was expecting the nchns parameter to be 2,
this parameter is now a local constant.
The variable i is renamed to channel as it denotes the channel index
in every case.
The behavior of the plugin remains identical.
Signed-off-by: Benedek Kupper <benedek.kupper@streamunlimited.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
David Ward [Fri, 3 Jan 2020 18:05:51 +0000 (13:05 -0500)]
Update the attributes.m4 macro file from xine
This file was imported from the xine project. Update it to the current
revision, which resolves the "no AC_LANG_SOURCE call detected in body"
warnings with Autoconf 2.68 or later.
Cc: Diego Pettenò <flameeyes@gmail.com> Signed-off-by: David Ward <david.ward@ll.mit.edu> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Takashi Iwai [Fri, 18 Oct 2019 06:10:04 +0000 (08:10 +0200)]
pulse: Add DEVICE parameter
Basically this patch adds the DEVICE parameter to pulse PCM and
control plugins, so that users may pass the specific pulse device
for multiple opens. Along with the addition of the DEVICE parameter
in the config definition, the plugin code is slightly modified for
allowing to receive the empty strings that are treated as the
"default" mode (= NULL).
Stian Skjelstad [Thu, 2 May 2019 21:26:15 +0000 (23:26 +0200)]
maemo: Fix a few crashing bugs
maemo plugin has two crashes I was able to see in a valgrind log from
another user:
* maximum write size was calculated in words (16bit), but checked against
byte-size length. This causes memcpy later to overflow the buffer
(normally by up to 12KB).
* remove a double free (by marking free'd data with NULL)
* mmap returns MMAP_FAILED on error, not NULL
I suspect that this plugin/driver might have other issues aswell, since I
am unable to find any logic for checking DSP buffer status, and no
implementation for odelay reporting.
Takashi Iwai [Wed, 27 Mar 2019 11:36:30 +0000 (12:36 +0100)]
configure: Fix unexpanded ALSA_DATA_DIR
When no --with-alsadatadir is given, configure scripts takes
$datadir/alsa as the default location, while it's expanded to
$prefix/data/alsa. Although ALSA_DATA_DIR is set via
AC_DEFINE_UNQUOTED(), this expands only $alsadatadir itself and not
about the $prefix in the content. For resolving this, we need to do
eval twice.
Alex Ivanov [Wed, 20 Mar 2019 17:29:33 +0000 (20:29 +0300)]
jack: use correct port names in 50-jack.conf
Change port names in 50-jack.conf from "alsa_pcm" to "system".
JACK1 v0.125.0 still provides alsa_pcm:playback_* and alsa_pcm:capture_*
port names, but only as aliases:
$ jack_lsp -A
system:capture_1
alsa_pcm:capture_1
system:capture_2
alsa_pcm:capture_2
system:playback_1
alsa_pcm:playback_1
system:playback_2
alsa_pcm:playback_2
JACK2 v1.9.12 doesn't support alsa_pcm:playback_* and alsa_pcm:capture_*
aliases anymore, so 50-jack.conf will fail for JACK2 users:
$ jack_lsp -A
system:capture_1
alsa_pcm:hw:0:out1
system:capture_2
alsa_pcm:hw:0:out2
system:playback_1
alsa_pcm:hw:0:in1
system:playback_2
alsa_pcm:hw:0:in2
As you see in both cases system:playback_* and system:capture_* are
correct port names.
Signed-off-by: Alex Ivanov <gnidorah@ya.ru> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Timo Wischer [Tue, 29 Jan 2019 14:30:56 +0000 (15:30 +0100)]
jack: Support to connect multiple JACK ports with same ALSA channel
The following example will connect ALSA channel 0 to JACK port
"system:playback_1" and "system:playback_3" and ALSA channel 1 to JACK
port "system:playback_2" and "system:playback_4":
pcm.jack {
type jack
playback_ports {
0 [ system:playback_1 system:playback_3 ]
1 [ system:playback_2 system:playback_4 ]
}
}
The old syntax with only one port for one channel is still supported:
playback_ports {
0 system:playback_1
1 system:playback_2
}
Without this patch an additional JACK client has to be used to
automatically connect the second JACK port but this could take some
time. Therefore it misses for example the first audio period on the
second port.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Laxmi Devi [Fri, 21 Dec 2018 09:29:42 +0000 (10:29 +0100)]
jack: Move jack_activate() and jack_connect() to snd_pcm_jack_prepare()
Since the processing of jack_activate() and jack_connect() take a while
longer, snd_pcm_jack_start() was blocked.
Consider a usecase of reading the data from capture device and
writing to a playback device, since the capture device is
already started and the starting of playback device is blocked,
it leads to XRUNs for capture device.
Therefore these calls are moved to snd_pcm_jack_prepare(),
So that the capture and playback devices can be prepared in advance so
that starting of the device doesn't take too long.
Andre Guedes [Sat, 8 Dec 2018 01:55:50 +0000 (17:55 -0800)]
aaf: AVTPDU transmission periodicity
When operating in playback mode (i.e. AVTP talker) the plugin is
expected to transmit the AVTPDUs in a periodical manner. The AVTPDU
period is defined by the number of audio frames per AVTPDU and the
sampling rate (see section 7.7 from AVTP spec [1] for further
information).
To enforce the AVTPDU periodicity, this patch leverages the SO_TXTIME
sockopt recently added to socket interface which enables the userspace
to specify when a given packet should be transmitted. The plugin
configures the transmission time from each AVTPDU so the expected
transmission interval is maintained.
The SO_TXTIME feature works in conjunction with the Earliest TxTime
First (ETF) qdisc. The ETF qdisc sorts packets from multiple sockets by
the earliest transmission time and sends them to the network controller.
It also enables offloading packet transmission to hardware in case the
NIC supports it, providing more time accuracy. For further information
about ETF qdisc, see tc-etf(8). The qdisc can be configured many ways,
in doc/aaf.txt we provide an example.
Below follows some implementation highlights:
The packet transmission time is configured through socket control
message interface so we now use sendmsg() to transmit AVTPDUs, instead
of sendto().
sendmsg() API requires a msghdr struct which is initialized during
device setup time. Strictly speaking, that struct is only required when
operating in playback mode but we initialize it always, no matter if
running in playback or capture mode. This makes hw_params() and
hw_free() callbacks implementation way more simpler, specially on
handling error cases.
[1] 1722-2016 - IEEE Standard for a Transport Protocol for Time-Sensitive
Applications in Bridged Local Area Networks
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Sat, 8 Dec 2018 01:55:49 +0000 (17:55 -0800)]
aaf: Tx multiple AVTPDUs per media clock tick
In order to implement the transmission offload mechanism, we need to
change the way the plugin behaves so, instead of sending only one
AVTPDU, it sends several AVTPDUs at every media clock tick.
To achieve that, this patch changes the plugin so it consumes the audio
buffer in chunks of period size instead of in frames_per_pdu. The number
of AVTPDUs sent at every media clock tick is calculated by dividing the
period size by the number of frames per AVTPDU. To ensure that number is
not fractional, the plugin requires that the period size is multiple of
the plugin configuration 'frames_per_pdu'.
For the sake of consistency, the capture mode is also changed so the
plugin presents audio frames to the alsa-lib layer in chunks of period
size as well.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Sat, 8 Dec 2018 01:55:48 +0000 (17:55 -0800)]
aaf: Refactor timeout routines
The functions aaf_mclk_timeout_playback() and aaf_mclk_timeout_capture()
have some common code so this patch does a code refactoring by moving
the shared code into a new function called aaf_timer_timeout().
After the refactoring, aaf_mclk_timeout_playback() and aaf_mclk_timeout_
capture() ended up having no code related to timeout so they were
renamed to better represent what they really do (send frames and present
frames, respectively).
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Sat, 8 Dec 2018 01:55:47 +0000 (17:55 -0800)]
aaf: Refactor AVTPDU reception routines
This patch does some code refactoring in the AVTPDU reception
routines in order to prepare the code to support the transmission
offload mechanism that will be added by upcoming patches. No
functionality is added or removed by this patch.
In summary, the function aaf_rx_pdu() is broken down into smaller, new
functions and some code is moved to is_pdu_valid(). Below follows more
details about the code refactoring.
The function aaf_rx_pdu() was renamed to aaf_socket_new_data() which
reads the socket and dispatches the AVTPDU in case the PCM device isn't
in DRAIN state. Function aaf_dispatch_pdu() simply reads the subtype
field from the AVTPDU and dispatches it according. For now, only AAF
PDUs are supported. Finally, the aaf_dispatch_pdu_aaf() handles AAF
AVTPDUs which means to check if the AVTPDU is valid, copies the PCM
samples from the payload to the audio buffer, and start the media clock
in case it hasn't been started already.
The function is_pdu_valid() is moved around to avoid forward
declaration. Code to validate the sequence number and presentation time
from the AVTPDU which used to be in aaf_rx_pdu() is moved into
is_pdu_valid().
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Sat, 8 Dec 2018 01:55:46 +0000 (17:55 -0800)]
aaf: Refactor AVTPDU transmission routines
This patch does some code refactoring in the AVTPDU transmission
routines in order to prepare the code to support the transmission
offload mechanism that will be added by upcoming patches. No
functionality is added or removed by this patch.
In summary, code from aaf_tx_pdu() is moved into aaf_mclk_timeout_
playback() and into a new function introduced by this patch called
aaf_tx_pdus(). Below follows more details about the code refactoring.
The function aaf_tx_pdu() is modified so it only takes care of setting
the payload, sequence number and presentation time from the AVTPDU, and
sending it to the kernel.
The new function aaf_tx_pdus() calculates the presentation time from
each AVTPDU and calls aaf_tx_pdu() multiple times, according to the pdu
count argument.
Finally, the function aaf_mclk_timeout_playback() now checks if there
are frames available to the "hardware" and takes care of moving the
hardware pointer forward.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Sat, 8 Dec 2018 01:55:45 +0000 (17:55 -0800)]
aaf: Add presentation time tolerance
Different AVTP applications have different presentation time tolerance.
The current version of the plugin doesn't support any tolerance so this
patch extends the AAF plugin in order to enable the user to configure
that tolerance value.
The presentation time tolerance is specified in microseconds and it is
relevant only when the plugin is operating in capture mode. For more
information see the 'Plugin Configuration' session in doc/aaf.txt
This patch also does some code refactoring and encapsulates all
presentation time validation code in the new is_ptime_valid() helper
function.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Andre Guedes [Thu, 25 Oct 2018 01:11:16 +0000 (18:11 -0700)]
aaf: Add support for direct read/write transfers
This patch adds support for direct read/write transfers (i.e. mmap
access mode) to the AAF plugin.
In order to enable direct read/write transfers, the AAF plugin is
required to implement ioplug's pseudo mmap mode. In this mode, the audio
buffer management (e.g. areas allocation, clean up, and data copy) is
handled at upper layers, making the AAF plugin simpler. So this patch
removes all code related to audio buffer management as well as the
transfer() callback from the AAF plugin.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Thu, 25 Oct 2018 01:11:14 +0000 (18:11 -0700)]
aaf: Implement Capture mode support
This patch implements the capture mode support from the AAF plugin.
Simply put, this mode works as follows: AVTPDUs are received from the
network, the PCM samples are retrieved and presented to the alsa-lib
layer at the presentation time. In summary, the capture mode implements
a typical AVTP Listener.
Once the AAF device is put in running state, packet reception is
started. Every time an AVTPDU is received, the plugin checks if it is
valid (according to the stream configuration provided by the user) and
copies the PCM samples to the audio buffer. Note that at this moment,
the samples are not presented to the alsa-lib layer yet (i.e. hw_ptr is
not incremented).
The media clock starts at the presentation time from the first AVTPDU.
At every tick from the media clock, PCM samples are presented to the
alsa-lib layer.
Below follows some secondary discussion about this patch:
The functions aaf_mclk_start_playback() and aaf_mclk_start_capture()
have some common code. This patch does some code refactoring so the
common code is put in a new function (aaf_mclk_start) which is called
by both aaf_mclk_start_playback() and aaf_mclk_start_capture().
Also, the helper function aaf_inc_hw_ptr() is refactored so it can be
used to increment both aaf->hw_ptr and aaf->hw_virt_ptr.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Thu, 25 Oct 2018 01:11:13 +0000 (18:11 -0700)]
aaf: Prepare for Capture mode support
The plugin code assumes only Playback mode is supported. This patch
prepares the code to support both Playback and Capture mode. Capture
mode support is implemented by a follow-up patch.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Thu, 25 Oct 2018 01:11:12 +0000 (18:11 -0700)]
aaf: Implement Playback mode support
This patch implements the playback mode support from the AAF plugin.
Simply put, this mode works as follows: PCM samples provided by alsa-lib
layer are encapsulated into AVTPDUs and transmitted through the network.
In summary, the playback mode implements a typical AVTP Talker.
When the AAF device is put in running state, its media clock is started.
At every tick from the media clock, audio frames are consumed from the
audio buffer, encapsulated into an AVTPDU, and transmitted to the
network. The presentation time from each AVTPDU is calculated taking in
consideration the maximum transit time and time uncertainty values
configured by the user.
Below follows some discussion about implementation details:
AVTP protocol doesn't support all formats and rates available in ALSA so
the plugin sets some constraints to ensure only supported configurations
are used (see aaf_set_hw_constraint function).
The plugin implements a media clock which is the source from AVTP
timestamps. The AVTP timestamp is based on PTP time which uses
International Atomic Time (TAI) coordinate system. The media clock is
implemented through a periodic timer using timerfd infrastructure so the
plugin requires that system clock and PTP clock are synchronized
(instructions on how to sync these clocks are provided in doc/aaf.txt).
CLOCK_TAI clockid isn't currently supported by timerfd so the timer fd
is created using CLOCK_REALTIME and the start time is converted from TAI
to UTC.
Even though only one file descriptor is used to implement the playback
mode, this patch doesn't leverage ioplug->poll_fd but defines poll
callbacks instead. The reason is these callbacks will be required to
support capture mode (to be implemented by upcoming patch).
The TSN data plane interface is the AF_PACKET socket family so the
plugin uses an AF_PACKET socket to send/receive AVTPDUs. Linux requires
CAP_NET_RAW capability in order to open an AF_PACKET socket so the
application that instantiates the plugin must have it. For further info
about AF_PACKET socket family see packet(7).
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Thu, 25 Oct 2018 01:11:11 +0000 (18:11 -0700)]
aaf: Load configuration parameters
This patch implements the infrastructure to load the plugin
configuration from ALSA configuration file. The configuration
is loaded in open() callback.
All configuration parameters are described in details in doc/aaf.txt
file.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Thu, 25 Oct 2018 01:11:10 +0000 (18:11 -0700)]
aaf: Introduce plugin skeleton
The patch introduces the skeleton code from the AAF plugin as well as
the buildsystem bits in order to get the plugin built. Following the
approach from other plugins, the AAF plugin is only built if its
dependency (libavtp) is detected by configure.
Follow-up patches implement support for both playback and capture modes.
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andre Guedes [Fri, 28 Sep 2018 21:27:27 +0000 (14:27 -0700)]
usb_stream: Fix leaks when us_set_hw_constraint() fails
If us_set_hw_constraint() returns error, we leak the 'us' object and all
the resources referenced by it. This patch fixes the issue by calling
us_free() before returning.
Andre Guedes [Fri, 28 Sep 2018 21:27:26 +0000 (14:27 -0700)]
oss: Fix leaks when oss_hw_constraint() fails
If oss_hw_constraint() returns error, we leak 'oss' object and all the
resources referenced by it. This patch fixes the issue by jumping to
'error' label where the proper clean up is already done.
Andre Guedes [Fri, 28 Sep 2018 21:27:25 +0000 (14:27 -0700)]
jack: Fix leaks when jack_set_hw_constraint() fails
If jack_set_hw_constraint() returns error, we leak the 'jack' object and
all the resources referenced by it. This patch fixes the issue by
calling snd_pcm_jack_free() before returning.
Andre Guedes [Fri, 28 Sep 2018 21:27:24 +0000 (14:27 -0700)]
a52: Fix leaks when a52_set_hw_constraint() fails
If a52_set_hw_constraint() returns error, we leak 'rec' and
'rec->slave'. This patch fixes the issue by jumping to 'error' label
where the proper clean up is already done.
jack: Only allow ALSA periods multiple of JACKd period
There is a higher Xrun probability whenever the ALSA period is not a
multiple of the JACKd period and the ALSA buffer is only twice the period.
Allowing ALSA buffers of min. 3x period is not a good solution because this
would increase the latency.
As an example in case of ALSA is using a period of 11 frames and JACK a
period of 12 frames and a buffer of 22 frames (2x ALSA period) is used:
- The buffer is filled and contains 22 frames
- JACK is reading 12 frames. Buffer is only containing 10 frames
- Now, ALSA has to be scheduled exactly after the last JACK read and
before the next read. Otherwise we will get an Xrun
In case of ALSA is using a multiple period of JACK, JACK can always read
2 periods before an Xrun if the buffer was full.
In case of ALSA is using a period of 12 frames and JACK a period of 11
frames and a buffer of 24 frames (2x ALSA period) is used:
- The buffer is filled and contains 24 frames
- JACK is reading 11 frames. Buffer is now containing 13 frames. But ALSA
can still not write to the buffer
- JACK reads 11 additional frames. Buffer contains 2 frames
- Now, ALSA has to be scheduled exactly after the last JACK read and
before the next read. Otherwise we will get an Xrun
In case of ALSA is using a multiple period of JACK, ALSA can always write
to the buffer as long as the buffer is filled with less or equal of half
of buffer.
Therefore this patch enforces an ALSA period which is always a multiple
of the JACKd period.
Timo Wischer [Tue, 3 Jul 2018 13:59:23 +0000 (15:59 +0200)]
jack: Update poll_fd also in draining state
... to support snd_pcm_drain for the JACK IO plugin.
With this changes there will be an poll_fd event in DRAINING state even if
the min_avail was not yet reached. Otherwise the application would never
recognize that all samples were processed by JACK.
In addition the JACK real-time thread is also processing when in DRAINING
state and not only when in RUNNING or PREPARE state.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Timo Wischer [Tue, 3 Jul 2018 13:59:22 +0000 (15:59 +0200)]
jack: Avoid call to snd_pcm_avail_update() from JACK thread
snd_pcm_avail_update() can call snd_pcm_jack_stop() but
snd_pcm_jack_stop() should not be called by the JACK thread.
It should only be called by the thread how has called
snd_pcm_jack_start().
In addition the execution of snd_pcm_avail_update() can take a while.
Therefore it should not be called by the JACK thread to not block this
thread.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jaroslav Kysela [Mon, 16 Apr 2018 14:24:29 +0000 (16:24 +0200)]
Move rate-lavc to rate-lav subdirectory and update to use libavresample
- --disable-avcodec renamed to --disable-libav
- --avcodec-includedir renamed to --libav-includedir
- --avcodec-libdir renamed to --libav-libdir
- --disable-lavcrate renamed to --disable-lavrate
The .c changes are from Anton Khirnov. The rest is from Jaroslav Kysela.
From: Anton Khirnov Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Timo Wischer [Fri, 16 Mar 2018 14:23:32 +0000 (15:23 +0100)]
jack: Report Xruns to user application
Only increasing the hw_ptr is not sufficient
because it will not be evaluated by the ALSA library
to detect an Xrun.
In addition there is a raise where an Xrun detected by the JACK thread
could not be detected in the ALSA thread.
- In playback use case
- The hw_ptr will be increased by the JACK thread
(hw_ptr > appl_ptr => Xrun)
- But the ALSA thread increases the appl_ptr before evaluating the
hw_ptr
- Therefore the hw_ptr < appl_ptr again
- ALSA will not detect the Xrun which was already detected by the
JACK thread
Therefore an additional variable is required to report an Xrun from the
JACK thread to ALSA.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Timo Wischer [Tue, 13 Mar 2018 08:34:44 +0000 (09:34 +0100)]
jack: Do not Xrun the ALSA buffer
when the JACK thread is requesting too many audio frames
Playback:
Without this commit the ALSA audio buffer will be played with endless
repeats as long as the user application has not provided new audio data.
Therefore this garbage will be played as long as the user application has
not called snd_pcm_stop() after an Xrun. With this fix the rest of the
JACK buffer will be filled with silence.
Capture:
Without this commit the audio data in the ALSA buffer would be
overwritten. With this commit the new data from the JACK buffer will not
be copied. Therefore the existing data in the ALSA buffer will not be
overwritten.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Timo Wischer [Fri, 23 Feb 2018 14:18:08 +0000 (15:18 +0100)]
jack: Use boundary as hw_ptr wrap around
instead of using buffer_size as wrap around.
This is required to detect Xruns.
It is also required to allow the JACK thread
to processes the whole ALSA audio buffer at once
without calling snd_pcm_avail_update() in between.
For example when the hw_ptr will be updated with
hw_ptr += buffer_size
and it is using the buffer_size as wrap around
hw_ptr %= buffer_size
would result in the same value as before the add operation.
Due to that the user application would not recognize
that the complete audio buffer was copied.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Kui Wang [Thu, 13 Jul 2017 19:33:05 +0000 (19:33 +0000)]
pulse: prevent double-free when pulse_hw_constraint returns error
When pulse_hw_constraint returns error, snd_pcm_ioplug_delete() is called.
It will then call pulse_close() where "snd_pcm_pulse_t *pcm" will be free.
Then if goto the "error" label, the "snd_pcm_pulse_t *pcm" will be double-free.
To prevent this, just jump over the code which might cause double-free.
Signed-off-by: Kui Wang <wangkuisuper@hotmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Daniel Kirchner [Wed, 9 Mar 2016 08:17:09 +0000 (09:17 +0100)]
a52: Fix usage of obsoleted avcodec_*_frame() functions
pcm_a52.c uses avcodec_alloc_frame and avcodec_free_frame that have
been replaced by av_frame_alloc and av_frame_free in recent versions
of libavcodec. The following patch should fix this while remaining
backwards compatible.
Tanu Kaskinen [Wed, 27 Jan 2016 11:45:51 +0000 (13:45 +0200)]
pph: include config.h from rate_speexrate.c
Fixes compilation against libspeexdsp 1.2rc3.
rate_speexrate.c includes speex_resampler.h, which depends on config.h
by referencing the HAVE_SPEEX_SPEEXDSP_TYPES_H macro. AFAIK it's not
a good idea to include config.h from headers (I don't know/remember
why, though), which is why I include config.h from rate_speexrate.c
instead of speex_resampler.h.
Tom Yan [Tue, 12 Jan 2016 07:57:39 +0000 (15:57 +0800)]
a52: fix reported input channel order
a52 plugin expects the input to be in ALSA order and remaps it to general order when encoding. However it reports that the input it takes should be in general order.
This fix should make programs (e.g. mpv) that is aware of channel layout reported by ALSA remap sources appropriately before sending when necessary.
It should not cause any regression to programs (e.g. mplayer) that does not check the reported channel layout (hence not affected by the issue) and remaps sources anyway.
Signed-off-by: Tom Yan <tom.ty89@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>