aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wilson2012-11-09 17:16:47 -0600
committerSimon Wilson2012-11-09 17:22:36 -0600
commitda39e0b09eb0a1b559a96e2108160d1d8dccf314 (patch)
tree81e2afcb7d8abcbe0829366d5c46b9d7fdeb2300 /tinyplay.c
parentff2e54293f32b5bb5ff75b4cb25babb00f429ca4 (diff)
downloadplatform-external-tinyalsa-da39e0b09eb0a1b559a96e2108160d1d8dccf314.tar.gz
platform-external-tinyalsa-da39e0b09eb0a1b559a96e2108160d1d8dccf314.tar.xz
platform-external-tinyalsa-da39e0b09eb0a1b559a96e2108160d1d8dccf314.zip
Update to latest tinyalsa
2c3a8e2 Add -Wall to Makefile and fix warnings 4ef9a57 tinyplay: add clean shutdown handler for ctrl-c 9bb8066 Merge pull request #15 from quantumdream/master bad2b79 tinymix: Add support for passing control name f51c05b mixer: Add mixer_ctl_{set,get}_bytes() fcf66ab Merge pull request #16 from PeterMalkin/master 3d62222 Add pcm_wait() to the tinyalsa API. f9678dd tinyplay: Add missing header file <string.h> cde1f6f Fix several 'symbol defined but not used' warnings. 2a274a1 pcm: Add support for S8 and S24LE formats. a5baefd tinymix: support setting of multiple control values Change-Id: I3d5fe076753ce7d1f74dd3ebedc59202d29f4efd
Diffstat (limited to 'tinyplay.c')
-rw-r--r--tinyplay.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tinyplay.c b/tinyplay.c
index 3f76cc6..d7e7d46 100644
--- a/tinyplay.c
+++ b/tinyplay.c
@@ -30,6 +30,8 @@
30#include <stdio.h> 30#include <stdio.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <stdint.h> 32#include <stdint.h>
33#include <string.h>
34#include <signal.h>
33 35
34#define ID_RIFF 0x46464952 36#define ID_RIFF 0x46464952
35#define ID_WAVE 0x45564157 37#define ID_WAVE 0x45564157
@@ -56,10 +58,19 @@ struct chunk_fmt {
56 uint16_t bits_per_sample; 58 uint16_t bits_per_sample;
57}; 59};
58 60
61static int close = 0;
62
59void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, 63void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels,
60 unsigned int rate, unsigned int bits, unsigned int period_size, 64 unsigned int rate, unsigned int bits, unsigned int period_size,
61 unsigned int period_count); 65 unsigned int period_count);
62 66
67void stream_close(int sig)
68{
69 /* allow the stream to be closed gracefully */
70 signal(sig, SIG_IGN);
71 close = 1;
72}
73
63int main(int argc, char **argv) 74int main(int argc, char **argv)
64{ 75{
65 FILE *file; 76 FILE *file;
@@ -189,6 +200,9 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in
189 200
190 printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits); 201 printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits);
191 202
203 /* catch ctrl-c to shutdown cleanly */
204 signal(SIGINT, stream_close);
205
192 do { 206 do {
193 num_read = fread(buffer, 1, size, file); 207 num_read = fread(buffer, 1, size, file);
194 if (num_read > 0) { 208 if (num_read > 0) {
@@ -197,7 +211,7 @@ void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned in
197 break; 211 break;
198 } 212 }
199 } 213 }
200 } while (num_read > 0); 214 } while (!close && num_read > 0);
201 215
202 free(buffer); 216 free(buffer);
203 pcm_close(pcm); 217 pcm_close(pcm);