Skip to content
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

code cleanup #69

Merged
merged 17 commits into from
Dec 11, 2017
Merged

code cleanup #69

merged 17 commits into from
Dec 11, 2017

Conversation

fuzzard
Copy link
Contributor

@fuzzard fuzzard commented Nov 12, 2017

Further cleanup of existing code. Removing unused variables/functions.
Stub OpenLiveStream and CloseLiveStream as they are not required for implementation as we now rely on GetChannelStreamProperties
Removed some globals that are not used throughout the codebase anymore.

Let me know if ive overstepped anything at this stage. I think this is the final pass for cleanups that i can see at this stage.

}
}
}
return jsonChannel["URL"].asString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation?

@@ -65,7 +65,7 @@ class HDHomeRunTuners
};

public:
HDHomeRunTuners();
HDHomeRunTuners(){};
Copy link
Member

@ksooo ksooo Nov 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ugly without a blank between ) and {.

src/Utils.h Outdated
@@ -47,7 +47,6 @@ int DbgPrintf(const char* szFormat, ...);
} while (0)

#define PVR_STRCPY(dest, source) do { strncpy(dest, source, sizeof(dest)-1); dest[sizeof(dest)-1] = '\0'; } while(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can also get rid of this ugly (and unneeded) macro?

src/client.h Outdated
@@ -27,6 +27,8 @@
#include <libXBMC_pvr.h>
#include <p8-platform/util/StringUtils.h>

using namespace ADDON;

typedef std::string String;
Copy link
Member

@ksooo ksooo Nov 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another ugly piece of code... Something like this is just for the lazy people (or people not knowing "search and replace"... ;-)

@fuzzard
Copy link
Contributor Author

fuzzard commented Nov 12, 2017

Removed the typedef and the macro as suggested. Also saw a comment elsewhere about not using the namespace. So i pulled that change as well.
The indentation is correct, i can put the {} back in if you think that makes it easier to read. The github diff makes it look a lot more complicated than the change is.

Happy to squash, unless you can do that on merge, just let me know

@fuzzard fuzzard force-pushed the minors branch 2 times, most recently from 555ee0d to 3f1a124 Compare November 12, 2017 23:21
Copy link
Member

@ksooo ksooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look sane. Thanks. Could you please update changelog and addon version number? Then we're good to go, imo.

@fuzzard
Copy link
Contributor Author

fuzzard commented Nov 13, 2017

rebased and added changelog/version bump.
Cheers

@fuzzard
Copy link
Contributor Author

fuzzard commented Nov 21, 2017

squashed and rebased after jsoncpp merge.
Also did some changes to headers. Explicitly putting the header includes in files that use them, rather than having them inherit from other headers. Reordered to suit kodi guidelines as well.
also had another unused variable thats been removed.

@fuzzard fuzzard force-pushed the minors branch 4 times, most recently from 5d4ac31 to cb100a7 Compare December 3, 2017 11:27
@fuzzard
Copy link
Contributor Author

fuzzard commented Dec 3, 2017

Couple more minors changed.
Removed addon namespace usage as it was only used for logging for the most part, so have just directly used the ADDON::XXXX types
Further header alterations. Make sure each file imports any and all headers required. In the past a lot of headers were just being pulled in due to the inclusion of the p8-platform headers.
Shuffled some variable declarations to better suit when they are required.
Removed another typdef that was only used a single time. Clearer to just have the declaration as it is i think.

@fuzzard fuzzard force-pushed the minors branch 5 times, most recently from 151b63a to ec1a4ef Compare December 5, 2017 11:38
@fuzzard
Copy link
Contributor Author

fuzzard commented Dec 5, 2017

@ksooo any chance of a final review. Ive repushed all of the changes and split it into individual commits to make it easier to review. The single commit was getting a bit out of hand to keep track of everything i think.

I also had a relook and think about the PVR_STRCPY define, and i didnt see it before, but it null terminates whatever is passed to it. In my initial pass of removing that, i wasnt dealing with null termination at all, which obviously is an issue. Should i stick with the define, or is the strcpy + null terminate at each use ok from a readability viewpoint?

