diff options
author | vivek mehta <mvivek@codeaurora.org> | 2016-07-15 13:12:52 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2016-07-29 00:43:31 +0000 |
commit | 51f47ff38e553ecb1823e44c47315c41e408ca27 (patch) | |
tree | 38f669fe09ec65532fffb00a5507ae273b4ba066 | |
parent | f25a2bf2de97ba15dcbeed2eb0b635f63a3f13dc (diff) | |
download | tinyalsa-nougat-mr1-cts-release.tar.gz |
tinyalsa: pcm: open pcm driver in non blocking modeandroid-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1nougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-dr1-release
- in current implementation pcm open call is blocking hence if pcm_open
is done on same driver twice second pcm open will get blocked till
first instance of the PCM driver is not released.
In times this will result in deadlock.
- fix this issue by making PCM open in non-blocking mode.
- after pcm open is successful, in non-blocking mode, change the device
mode to blocking again to make sure rest of the operation on the
driver, like read / write calls, are always called in blocking mode.
Also fix jump to wrong label in case of failure before mmap().
Bug: 29865791
Bug: 30388410
Change-Id: I95c0ad8456e6c2bb3bfb48813e1db75cdef387f8
-rw-r--r-- | pcm.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -855,12 +855,18 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, flags & PCM_IN ? 'c' : 'p'); pcm->flags = flags; - pcm->fd = open(fn, O_RDWR); + pcm->fd = open(fn, O_RDWR|O_NONBLOCK); if (pcm->fd < 0) { oops(pcm, errno, "cannot open device '%s'", fn); return pcm; } + if (fcntl(pcm->fd, F_SETFL, fcntl(pcm->fd, F_GETFL) & + ~O_NONBLOCK) < 0) { + oops(pcm, errno, "failed to reset blocking mode '%s'", fn); + goto fail_close; + } + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) { oops(pcm, errno, "cannot get info"); goto fail_close; @@ -884,7 +890,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, if (flags & PCM_NOIRQ) { if (!(flags & PCM_MMAP)) { oops(pcm, -EINVAL, "noirq only currently supported with mmap()."); - goto fail; + goto fail_close; } params.flags |= SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP; |