void Mediator::Play(Type type, Company company) { //Set requested device if (SetActiveDevice(type, company)){ active_Player->play(); //Play on successful set } else{ cout << "Device already active or no such device in console" << endl; } }
bool FAudioDeviceManager::ShutdownAudioDevice(uint32 Handle) { if (!IsValidAudioDeviceHandle(Handle)) { return false; } check(NumActiveAudioDevices > 0); --NumActiveAudioDevices; // If there are more than 1 device active, check to see if this handle is the main audio device handle if (NumActiveAudioDevices >= 1) { uint32 MainDeviceHandle = GEngine->GetAudioDeviceHandle(); if (NumActiveAudioDevices == 1) { // If we only have one audio device left, then set the active // audio device to be the main audio device SetActiveDevice(MainDeviceHandle); } // If this is the main device handle and there's more than one reference to the main device, // don't shut it down until it's the very last handle to get shut down // this is because it's possible for some PIE sessions to be using the main audio device as a fallback to // preserve CPU performance on low-performance machines if (NumWorldsUsingMainAudioDevice > 0 && MainDeviceHandle == Handle) { --NumWorldsUsingMainAudioDevice; return true; } } uint32 Index = GetIndex(Handle); uint8 Generation = GetGeneration(Handle); check(int32(Index) < Generations.Num()); // Bump up the generation at the given index. This will invalidate // the handle without needing to broadcast to everybody who might be using the handle Generations[Index] = ++Generation; // Make sure we have a non-null device ptr in the index slot, then delete it FAudioDevice* AudioDevice = Devices[Index]; check(AudioDevice != nullptr); // Tear down the audio device AudioDevice->Teardown(); delete AudioDevice; // Nullify the audio device slot for future audio device creations Devices[Index] = nullptr; // Add this index to the list of free indices ++FreeIndicesSize; FreeIndices.Enqueue(Index); return true; }