-
Notifications
You must be signed in to change notification settings - Fork 167
bugfix(audiomanager): Fix dummy audio manager implementation for failing audio length script conditions in headless mode #2313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a74d176
2968389
48e8dc8
477d80b
487a865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,3 +330,53 @@ class MilesAudioManager : public AudioManager | |
|
|
||
| }; | ||
|
|
||
| // TheSuperHackers @feature helmutbuhler 17/05/2025 AudioManager that does almost nothing. Used for Headless Mode. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Useful for headless mode" |
||
| // @bugfix Caball009 16/02/2026 Scripts may require the actual audio file length to function properly. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps clarify that this is CRC relevant |
||
| // The Miles AudioManager handles the device opening / closure, so that getFileLengthMS can function as intended. | ||
| class MilesAudioManagerDummy : public MilesAudioManager | ||
| { | ||
| #if defined(RTS_DEBUG) | ||
| virtual void audioDebugDisplay(DebugDisplayInterface* dd, void* userData, FILE* fp) {} | ||
| #endif | ||
| virtual void stopAudio(AudioAffect which) {} | ||
| virtual void pauseAudio(AudioAffect which) {} | ||
| virtual void resumeAudio(AudioAffect which) {} | ||
| virtual void pauseAmbient(Bool shouldPause) {} | ||
| virtual void killAudioEventImmediately(AudioHandle audioEvent) {} | ||
| virtual void nextMusicTrack() {} | ||
| virtual void prevMusicTrack() {} | ||
| virtual Bool isMusicPlaying() const { return false; } | ||
| virtual Bool hasMusicTrackCompleted(const AsciiString& trackName, Int numberOfTimes) const { return false; } | ||
| virtual AsciiString getMusicTrackName() const { return ""; } | ||
| //virtual void openDevice() {} | ||
| //virtual void closeDevice() {} | ||
| //virtual void* getDevice() { return nullptr; } | ||
|
Comment on lines
+351
to
+353
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. The existing comment at line 335 already explains why these methods aren't overridden. Prompt To Fix With AIThis is a comment left during a code review.
Path: Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h
Line: 351-353
Comment:
Remove commented-out code. The existing comment at line 335 already explains why these methods aren't overridden.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's value in providing a complete implementation of AudioManager. The functions that are commented out show clearly, more so than the comment, which functions are not overridden for this dummy implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a fair point. Commented-out method signatures can serve as inline documentation showing what's intentionally not overridden, especially in a class that overrides most other virtual methods. However, this approach has a trade-off: it creates ambiguity about whether the code is temporarily disabled or intentionally documented. A clearer alternative would be to add these method names to the existing comment at line 335, making it explicit which methods are intentionally not overridden without leaving commented code. For example: // Methods intentionally not overridden: openDevice(), closeDevice(), getDevice()This gives you the same clarity without the "is this dead code?" question. But if you prefer the visual clarity of seeing the signatures, keeping them commented is also reasonable—just be aware that most linters and style guides flag commented-out code as a smell. Your call on which approach better serves future maintainers. |
||
| virtual void notifyOfAudioCompletion(UnsignedInt audioCompleted, UnsignedInt flags) {} | ||
| virtual UnsignedInt getProviderCount() const { return 0; }; | ||
| virtual AsciiString getProviderName(UnsignedInt providerNum) const { return ""; } | ||
| virtual UnsignedInt getProviderIndex(AsciiString providerName) const { return 0; } | ||
| virtual void selectProvider(UnsignedInt providerNdx) {} | ||
| virtual void unselectProvider() {} | ||
| virtual UnsignedInt getSelectedProvider() const { return 0; } | ||
| virtual void setSpeakerType(UnsignedInt speakerType) {} | ||
| virtual UnsignedInt getSpeakerType() { return 0; } | ||
| virtual UnsignedInt getNum2DSamples() const { return 0; } | ||
| virtual UnsignedInt getNum3DSamples() const { return 0; } | ||
| virtual UnsignedInt getNumStreams() const { return 0; } | ||
| virtual Bool doesViolateLimit(AudioEventRTS* event) const { return false; } | ||
| virtual Bool isPlayingLowerPriority(AudioEventRTS* event) const { return false; } | ||
| virtual Bool isPlayingAlready(AudioEventRTS* event) const { return false; } | ||
| virtual Bool isObjectPlayingVoice(UnsignedInt objID) const { return false; } | ||
| virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume) {} | ||
| virtual void removePlayingAudio(AsciiString eventName) {} | ||
| virtual void removeAllDisabledAudio() {} | ||
| virtual Bool has3DSensitiveStreamsPlaying() const { return false; } | ||
| virtual void* getHandleForBink() { return nullptr; } | ||
| virtual void releaseHandleForBink() {} | ||
| virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay) {} | ||
| virtual void setPreferredProvider(AsciiString providerNdx) {} | ||
| virtual void setPreferredSpeaker(AsciiString speakerType) {} | ||
| //virtual Real getFileLengthMS(AsciiString strToLoad) const { return 0.0f; } | ||
Caball009 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| virtual void closeAnySamplesUsingFile(const void* fileToClose) {} | ||
| virtual void setDeviceListenerPosition() {} | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,7 @@ class Win32GameEngine : public GameEngine | |
| virtual NetworkInterface *createNetwork(); ///< Factory for the network | ||
| virtual Radar *createRadar(); ///< Factory for radar | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps mirror the implemention for createRadar? It currently also does |
||
| virtual WebBrowser *createWebBrowser(); ///< Factory for embedded browser | ||
| virtual AudioManager *createAudioManager(); ///< Factory for audio device | ||
| virtual AudioManager *createAudioManager(Bool headless); ///< Factory for audio device | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe do |
||
| virtual ParticleSystemManager* createParticleSystemManager(); | ||
|
|
||
|
|
||
|
|
@@ -98,4 +98,4 @@ inline ParticleSystemManager* Win32GameEngine::createParticleSystemManager() { r | |
| inline NetworkInterface *Win32GameEngine::createNetwork() { return NetworkInterface::createNetwork(); } | ||
| inline Radar *Win32GameEngine::createRadar() { return NEW W3DRadar; } | ||
| inline WebBrowser *Win32GameEngine::createWebBrowser() { return NEW CComObject<W3DWebBrowser>; } | ||
| inline AudioManager *Win32GameEngine::createAudioManager() { return NEW MilesAudioManager; } | ||
| inline AudioManager *Win32GameEngine::createAudioManager(Bool headless) { return headless ? NEW MilesAudioManagerDummy : NEW MilesAudioManager; } | ||
Uh oh!
There was an error while loading. Please reload this page.