sort headers according to kodi guidelines and include all appropriate headers
in each source file
@fuzzard fuzzard force-pushed the minors branch 4 times, most recently from 4cac101 to ffc0b27 Compare December 8, 2017 04:13
whitespace, aesthetics/layout cleanup
Change final for auto range loops, move variable declarations closer to actual usage
@fuzzard
Copy link
Contributor Author

fuzzard commented Dec 9, 2017

Another commit added. Currently a discover is never done past initial startup of addon. This means no additional tuners will ever be added unless the addon is restarted. The change will now add a tuner without a full discover if it is not found in the m_Tuners vector. To handle a tuner disappearing, it will do a clear on the vector if the size is larger than the discovered nTunerCount returned by the discovery request.
This doesnt really handle the situation of the tuner count staying the same, but with different tuners. This is such a corner case, that i couldnt work out a clean way to handle it without a lot of extra code for no real use. On the subsequent update call (60 minutes), this should all wash out as the m_tuners size will be larger than the next discovery, so it will reset the vector and recreate it all anyway.

Figured id throw this and 2 other commits into this PR, as its proven difficult to continue to get PR's merged (this is in no way aimed at you ksooo, because i know you have far more stuff to do than keep looking at one measly addon).
If required i can pull out the feature change commits and put into another PR if desired.

@ksooo
Copy link
Member

ksooo commented Dec 9, 2017

Another commit added.

Hold on! Give me some time to review the PR. I have the feeling if I find no time soon I will be confronted with a 50 commits PR containing all kind of different stuff. ;-)

Copy link
Member

@ksooo ksooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just some nitpicking from my end. cannot say anything about the correctness of the hdhomerun functioality specific changes, though.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hdhomerun"
version="3.1.9"
version="3.1.10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add new features, please increase minor version number (3.1.9 => 3.2.0 in this case).

v3.1.10
- code cleanup
- guide filters updated
- additional epg_tag fields added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add new features, please increase minor version number (3.1.9 => 3.2.0 in this case).

src/client.cpp Outdated

strncpy(signalStatus.strAdapterName, "PVR HDHomeRun Adapter 1",
sizeof(signalStatus.strAdapterName) - 1);
signalStatus.strAdapterName[sizeof(signalStatus.strAdapterName)-1] = '\0';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add blanks around the -?

src/client.cpp Outdated
signalStatus.strAdapterName[sizeof(signalStatus.strAdapterName)-1] = '\0';
strncpy(signalStatus.strAdapterStatus, "OK",
sizeof(signalStatus.strAdapterStatus) - 1);
signalStatus.strAdapterStatus[sizeof(signalStatus.strAdapterStatus)-1] = '\0';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add blanks around the -?

make sure we null terminate our strncpy
change location of variable declarations to avoid construction before a failure case
remove and indent as needed whitespace
remove temp variable and return directly in _GetChannelStreamURL()
change to c++ style casts for time_t and last for auto range loop in
PvrGetEPGForChannel()
This handles an episode that is numbered via SD's guide to match an episode number
such as E2017-199. This sets the series to first number (the year), and episodenumber to
the last number.
move guidenumberset outside of tuner loop so it retains the set of channels for all
found tuners.
Should test thread creation of updatethread actually succeeds, if not addon should fail
as no guide/lineup will be updated.
If a new tuner is found, add it to the list and process as normal
If total tuners found is less than the current list, clear and recreate tuner list for all
This doesnt not handle the situation of the same tuner count, but different tuners. It
will have a greater size on next update call, so should even out in the end, but it will go
an hour between the next update call before it is fixed.
@fuzzard
Copy link
Contributor Author

fuzzard commented Dec 11, 2017

Cheers, done.

@ksooo ksooo merged commit 63dfccb into kodi-pvr:master Dec 11, 2017
afedchin added a commit to afedchin/pvr.hdhomerun that referenced this pull request Dec 13, 2017
afedchin added a commit that referenced this pull request Dec 13, 2017
win10: fix build on UWP after #69
fuzzard pushed a commit to fuzzard/pvr.hdhomerun that referenced this pull request Dec 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants