Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALSA backend: Multi ALSA device support #608

Open
wants to merge 42 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bb0fcf0
posix: fifo: use right prototype
May 7, 2019
c811168
posix: socket: Add missing time header include
May 7, 2019
e064932
Add QNX platform specific implementations
May 7, 2019
d86d2be
AudioAdapter: Use empty Adapter also for QNX
May 7, 2019
8521b98
qnx: sigaction: do not set SA_RESTART flag
May 7, 2019
5dfc216
qnx: shm: Include right header
May 7, 2019
012fe02
shm: Add semget() and semop() replacement for QNX
May 22, 2019
7bed71c
alsa: Extract snd_pcm_start/poll_descriptors/avail_update
Sep 6, 2019
71ecea6
alsa backend for qnx
Feb 4, 2020
8e8ae8e
alsa: Simplify get state on linux
Oct 15, 2019
fc1d6a5
Support QNX build with WAF
May 7, 2019
831f4e6
Workaround: JackClient: Fix printf NULL issue
DeviLaxmii Jan 20, 2020
92911ea
alsa: Add multi dev support
Sep 23, 2019
eb0739d
jack: alsa_driver: add check alsa_driver_poll_descriptor
kapildevpatel Feb 7, 2020
1ef6fb9
JackRequest: Add missing comma
Sep 27, 2019
4ed6112
jack common: add api jack_client_reload_master
Sep 27, 2019
521874d
jack alsa: introduce alsa_driver_info_t [2/2]
Oct 2, 2019
78e97af
jack alsa: implement restart request [1/3]
Oct 1, 2019
b88a85a
jack alsa: implement restart request [2/3]
Oct 1, 2019
418f4ed
jack alsa: implement restart request [3/3]
Oct 1, 2019
f45f3cc
jack alsa: move linking functionality to separate function
Oct 16, 2019
316aee4
jack alsa: do not return early
Oct 17, 2019
3de4858
jack alsa: add array_string_t flags
Sep 30, 2019
9a25d22
jack alsa: reoganize code for readability
Sep 30, 2019
99bb68b
jack alsa: implement ALSA_DRIVER_FEAT_START_CLOSED
Oct 2, 2019
9a3bdd6
jack alsa: reintroduce special hardware handling
Oct 2, 2019
27a676c
jack alsa: reformat to allow easier managing of priorities
Oct 16, 2019
e994144
jack alsa: add DriverMode as enum
Oct 17, 2019
eb17137
jack alsa: add shutdown mode of operation
Oct 16, 2019
950497d
jack alsa: optimize operation of reload request
Oct 16, 2019
4d60f5b
jack alsa: rework 'x' and 'c' options
Jan 2, 2020
cdddc81
alsa_driver: remove additional delete to avoid double free
Jan 14, 2020
104ca04
QTISA-195 alsa: qnx call plugin flush for every device separately
Feb 20, 2020
894ca0c
alsa: rework error reporting from alsa_driver_wait
Feb 7, 2020
0187cf6
QTISA-183 alsa: add more logs improve debugging
Feb 20, 2020
3fb9fec
QTISA-183 alsa: make alsa_driver_xrun_recovery global
Feb 21, 2020
604c485
QTISA-183 alsa: remove recovery from alsa_driver_wait
Feb 21, 2020
ee274e7
QTISA-183 audio: implement retry for failed read write
Feb 25, 2020
b5ede1c
QTISA-183 alsa: allow recovery for read and write
Feb 25, 2020
eaca20d
QTISA-188 alsa: fix implementation for shorts_first
Feb 26, 2020
0e95738
QTISA-188 alsa: modify sample rate only when device was opened
Feb 26, 2020
a154717
example: Add client for reloading the master
Mar 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
QTISA-183 alsa: remove recovery from alsa_driver_wait
upper layer will be responsible for handling recovery

Change-Id: I507df2976ae569b4953a16e6e334ae5f9c78b59f
Signed-off-by: Adam Miartus <[email protected]>
(cherry picked from commit aff8dd6e215df7023918dc47264da70b3252ad91)
Signed-off-by: Timo Wischer <[email protected]>
  • Loading branch information
Adam Miartus authored and Timo Wischer committed Jun 30, 2020
commit 604c4859efb745d6575a0abefe6e177ff93aeeb8
41 changes: 16 additions & 25 deletions linux/alsa/alsa_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ char* strcasestr(const char* haystack, const char* needle);

/* Delay (in process calls) before jackd will report an xrun */
#define XRUN_REPORT_DELAY 0
/* Max re-try count for Alsa poll timeout handling */
#define MAX_RETRY_COUNT 5

