mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-16 08:56:42 -05: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;
|
||||
while (step < 4096 &&
|
||||
(step & pinfo.fragment_align) != 0 &&
|
||||
(step & rinfo.fragment_align) != 0) step++;
|
||||
(step & rinfo.fragment_align) != 0)
|
||||
step++;
|
||||
if (*fragmentsize) {
|
||||
*fragmentsize += step;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ void main( void )
|
|||
char *buffer, *buffer1;
|
||||
|
||||
buffer = (char *) malloc(512 * 1024);
|
||||
if ( !buffer ) return;
|
||||
if (!buffer)
|
||||
return;
|
||||
if ((err = snd_pcm_open(&handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0) {
|
||||
fprintf(stderr, "open failed: %s\n", snd_strerror(err));
|
||||
return;
|
||||
|
|
@ -67,8 +68,10 @@ void main( void )
|
|||
close(fd);
|
||||
if (!memcmp(buffer, ".snd", 4)) {
|
||||
idx = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7]);
|
||||
if ( idx > 128 ) idx = 128;
|
||||
if ( idx > count ) idx = count;
|
||||
if (idx > 128)
|
||||
idx = 128;
|
||||
if (idx > count)
|
||||
idx = count;
|
||||
}
|
||||
buffer1 = buffer + idx;
|
||||
count -= idx;
|
||||
|
|
|
|||
18
test/pcm.c
18
test/pcm.c
|
|
@ -44,13 +44,15 @@ void method1( void )
|
|||
return;
|
||||
}
|
||||
setformat(phandle, rhandle);
|
||||
printf( "Recording... " ); fflush( stdout );
|
||||
printf("Recording... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
}
|
||||
printf("done...\n");
|
||||
printf( "Playback... " ); fflush( stdout );
|
||||
printf("Playback... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
|
|
@ -77,7 +79,8 @@ void method2( void )
|
|||
return;
|
||||
}
|
||||
setformat(phandle, rhandle);
|
||||
printf( "Recording... " ); fflush( stdout );
|
||||
printf("Recording... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_read(rhandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
|
|
@ -88,7 +91,8 @@ void method2( void )
|
|||
return;
|
||||
}
|
||||
printf("Record flush done...\n");
|
||||
printf( "Playback... " ); fflush( stdout );
|
||||
printf("Playback... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_write(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
|
|
@ -116,7 +120,8 @@ void method3( void )
|
|||
return;
|
||||
}
|
||||
setformat(handle, handle);
|
||||
printf( "Recording... " ); fflush( stdout );
|
||||
printf("Recording... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_read(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Read error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
|
|
@ -127,7 +132,8 @@ void method3( void )
|
|||
return;
|
||||
}
|
||||
printf("Record flush done...\n");
|
||||
printf( "Playback... " ); fflush( stdout );
|
||||
printf("Playback... ");
|
||||
fflush(stdout);
|
||||
if ((err = snd_pcm_write(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
|
||||
printf("Write error: %s\n", err < 0 ? snd_strerror(err) : xitoa(err));
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,16 @@
|
|||
const char *get_type(unsigned int type)
|
||||
{
|
||||
switch (type) {
|
||||
case 0: return "Boolean";
|
||||
case 1: return "Byte";
|
||||
case 2: return "Word";
|
||||
case 3: return "DWord";
|
||||
case 4: return "User";
|
||||
case 0:
|
||||
return "Boolean";
|
||||
case 1:
|
||||
return "Byte";
|
||||
case 2:
|
||||
return "Word";
|
||||
case 3:
|
||||
return "DWord";
|
||||
case 4:
|
||||
return "User";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
|
@ -33,7 +38,6 @@ void main( void )
|
|||
printf("Giving up...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* control interface */
|
||||
for (card = 0; card < cards; card++) {
|
||||
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);
|
||||
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) {
|
||||
printf("PCM open error: %s\n", snd_strerror(err));
|
||||
continue;
|
||||
|
|
@ -182,7 +187,8 @@ void main( void )
|
|||
int (*switch_write) (void *handle, int switchn, snd_rawmidi_switch_t * data);
|
||||
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) {
|
||||
printf("RawMIDI CTL open error: %s\n", snd_strerror(err));
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue