| 660 | |
| 661 | |
| 662 | static int |
| 663 | WASAPI_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) |
| 664 | { |
| 665 | LPCWSTR devid = (LPCWSTR) handle; |
| 666 | |
| 667 | /* Initialize all variables that we clean on shutdown */ |
| 668 | this->hidden = (struct SDL_PrivateAudioData *) |
| 669 | SDL_malloc((sizeof *this->hidden)); |
| 670 | if (this->hidden == NULL) { |
| 671 | return SDL_OutOfMemory(); |
| 672 | } |
| 673 | SDL_zerop(this->hidden); |
| 674 | |
| 675 | WASAPI_RefDevice(this); /* so CloseDevice() will unref to zero. */ |
| 676 | |
| 677 | if (!devid) { /* is default device? */ |
| 678 | this->hidden->default_device_generation = SDL_AtomicGet(iscapture ? &WASAPI_DefaultCaptureGeneration : &WASAPI_DefaultPlaybackGeneration); |
| 679 | } else { |
| 680 | this->hidden->devid = WStrDupe(devid); |
| 681 | if (!this->hidden->devid) { |
| 682 | return SDL_OutOfMemory(); |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | if (WASAPI_ActivateDevice(this, SDL_FALSE) == -1) { |
| 687 | return -1; /* already set error. */ |
| 688 | } |
| 689 | |
| 690 | /* Ready, but waiting for async device activation. |
| 691 | Until activation is successful, we will report silence from capture |
| 692 | devices and ignore data on playback devices. |
| 693 | Also, since we don't know the _actual_ device format until after |
| 694 | activation, we let the app have whatever it asks for. We set up |
| 695 | an SDL_AudioStream to convert, if necessary, once the activation |
| 696 | completes. */ |
| 697 | |
| 698 | return 0; |
| 699 | } |
| 700 | |
| 701 | static void |
| 702 | WASAPI_ThreadInit(_THIS) |
nothing calls this directly
no test coverage detected