pcm: avoid calling pcm_hw->close() twice

It would result in a double free:

  $ tinyplay example.wav
  failed to open for pcm 0,0
  *** glibc detected *** ./utils/tinyplay: double free or corruption (fasttop): 0x402dc258 ***
  Aborted
  $

The crash happens here:

  Program received signal SIGABRT, Aborted.
  0x40070e78 in raise () from /lib/libc.so.6
  Missing separate debuginfos, use: debuginfo-install glibc-2.16-34.olpc.0.fc18.armv7hl libgcc-4.7.2-8.fc18.armv7hl
  (gdb) bt
  #0  0x40070e78 in raise () from /lib/libc.so.6
  #1  0x400724b8 in abort () from /lib/libc.so.6
  #2  0x400ad6e0 in ?? () from /lib/libc.so.6
  #3  0x400b54e8 in ?? () from /lib/libc.so.6
  #4  0x2a00486c in pcm_hw_close ()
  #5  0x2a0032e0 in pcm_close ()
  #6  0x2a0016b0 in ctx_init ()
  #7  0x2a000c98 in main ()
  (gdb)

The previous free was done here:

  Breakpoint 1, 0x400b8b8c in free () from /lib/libc.so.6
  (gdb) bt
  #0  0x400b8b8c in free () from /lib/libc.so.6
  #1  0x2a00486c in pcm_hw_close ()
  #2  0x2a003674 in pcm_open ()
  #3  0x2a0015e8 in ctx_init ()
  #4  0x2a000c98 in main ()
  (gdb)
1 file changed
tree: 55a6884f9a7017ce029a7fe6159c23f974ac66eb
  1. debian/
  2. doxygen/
  3. examples/
  4. include/
  5. scripts/
  6. src/
  7. utils/
  8. .gitignore
  9. .travis.yml
  10. Android.bp
  11. CMakeLists.txt
  12. Makefile
  13. meson.build
  14. meson_options.txt
  15. NOTICE
  16. README.md
README.md

TinyALSA

Build Status

TinyALSA is a small library to interface with ALSA in the Linux kernel.

The aims are:

  • Provide a basic pcm and mixer API.
  • If it's not absolutely needed, don't add it to the API.
  • Avoid supporting complex and unnecessary operations, that could be dealt with at a higher level.
  • Provide comprehensive documentation.

Building

TinyALSA uses Makefile as the primary build system.

To build and install with Make, run the commands:

make
sudo make install
sudo ldconfig

Installing

TinyALSA is now available as a set of the following debian packages from launchpad:

Package Name:Description:
tinyalsaContains tinyplay, tinycap, tinymix and tinypcminfo
libtinyalsaContains the shared library
libtinyalsa-devContains the static library and header files

To install these packages, run the commands:

sudo apt-add-repository ppa:taylorcholberton/tinyalsa
sudo apt-get update
sudo apt-get install tinyalsa
sudo apt-get install libtinyalsa-dev

Documentation

Once installed, the man pages are available via:

man tinyplay
man tinycap
man tinymix
man tinypcminfo
man libtinyalsa-pcm
man libtinyalsa-mixer