Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9294379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:21:30+00:00 2026-06-18T21:21:30+00:00

I have a device that is continuously putting out PCM data. Under certain circumstances

  • 0

I have a device that is continuously putting out PCM data. Under certain circumstances I want to record this output. To this end I have a process that waits for the signal to record and when it gets it, it starts a thread (via pthread_create). This thread opens the PCM device and starts recording using snd_async_add_pcm_handler. This handler fn uses pcm_readi to get any available info in the PCM stream and write it to disk.

All well and good – except

Once this starts running my calling process stops getting any cycles. It should be continuing to listen for the next event that would signal to stop recording. Watching the execution I see it slow and then halt once the PCM recording starts. If I don’t start the recording the app runs normally and continues to respond.

So it seems like I’m left with two avenues:

  1. find gaps in the recording process and usleep (or similar) to give the calling app time to respond
  2. attempt to exit the recording using other means

I’ve failed to make any headway using #1 so I’m working on #2. It’s known that the audio sample will start with low amplitude, go high for a second or two and then go low again. I’m using a rolling average to trap this low-high-low and am attempting to close the async IO.

Where it stands: Once the IO is supposed to be stopped I’ve tried calling snd_async_del_handler but this crashes the app with a simple ‘IO possible’ message. I’ve also tried calling snd_pcm_drop but this doesn’t close the async io so it crashes the next time it tries to read. Combining the two in either order gives similar responses.

What step(s) have I missed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:21:31+00:00Added an answer on June 18, 2026 at 9:21 pm

    The snd_async_* functions are strongly deprecated, because they don’t work with all kinds of devices, are hard to use, and don’t have any advantages in practice.

    Please note that the ALSA API is not thread safe, i.e., calls for one PCM device must all be from one thread, or synchronized.

    What you should do is to have an event loop (using poll) in your thread that handles both the PCM device and the exit message from the main thread.
    For this, the PCM device should be run in non-blocking mode (using the snd_pcm_poll_descriptors* functions).
    To send a message to the thread, use any mechanism with a pollable file handle, such as a pipe or eventfd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an external device that spits out UDP packets of binary data and
I created the list that have device detected, and I want to send data
I have a device that continuously collects data and stores it on a local
I have this device that sends XML data to a webserver in format as
I have a device that sends data to COM port. And I'd like to
I am developing a device that will continuously collect data from a PLC and
I have a device that records GPS data. A reading is taken every 2-10
I have a device that continually outputs data and I would like to send
So here is the story. I have this device that uses Linux and more
We have a device that uses Exchange web services to download mail and calendar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.