|
@@ -358,32 +358,33 @@ static int open_audio_playing(void *arg)
|
|
|
wanted_spec.callback = sdl_audio_callback; // 回调函数,若为NULL,则应使用SDL_QueueAudio()机制
|
|
|
wanted_spec.userdata = is; // 提供给回调函数的参数
|
|
|
|
|
|
- int iaudioapeaker = SDL_GetNumAudioDevices(0);
|
|
|
- const char* strdevname = NULL;
|
|
|
- is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "audio output device number is %d.", iaudioapeaker);
|
|
|
- int i = 0;
|
|
|
- for (; i < iaudioapeaker; i++) {
|
|
|
- is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "device id %d audio device name is %s.", i, SDL_GetAudioDeviceName(i, 0));
|
|
|
- if (is->paudiodev && strstr(SDL_GetAudioDeviceName(i, 0), is->paudiodev)){
|
|
|
- strdevname = SDL_GetAudioDeviceName(i, 0);
|
|
|
- is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s matched audio device name is %s.", is->paudiodev, strdevname);
|
|
|
- break;
|
|
|
+ if (NULL == strdevname) {
|
|
|
+ int iaudioapeaker = SDL_GetNumAudioDevices(0);
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "audio output device number is %d.", iaudioapeaker);
|
|
|
+ int i = 0;
|
|
|
+ for (; i < iaudioapeaker; i++) {
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "device id %d audio device name is %s.", i, SDL_GetAudioDeviceName(i, 0));
|
|
|
+ if (is->paudiodev && strstr(SDL_GetAudioDeviceName(i, 0), is->paudiodev)) {
|
|
|
+ strdevname = SDL_GetAudioDeviceName(i, 0);
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "%s matched audio device name is %s.", is->paudiodev, strdevname);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ if (i == iaudioapeaker) {
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "matched audio device name (%s) failed!", strdevname ? strdevname : "null");
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ int inum = SDL_GetNumAudioDrivers();
|
|
|
+ int i = 0;
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Audio Drivers number is %d.", inum);
|
|
|
+ for (; i < inum; i++) {
|
|
|
+ const char* drivername = SDL_GetAudioDriver(i);
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "[%d] Audio Drivers name is %s.", i, drivername);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "current audio driver name is %s.", SDL_GetCurrentAudioDriver());
|
|
|
}
|
|
|
- if (i == iaudioapeaker){
|
|
|
- is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "matched audio device name (%s) failed!", strdevname ? strdevname : "null");
|
|
|
- }
|
|
|
-
|
|
|
- //{
|
|
|
- // int inum = SDL_GetNumAudioDrivers();
|
|
|
- // int i = 0;
|
|
|
- // is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "Audio Drivers number is %d.", inum);
|
|
|
- // for (; i < inum; i++) {
|
|
|
- // const char* drivername = SDL_GetAudioDriver(i);
|
|
|
- // is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "[%d] Audio Drivers name is %s.", i, drivername);
|
|
|
- // }
|
|
|
- //}
|
|
|
- is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "current audio driver name is %s.", SDL_GetCurrentAudioDriver());
|
|
|
|
|
|
while (!(audio_dev = SDL_OpenAudioDevice(strdevname, 0, &wanted_spec, &actual_spec, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | SDL_AUDIO_ALLOW_CHANNELS_CHANGE))){
|
|
|
is->rvc_hostapi->Debug(MEDIA_LOG_ERROR, "SDL_OpenAudio (%d channels, %d Hz): %s",wanted_spec.channels, wanted_spec.freq, SDL_GetError());
|
|
@@ -414,8 +415,7 @@ static int open_audio_playing(void *arg)
|
|
|
|
|
|
SDL_PauseAudioDevice(audio_dev, 0);
|
|
|
|
|
|
- while (false == is->baudio_finished)
|
|
|
- {
|
|
|
+ while (false == is->baudio_finished){
|
|
|
SDL_Delay(1);
|
|
|
}
|
|
|
|