diff options
author | Anish Kumar <kanish@codeaurora.org> | 2014-04-09 12:58:17 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2014-11-04 08:45:03 -0700 |
commit | b8b375adf8b220d03c2cdd72fefd2d371b72d854 (patch) | |
tree | 9fb5297056c181ae3410344688aa5443c035f4c3 | |
parent | 8863816dc5659a1e4678d17906c90844264d1588 (diff) | |
download | android_external_tinyalsa-stable/cm-12.0-YNG1TA.tar.gz android_external_tinyalsa-stable/cm-12.0-YNG1TA.tar.bz2 android_external_tinyalsa-stable/cm-12.0-YNG1TA.zip |
tinyplay: Fix pop issue at the end of playback.staging/cm-12.0-cafstable/cm-12.0-YNG4Nstable/cm-12.0-YNG3Cstable/cm-12.0-YNG1TAstable/cm-12.0-YNG1Tstable/cm-12.0-YNG1Icm-12.0
Pop issue is observed at the end of playback for certain contents.
Wave file format data description header contains actual size
of sound data included in the data section. Use this data size
information for processing actual raw bytes, which avoids reading
extra bytes and avoids pop issue.
Change-Id: I71b881ec7d7b5e1fc688d54061751e6f4527bcc5
CRs-fixed: 613569
-rw-r--r-- | tinyplay.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -59,6 +59,7 @@ struct chunk_fmt { }; static int close = 0; +static int data_sz = 0; void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, unsigned int rate, unsigned int bits, unsigned int period_size, @@ -117,6 +118,7 @@ int main(int argc, char **argv) break; case ID_DATA: /* Stop looking for chunks */ + data_sz = chunk_header.sz; more_chunks = 0; break; default: @@ -217,6 +219,7 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in char *buffer; int size; int num_read; + int remaining_data; config.channels = channels; config.rate = rate; @@ -250,6 +253,8 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in return; } + remaining_data = data_sz; + printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits); /* catch ctrl-c to shutdown cleanly */ @@ -262,8 +267,13 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in fprintf(stderr, "Error playing sample\n"); break; } + if (remaining_data) { + remaining_data -= size; + if (remaining_data < size) + size = remaining_data; + } } - } while (!close && num_read > 0); + } while (!close && num_read > 0 && !(remaining_data <= 0)); free(buffer); pcm_close(pcm); |