aboutsummaryrefslogtreecommitdiff
path: root/src/pcm.c
AgeCommit message (Collapse)Author
2020-02-11Merge pull request #137 from codeauroraforum/plugin-supportTaylor Holberton
Plugin support
2020-02-07tinyalsa: add support for PCM pluginsBhalchandra Gajare
Update the pcm framework to support plugins. Resolve the pcm device node to be either kernel device or virtual device and setup function pointers accordingly. Implement framework functionality for pcm_plugin.c for ease of plugin development. Plugin itself is compiled as shared object (.so) and dynamically linked from pcm_plugin.c. Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org> Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
2020-02-06pcm: Set SW params.avail_min to period sizeMiguel GAIO
Using MMAP APIs, this parameter wake up application when 'avail_min' samples are availables. When audio processing expects exactly a full period size samples, the default parameter to 1 burns CPU until the full period available. Fix SW params.avail parameter to period size value. Signed-off-by: Miguel GAIO <mgaio35@gmail.com>
2019-04-24pcm: Allow to wait if capture is not runningRicardo Biehl Pasquali
This allows starting capture from another thread. See the commit 932a81519572 ("ALSA: pcm: Comment why read blocks when PCM is not running") in Linux kernel. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-04-12pcm: Remove setting unnecessary parametersRicardo Biehl Pasquali
SUBFORMAT is always zero. SAMPLE_BITS and FRAME_BITS are refined by ALSA based on the already set FORMAT and CHANNELS. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Check for error after setting appl_ptrRicardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Cleanup control/status when setup failsRicardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Replace 'underruns' with 'xruns'Ricardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Create generic transferRicardo Biehl Pasquali
Group read/write transfer into pcm_rw_transfer(). Create pcm_generic_transfer() for read/write and mmap transfer modes. This recovers from xrun and suspended. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Put transfer functions togetherRicardo Biehl Pasquali
A generic transfer function will be created. Put together functions related to it. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove 'running' variable from pcm structureRicardo Biehl Pasquali
It is not needed. As the pcm structure is opaque to user it can be safely removed. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Rewrite pcm_mmap_transfer() for compatibilityRicardo Biehl Pasquali
Make pcm_mmap_transfer() compatible with read/write IO. start_threshold check was not valid for capture. pcm->running checks were removed. NOIRQ fallback was removed. Clocks of sound devices may differ from the system, leading to desynchronization. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Exit loop when there are no available framesRicardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Put mmap functions togetherRicardo Biehl Pasquali
pcm_mmap_transfer() will be rewritten. Put together functions related to mmap transfer. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Rewrite pcm_get_htimestamp()Ricardo Biehl Pasquali
Use pcm_avail_update(), check avail for timestamp coherence. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Move pcm_get_htimestamp()Ricardo Biehl Pasquali
pcm_get_htimestamp() will be rewritten. Place it after pcm_avail_update(), which will be used in the rewrite. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Get values from kernel in avail_updateRicardo Biehl Pasquali
Instead of sending appl_ptr and avail_min to the kernel, get them. This is the behavior of alsa-lib. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Call HWSYNC ioctl when status is mmapedRicardo Biehl Pasquali
When hardware pointer update is requested and status structure is mmaped, call HWSYNC ioctl. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove HWSYNC before available calculationRicardo Biehl Pasquali
Hardware pointer should not be updated in available calculation. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Do not set values after control/status mmapRicardo Biehl Pasquali
It's not necessary to send appl_ptr or avail_min to the kernel here. In prepare action, called later in pcm_open(), appl_ptr becomes zero. avail_min is already defined in software parameters. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Get appl_ptr and avail_min after prepareRicardo Biehl Pasquali
appl_ptr becomes zero in prepare action. avail_min is the same as when it was set in software parameters. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove 'prepared' variable from pcm structureRicardo Biehl Pasquali
It is not needed. As the pcm structure is opaque to user it can be safely removed. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove prepare before startRicardo Biehl Pasquali
Prepare is done in pcm_open(). Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove start before readRicardo Biehl Pasquali
Start is done by kernel when start_threshold or more frames are requested. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Prepare after overrunRicardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Remove code assuming start after writeRicardo Biehl Pasquali
The state cannot be assumed as RUNNING after a write because start_threshold may not have elapsed. Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Move prepare action to xrun handlingRicardo Biehl Pasquali
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2019-01-08pcm: Do prepare action in pcm_open()Ricardo Biehl Pasquali
This eliminates the need for prepare in transfer functions and pcm_start(). Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
2018-11-28Added ifndef around macrosTaylor Holberton
2018-11-28Checking for definition of __bitwise, __force, __userTaylor Holberton
2018-07-17Fixed pcm_start when pcm is linked to other pcm deviceMiguel Gaio
When pcm device is linked to other pcm device, the start call may be triggered by other pcm device. Handle this condition by checing pcm state before start call. Signed-off-by: Miguel Gaio <mgaio35@gmail.com>
2018-07-17Corrected pcm_sync_ptr() on dma mmap coherent architectureMiguel Gaio
It is valid to get null sync_ptr on dma mmap coherent architecture. In this case pcm_sync_ptr() is a nop. Signed-off-by: Miguel Gaio <mgaio35@gmail.com>
2018-04-10Fix pcm_writei return value if pcm is in not running state.Miguel GAIO
As per comment, on success, pcm_writei returns the number of frames written. Fix the case of pcm not running. Signed-off-by: Miguel GAIO <mgaio35@gmail.com>
2017-10-12added PCM_NONBLOCK macroTaylor Holberton
2017-04-10adding bounds check only when neededTaylor Holberton
2017-04-10moved code in pcm_open() to pcm_set_config()Taylor Holberton
2017-04-10removed tab charactersTaylor Holberton
2017-04-10added pcm_get_config()Taylor Holberton
2017-04-06simplified pcm_read() and pcm_write()Taylor Holberton
2017-04-06checking limits of frame countsTaylor Holberton
2017-04-06removed debug statementTaylor Holberton
2017-01-13added doc on pcm_open and null checking pcm_is_readyTaylor Holberton
2016-12-24Added pcm_open_by_name()Taylor Holberton
This function parses a PCM name similar to the ALSA library. This is done so that the differences between alsa-lib and tinyalsa are a little more transparent to the user.
2016-12-04Added pcm_link and pcm_unlink functionsTaylor Holberton
The link function is necessary for time sychronization between multiple PCMs.
2016-12-01renamed parameter in docTaylor Holberton
2016-12-01Using frame counts in pcm_readi and pcm_writeiTaylor Holberton
pcm_readi and pcm_writei now use a frame count to specify the buffer length instead of using a byte count.
2016-12-01Added pcm_readi and pcm_writei functionsTaylor Holberton
Added these functions to replace pcm_read and pcm_write, which don't return the number of frames actually transferred. On GCC-like compilers, pcm_read and pcm_write have been marked as deprecated On doxygen documentation, they have been marked as deprecated as well.
2016-12-01Added format related getters for PCMTaylor Holberton
Added functions: - pcm_get_channels - pcm_get_rate - pcm_get_format These were added since they're required for iterating samples and frames.
2016-12-01Added const specifier in several functionsTaylor Holberton
pcm_get_file_descriptor pcm_get_error pcm_get_buffer_size pcm_frames_to_bytes pcm_bytes_to_frames pcm_get_subdevice
2016-12-01added const specifier in function, pcm_is_readyTaylor Holberton