mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:12:43 +00:00 
			
		
		
		
	 859ac200b7
			
		
	
	
		859ac200b7
		
	
	
	
	
		
			
			The driver would crash if it was unable to find an output route, and subsequently the destruction of controller did not invoke `GenericInterruptHandler::will_be_destroyed()` because on the level of `AudioController`, that method is unavailable. By decoupling the interrupt handling from the controller, we get a new refcounted class that correctly cleans up after itself :^)
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			824 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			824 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/NonnullRefPtr.h>
 | |
| #include <Kernel/Interrupts/PCIIRQHandler.h>
 | |
| 
 | |
| namespace Kernel::Audio::IntelHDA {
 | |
| 
 | |
| class Controller;
 | |
| 
 | |
| class InterruptHandler
 | |
|     : public PCIIRQHandler
 | |
|     , public RefCounted<InterruptHandler> {
 | |
| public:
 | |
|     static ErrorOr<NonnullRefPtr<InterruptHandler>> create(Controller& controller)
 | |
|     {
 | |
|         return adopt_nonnull_ref_or_enomem(new (nothrow) InterruptHandler(controller));
 | |
|     }
 | |
| 
 | |
|     // ^PCIIRQHandler
 | |
|     virtual StringView purpose() const override { return "IntelHDA IRQ Handler"sv; }
 | |
| 
 | |
| private:
 | |
|     InterruptHandler(Controller& controller);
 | |
| 
 | |
|     // ^PCIIRQHandler
 | |
|     virtual bool handle_irq(RegisterState const&) override;
 | |
| 
 | |
|     Controller& m_controller;
 | |
| };
 | |
| 
 | |
| }
 |