All of lore.kernel.org
 help / color / mirror / Atom feed
* arecord stops capturing data when streaming to stdout after max wav file size data processed
@ 2017-12-15 17:31 sam detweiler
  0 siblings, 0 replies; only message in thread
From: sam detweiler @ 2017-12-15 17:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: evanbtcohen

The github smart-mirror project uses arecord on pi devices to capture user
audio. This is a long running application, 

(I expect my mirror to be on 24/7)

 

Anyhow, after 18 hours, we stop receiving audio data. 

 

 

I have debugged it to the capture routine in aplay.c

 

Basically it is not intended to run forever. 

 

                rest = count;  <---- get the remaining size from the count
total size

                                // don't let the remaining data size be too
big

                                if (rest >
fmt_rec_table[file_type].max_filesize)

                                                rest =
fmt_rec_table[file_type].max_filesize;

                                if (max_file_size && (rest > max_file_size))


                                                rest = max_file_size;

 

                                write the 'file'  header

                                /* setup sample header */

                                if (fmt_rec_table[file_type].start)

 
fmt_rec_table[file_type].start(fd, rest);

 

                                /* capture */

                                fdcount = 0;

                                while (rest > 0 && recycle_capture_file == 0
&& !in_aborting) {

                                                size_t c = (rest <=
(off64_t)chunk_bytes) ?

                                                                (size_t)rest
: chunk_bytes;

                                                size_t f = c * 8 /
bits_per_frame;

                                                if (pcm_read(audiobuf, f) !=
f) {

                                                                in_aborting
= 1;

                                                                break;

                                                }

                                                if (xwrite(fd, audiobuf, c)
!= c) {

 
perror(name);

                                                                in_aborting
= 1;

                                                                break;

                                                }

                                                count -= c; <--- decrement
the file size 

                                                rest -= c;  <---- decement
the remaining data

                                                fdcount += c;

                                }

 

                                Eventually rest AND count will be 0 or less
than 0 (for wav this is 2 gig).

                                Then we loop back up, start another file,
and then while rest >0, it is not any longer

                                Then we loop, and write a new file header,
and then rest <0, so no data capture..

                                                

                                If this is stdout, we should NOT decrement
the rest and size counters.. but let the timelimit and sample limit stop the
outer loop

 

                                while ((file_type == FORMAT_RAW &&
!timelimit && !sampleslimit) || count > 0);

 

so my proposed change is 

 

                                                /* capture */

                                fdcount = 0;

                                while (rest > 0 && recycle_capture_file == 0
&& !in_aborting) {

                                                size_t c = (rest <=
(off64_t)chunk_bytes) ?

                                                                (size_t)rest
: chunk_bytes;

                                                size_t f = c * 8 /
bits_per_frame;

                                                if (pcm_read(audiobuf, f) !=
f) {

                                                                in_aborting
= 1;

                                                                break;

                                                }

                                                if (xwrite(fd, audiobuf, c)
!= c) {

 
perror(name);

                                                                in_aborting
= 1;

                                                                break;

                                                }

                                                If(!stdout){
<---- add this test

                                                                count -= c;
<--- decrement the file size 

                                                                rest -= c;
<---- decement the remaining data

                                                                fdcount +=
c;

                                                }

                                }

 

 

Sam

 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-15 17:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-15 17:31 arecord stops capturing data when streaming to stdout after max wav file size data processed sam detweiler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.