CasparCG / client

Client software primarily used with the CasparCG Server software for audio and video playout, to control graphics and recording, but it can also be used for other tasks within television broadcast.
https://casparcg.com
GNU General Public License v3.0
278 stars 97 forks source link

GPO saved rising/falling configuration does not correctly recall settings at startup #305

Closed amwtech closed 7 months ago

amwtech commented 1 year ago

Problem observed in client versions 2.0.9 and 2.2

This problem shows when trying to use the GPO widget to pulse ouput 1, which does not react. Higher numbered outputs do switch correctly. Opening the configuration and changing the rising/falling status, for example swap the value, then swap again enables GPO 1 to respond to the widget until the client is restarted.

Configuring any output to have the opposite rising/falling state relative to the other outputs then restarting the client shows an offset of +1 output for the rising/falling state change. Looking at the database table with DB Browser for SQlite shows the configuration is stored in the correct lines of the table.

Investigation of the client code shows the internal GPO numbering is zero-based (eg 0 to 7), an offset of +1 is added to the GPO number when storing into the database. This offset is not removed when the config is recalled. The code error is in file src/Core/DatabaseManager.cpp. The code line numbers differ for the two clients, and the corrected lines are shown below.

Client version 2.0.9 Line 1041 is: models.push_back(GpoPortModel(sql.value(0).toInt(), sql.value(1).toInt() == 1, sql.value(2).toInt()));

It should be models.push_back(GpoPortModel(sql.value(0).toInt() - 1, sql.value(1).toInt() == 1, sql.value(2).toInt()));

Client 2.2 Line 1050 is: models.push_back(GpoPortModel(sql.value("Id").toInt(),

It should be: models.push_back(GpoPortModel(sql.value("Id").toInt() - 1,

Julusian commented 7 months ago

Fix applied in https://github.com/CasparCG/client/commit/c79c5ff89222b4eab7f4bd5d6871fd2a697eb58e I havent tested it, hopefully it still works

amwtech commented 7 months ago

Tested on Mac and Windows client build. Operates correctly.

Julusian commented 7 months ago

I should also add that it looked like GpiPortModel had the same bug, so I applied the same fix there