test/testmultiaudio.c
changeset 2146 9fcde304c7b6
parent 2060 866052b01ee5
child 2867 eec7adc3d1c5
equal deleted inserted replaced
2145:5c14978b1e97 2146:9fcde304c7b6
    19     int waveleft = soundlen - cbd->soundpos;
    19     int waveleft = soundlen - cbd->soundpos;
    20     int cpy = len;
    20     int cpy = len;
    21     if (cpy > waveleft)
    21     if (cpy > waveleft)
    22         cpy = waveleft;
    22         cpy = waveleft;
    23 
    23 
    24     memcpy(stream, waveptr, cpy);
    24     SDL_memcpy(stream, waveptr, cpy);
    25     len -= cpy;
    25     len -= cpy;
    26     cbd->soundpos += cpy;
    26     cbd->soundpos += cpy;
    27     if (len > 0) {
    27     if (len > 0) {
    28         stream += cpy;
    28         stream += cpy;
    29         memset(stream, spec.silence, len);
    29         SDL_memset(stream, spec.silence, len);
    30         cbd->done++;
    30         cbd->done++;
    31     }
    31     }
    32 }
    32 }
    33 
    33 
    34 static void
    34 static void
    49     for (i = 0; i < devcount; i++) {
    49     for (i = 0; i < devcount; i++) {
    50         const char *devname = SDL_GetAudioDeviceName(i, 0);
    50         const char *devname = SDL_GetAudioDeviceName(i, 0);
    51         printf("playing on device #%d: ('%s')...", i, devname);
    51         printf("playing on device #%d: ('%s')...", i, devname);
    52         fflush(stdout);
    52         fflush(stdout);
    53 
    53 
    54         memset(&cbd[0], '\0', sizeof(callback_data));
    54         SDL_memset(&cbd[0], '\0', sizeof(callback_data));
    55         spec.userdata = &cbd[0];
    55         spec.userdata = &cbd[0];
    56         cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL);
    56         cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL);
    57         if (cbd[0].dev == 0) {
    57         if (cbd[0].dev == 0) {
    58             printf("Open device failed: %s\n", SDL_GetError());
    58             printf("Open device failed: %s\n", SDL_GetError());
    59         } else {
    59         } else {
    64             printf("done.\n");
    64             printf("done.\n");
    65             SDL_CloseAudioDevice(cbd[0].dev);
    65             SDL_CloseAudioDevice(cbd[0].dev);
    66         }
    66         }
    67     }
    67     }
    68 
    68 
    69     memset(cbd, '\0', sizeof(cbd));
    69     SDL_memset(cbd, '\0', sizeof(cbd));
    70 
    70 
    71     printf("playing on all devices...\n");
    71     printf("playing on all devices...\n");
    72     for (i = 0; i < devcount; i++) {
    72     for (i = 0; i < devcount; i++) {
    73         const char *devname = SDL_GetAudioDeviceName(i, 0);
    73         const char *devname = SDL_GetAudioDeviceName(i, 0);
    74         spec.userdata = &cbd[i];
    74         spec.userdata = &cbd[i];