#ifdef __QNXNTO__

Expand Down Expand Up @@ -2108,7 +2106,6 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
snd_pcm_sframes_t avail = 0;
snd_pcm_sframes_t capture_avail = 0;
snd_pcm_sframes_t playback_avail = 0;
int retry_cnt = 0;
jack_time_t poll_enter;
jack_time_t poll_ret = 0;

Expand Down Expand Up @@ -2177,7 +2174,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
/* In case of xrun -EPIPE is returned perform xrun recovery*/
if (pfd_cap_count[i] == -EPIPE) {
jack_error("poll descriptors xrun C: %s pfd_cap_count[%d]=%d", device->capture_name, i, pfd_cap_count[i]);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
}
/* for any other error return negative wait status to caller */
jack_error("poll descriptors error C: %s pfd_cap_count[%d]=%d", device->capture_name, i, pfd_cap_count[i]);
Expand Down Expand Up @@ -2212,7 +2210,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
/* In case of xrun -EPIPE is returned perform xrun recovery*/
if (pfd_cap_count[i] == -EPIPE) {
jack_error("poll descriptors xrun P: %s pfd_cap_count[%d]=%d", device->playback_name, i, pfd_play_count[i]);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
}
/* for any other error return negative wait status to caller */
jack_error("poll descriptors error P: %s pfd_cap_count[%d]=%d", device->playback_name, i, pfd_play_count[i]);
Expand Down Expand Up @@ -2272,18 +2271,9 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
poll_ret = jack_get_microseconds ();

if (poll_result == 0) {
retry_cnt++;
if(retry_cnt > MAX_RETRY_COUNT) {
jack_error ("ALSA: poll time out, polled for %" PRIu64
" usecs, Reached max retry cnt = %d, Exiting",
poll_ret - poll_enter, MAX_RETRY_COUNT);
*status = ALSA_DRIVER_WAIT_ERROR;
return 0;
}

jack_error ("ALSA: poll time out, polled for %" PRIu64
" usecs, Retrying with a recovery, retry cnt = %d",
poll_ret - poll_enter, retry_cnt);
" usecs, Retrying with a recovery",
poll_ret - poll_enter);
for (int i = 0; i < driver->devices_count; ++i) {
if (driver->devices[i].capture_handle && i < driver->devices_c_count && cap_revents[i] == 0) {
jack_log("device C: %s poll was requested", driver->devices[i].capture_name);
Expand All @@ -2292,7 +2282,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
jack_log("device P: %s poll was requested", driver->devices[i].playback_name);
}
}
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
}

// JACK2
Expand Down Expand Up @@ -2353,7 +2344,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
if (collect_revs & POLLERR) {
/* optimization, no point in polling more if we already have xrun on one device */
jack_error ("xrun C: '%s'", device->capture_name);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
}
if (collect_revs & POLLIN) {
}
Expand Down Expand Up @@ -2391,7 +2383,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
if (collect_revs & POLLERR) {
/* optimization, no point in polling more if we already have xrun on one device */
jack_error ("xrun P: '%s'", device->playback_name);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
}
if (collect_revs & POLLNVAL) {
jack_error ("ALSA: playback device disconnected");
Expand Down Expand Up @@ -2429,7 +2422,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
if ((avail = alsa_driver_avail (driver, device->capture_handle, SND_PCM_STREAM_CAPTURE)) < 0) {
if (avail == -EPIPE) {
jack_error ("ALSA: avail_update xrun on capture dev '%s'", device->capture_name);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
} else {
jack_error ("unknown ALSA avail_update return value (%u)", capture_avail);
}
Expand All @@ -2454,7 +2448,8 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
if ((avail = alsa_driver_avail (driver, device->playback_handle, SND_PCM_STREAM_PLAYBACK)) < 0) {
if (avail == -EPIPE) {
jack_error ("ALSA: avail_update xrun on playback dev '%s'", device->playback_name);
goto xrun;
*status = ALSA_DRIVER_WAIT_XRUN;
return 0;
} else {
jack_error ("unknown ALSA avail_update return value (%u)", playback_avail);
}
Expand Down Expand Up @@ -2492,10 +2487,6 @@ alsa_driver_wait (alsa_driver_t *driver, int extra_fd, alsa_driver_wait_status_t
*/

return avail - (avail % driver->frames_per_cycle);

xrun:
*status = (alsa_driver_xrun_recovery (driver, delayed_usecs) == 0) ? ALSA_DRIVER_WAIT_XRUN : ALSA_DRIVER_WAIT_ERROR;
return 0;
}

int
Expand Down