Skip to content

Commit a258aad

Browse files
committed
Address Copilot review feedback
1 parent 629be9b commit a258aad

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/playlist/PlaylistCWrapper.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,9 @@ void PlaylistCWrapper::PlayPresetIndex(uint32_t index, bool hardCut, bool resetF
131131
{
132132
if (m_presetLoadEventCallback(index, filename.c_str(), hardCut, m_presetLoadEventUserData))
133133
{
134-
// Application handled the load, don't try to load from filesystem.
135-
// Only fire switched event if the app's load succeeded.
136-
if (!m_lastPresetSwitchFailed && m_presetSwitchedEventCallback != nullptr)
137-
{
138-
m_presetSwitchedEventCallback(hardCut, index, m_presetSwitchedEventUserData);
139-
}
134+
// Application handled the load - return without further action.
135+
// The app is responsible for calling projectm_load_preset_file/data,
136+
// handling errors, and firing the switched event when ready.
140137
return;
141138
}
142139
}

src/playlist/api/projectM-4/playlist_callbacks.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,24 @@ typedef void (*projectm_playlist_preset_switch_failed_event)(const char* preset_
8080
* - Custom preset storage solutions
8181
*
8282
* When this callback is set and returns true, the playlist library will NOT attempt
83-
* to load the preset file itself. The application is responsible for calling
84-
* projectm_load_preset_file() or projectm_load_preset_data() with the preset content.
83+
* to load the preset file itself and will return immediately without firing any events.
84+
* The application takes full responsibility for:
85+
* - Calling projectm_load_preset_file() or projectm_load_preset_data() with the preset content
86+
* - Handling any loading errors
87+
* - Firing the preset_switched_event callback when the preset is ready (if desired)
8588
*
8689
* If the callback returns false or is not set, the playlist library will use the
8790
* default behavior of loading the preset from the filesystem.
8891
*
8992
* @note The filename pointer is only valid inside the callback. Make a copy if it needs
9093
* to be retained for later use.
94+
* @note Do not call any playlist preset-switching functions from within this callback.
9195
* @param index The playlist index of the preset to be loaded.
9296
* @param filename The preset filename/URL at this index. Can be used as a key or path.
9397
* @param hard_cut True if this should be a hard cut, false for a smooth transition.
9498
* @param user_data A user-defined data pointer that was provided when registering the callback,
9599
* e.g. context information.
96-
* @return True if the application handled the preset loading, false to use default behavior.
100+
* @return True if the application handles preset loading, false to use default behavior.
97101
* @since 4.2.0
98102
*/
99103
typedef bool (*projectm_playlist_preset_load_event)(unsigned int index, const char* filename,

0 commit comments

Comments
 (0)