mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
Coding style..
This commit is contained in:
parent
d9087a8773
commit
fb1938d29f
6 changed files with 569 additions and 553 deletions
|
|
@ -74,7 +74,8 @@ int setparams(void *phandle, void *rhandle, int *fragmentsize)
|
||||||
step = rinfo.min_fragment_size;
|
step = rinfo.min_fragment_size;
|
||||||
while (step < 4096 &&
|
while (step < 4096 &&
|
||||||
(step & pinfo.fragment_align) != 0 &&
|
(step & pinfo.fragment_align) != 0 &&
|
||||||
(step & rinfo.fragment_align) != 0) step++;
|
(step & rinfo.fragment_align) != 0)
|
||||||
|
step++;
|
||||||
if (*fragmentsize) {
|
if (*fragmentsize) {
|
||||||
*fragmentsize += step;
|
*fragmentsize += step;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ void main( void )
|
||||||
char *buffer, *buffer1;
|
char *buffer, *buffer1;
|
||||||
|
|
||||||
buffer = (char *) malloc(512 * 1024);
|
buffer = (char *) malloc(512 * 1024);
|
||||||
if ( !buffer ) return;
|
if (!buffer)
|
||||||
|
return;
|
||||||
if ((err = snd_pcm_open(&handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0) {
|
if ((err = snd_pcm_open(&handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0) {
|
||||||
fprintf(stderr, "open failed: %s\n", snd_strerror(err));
|
fprintf(stderr, "open failed: %s\n", snd_strerror(err));
|
||||||
return;
|
return;
|
||||||
|
|
@ -67,8 +68,10 @@ void main( void )
|
||||||
close(fd);
|
close(fd);
|
||||||
if (!memcmp(buffer, ".snd", 4)) {
|
if (!memcmp(buffer, ".snd", 4)) {
|
||||||
idx = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7]);
|
idx = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7]);
|
||||||
if ( idx > 128 ) idx = 128;
|
if (idx > 128)
|
||||||
if ( idx > count ) idx = count;
|
idx = 128;
|
||||||
|
if (idx > count)
|
||||||
|
idx = count;
|
||||||
}
|
}
|
||||||
buffer1 = buffer + idx;
|
buffer1 = buffer + idx;
|
||||||
count -= idx;
|
count -= idx;
|
||||||
|
|
|
||||||
18
test/pcm.c
18
test/pcm.c
|
|
@ -44,13 +44,15 @@ void method1( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setformat(phandle, rhandle);
|
setformat(phandle, rhandle);
|
||||||
printf( "Recording... " ); fflush( stdout );
|
printf("Recording... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("done...\n");
|
printf("done...\n");
|
||||||
printf( "Playback... " ); fflush( stdout );
|
printf("Playback... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
|
|
@ -77,7 +79,8 @@ void method2( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setformat(phandle, rhandle);
|
setformat(phandle, rhandle);
|
||||||
printf( "Recording... " ); fflush( stdout );
|
printf("Recording... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
|
|
@ -88,7 +91,8 @@ void method2( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Record flush done...\n");
|
printf("Record flush done...\n");
|
||||||
printf( "Playback... " ); fflush( stdout );
|
printf("Playback... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
|
|
@ -116,7 +120,8 @@ void method3( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setformat(handle, handle);
|
setformat(handle, handle);
|
||||||
printf( "Recording... " ); fflush( stdout );
|
printf("Recording... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_read(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_read(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
|
|
@ -127,7 +132,8 @@ void method3( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Record flush done...\n");
|
printf("Record flush done...\n");
|
||||||
printf( "Playback... " ); fflush( stdout );
|
printf("Playback... ");
|
||||||
|
fflush(stdout);
|
||||||
if ((err = snd_pcm_write(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
if ((err = snd_pcm_write(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,16 @@
|
||||||
const char *get_type(unsigned int type)
|
const char *get_type(unsigned int type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0: return "Boolean";
|
case 0:
|
||||||
case 1: return "Byte";
|
return "Boolean";
|
||||||
case 2: return "Word";
|
case 1:
|
||||||
case 3: return "DWord";
|
return "Byte";
|
||||||
case 4: return "User";
|
case 2:
|
||||||
|
return "Word";
|
||||||
|
case 3:
|
||||||
|
return "DWord";
|
||||||
|
case 4:
|
||||||
|
return "User";
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +38,6 @@ void main( void )
|
||||||
printf("Giving up...\n");
|
printf("Giving up...\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* control interface */
|
/* control interface */
|
||||||
for (card = 0; card < cards; card++) {
|
for (card = 0; card < cards; card++) {
|
||||||
if ((err = snd_ctl_open(&handle, card)) < 0) {
|
if ((err = snd_ctl_open(&handle, card)) < 0) {
|
||||||
|
|
@ -122,7 +126,8 @@ void main( void )
|
||||||
int (*switch_write) (void *handle, int switchn, snd_pcm_switch_t * data);
|
int (*switch_write) (void *handle, int switchn, snd_pcm_switch_t * data);
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if ( !(pcm_info.flags & (!direction ? SND_PCM_INFO_PLAYBACK : SND_PCM_INFO_RECORD)) ) continue;
|
if (!(pcm_info.flags & (!direction ? SND_PCM_INFO_PLAYBACK : SND_PCM_INFO_RECORD)))
|
||||||
|
continue;
|
||||||
if ((err = snd_pcm_open(&handle, card, device, !direction ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_RECORD)) < 0) {
|
if ((err = snd_pcm_open(&handle, card, device, !direction ? SND_PCM_OPEN_PLAYBACK : SND_PCM_OPEN_RECORD)) < 0) {
|
||||||
printf("PCM open error: %s\n", snd_strerror(err));
|
printf("PCM open error: %s\n", snd_strerror(err));
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -182,7 +187,8 @@ void main( void )
|
||||||
int (*switch_write) (void *handle, int switchn, snd_rawmidi_switch_t * data);
|
int (*switch_write) (void *handle, int switchn, snd_rawmidi_switch_t * data);
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if ( !(pcm_info.flags & (!direction ? SND_RAWMIDI_INFO_OUTPUT : SND_RAWMIDI_INFO_INPUT)) ) continue;
|
if (!(pcm_info.flags & (!direction ? SND_RAWMIDI_INFO_OUTPUT : SND_RAWMIDI_INFO_INPUT)))
|
||||||
|
continue;
|
||||||
if ((err = snd_rawmidi_open(&handle, card, device, !direction ? SND_RAWMIDI_OPEN_OUTPUT : SND_RAWMIDI_OPEN_INPUT)) < 0) {
|
if ((err = snd_rawmidi_open(&handle, card, device, !direction ? SND_RAWMIDI_OPEN_OUTPUT : SND_RAWMIDI_OPEN_INPUT)) < 0) {
|
||||||
printf("RawMIDI CTL open error: %s\n", snd_strerror(err));
|
printf("RawMIDI CTL open error: %s\n", snd_strerror(err));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue