src/audio/xaudio2/SDL_xaudio2.c
changeset 8518 bc44448125eb
parent 8500 f25ef28d61e8
child 8519 0a334fc866b0
equal deleted inserted replaced
8517:d7d86c917b1d 8518:bc44448125eb
   323     int valid_format = 0;
   323     int valid_format = 0;
   324     SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
   324     SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
   325     IXAudio2 *ixa2 = NULL;
   325     IXAudio2 *ixa2 = NULL;
   326     IXAudio2SourceVoice *source = NULL;
   326     IXAudio2SourceVoice *source = NULL;
   327 #if defined(__WINRT__)
   327 #if defined(__WINRT__)
   328     WCHAR devIdBuffer[256];
       
   329     LPCWSTR devId = 0;
   328     LPCWSTR devId = 0;
   330 #else
   329 #else
   331     UINT32 devId = 0;  /* 0 == system default device. */
   330     UINT32 devId = 0;  /* 0 == system default device. */
   332 #endif
   331 #endif
   333 
   332 
   345     };
   344     };
   346 
   345 
   347 	static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
   346 	static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
   348 #endif // ! defined(__cplusplus)
   347 #endif // ! defined(__cplusplus)
   349 
   348 
   350 #if defined(__WINRT__)
       
   351     SDL_zero(devIdBuffer);
       
   352 #endif
       
   353 
       
   354     if (iscapture) {
   349     if (iscapture) {
   355         return SDL_SetError("XAudio2: capture devices unsupported.");
   350         return SDL_SetError("XAudio2: capture devices unsupported.");
   356     } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
   351     } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
   357         return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
   352         return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
   358     }
   353     }
       
   354 
   359     /*
   355     /*
   360     XAUDIO2_DEBUG_CONFIGURATION debugConfig;
   356     XAUDIO2_DEBUG_CONFIGURATION debugConfig;
   361     debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
   357     debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
   362     debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
   358     debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
   363     debugConfig.LogThreadID = TRUE;
   359     debugConfig.LogThreadID = TRUE;
   365     debugConfig.LogFunctionName = TRUE;
   361     debugConfig.LogFunctionName = TRUE;
   366     debugConfig.LogTiming = TRUE;
   362     debugConfig.LogTiming = TRUE;
   367     ixa2->SetDebugConfiguration(&debugConfig);
   363     ixa2->SetDebugConfiguration(&debugConfig);
   368     */
   364     */
   369 
   365 
   370 #if ! defined(__WINRT__) || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
   366 #if ! defined(__WINRT__)
   371     if (devname != NULL) {
   367     if (devname != NULL) {
   372         UINT32 devcount = 0;
   368         UINT32 devcount = 0;
   373         UINT32 i = 0;
   369         UINT32 i = 0;
   374 
   370 
   375         if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
   371         if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
   382                 char *str = WIN_StringToUTF8(details.DisplayName);
   378                 char *str = WIN_StringToUTF8(details.DisplayName);
   383                 if (str != NULL) {
   379                 if (str != NULL) {
   384                     const int match = (SDL_strcmp(str, devname) == 0);
   380                     const int match = (SDL_strcmp(str, devname) == 0);
   385                     SDL_free(str);
   381                     SDL_free(str);
   386                     if (match) {
   382                     if (match) {
   387 #if defined(__WINRT__)
       
   388                         wcsncpy_s(devIdBuffer, ARRAYSIZE(devIdBuffer), details.DeviceID, _TRUNCATE);
       
   389                         devId = (LPCWSTR) &devIdBuffer;
       
   390 #else
       
   391                         devId = i;
   383                         devId = i;
   392 #endif
       
   393                         break;
   384                         break;
   394                     }
   385                     }
   395                 }
   386                 }
   396             }
   387             }
   397         }
   388         }