From 0b87afe091b81a9bc04be3594bbeb4711294956d Mon Sep 17 00:00:00 2001 From: Patrick Linstruth Date: Wed, 24 Jan 2018 15:16:20 -0800 Subject: [PATCH 1/2] Fixed bug in GetStream() where return value from HPI_OutStreamOpen was ignored --- rdhpi/rdhpiplaystream.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rdhpi/rdhpiplaystream.cpp b/rdhpi/rdhpiplaystream.cpp index 7fd823c5..bbb41321 100644 --- a/rdhpi/rdhpiplaystream.cpp +++ b/rdhpi/rdhpiplaystream.cpp @@ -761,12 +761,13 @@ int RDHPIPlayStream::GetStream() #ifdef RDHPIPLAYSTREAM_USE_LOCAL_MUTEX for(int i=0;igetCardOutputStreams(card_number);i++) { if(++stream_mutex[card_number][i]==1) { - LogHpi(HPI_OutStreamOpen(NULL,card_index[card_number],i,&hpi_stream)); - stream_number=i; - return stream_number; - } - else { - stream_mutex[card_number][i]--; + if (LogHpi(HPI_OutStreamOpen(NULL,card_index[card_number],i,&hpi_stream))==0) { + stream_number=i; + return stream_number; + } + else { + stream_mutex[card_number][i]--; + } } } return -1; From 42400de160984b23aabb05c7e4c87a02ae7e0fc2 Mon Sep 17 00:00:00 2001 From: Patrick Linstruth Date: Wed, 24 Jan 2018 16:37:53 -0800 Subject: [PATCH 2/2] Fixed bug in my bug fix - was not properly decrementing mutex --- rdhpi/rdhpiplaystream.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rdhpi/rdhpiplaystream.cpp b/rdhpi/rdhpiplaystream.cpp index bbb41321..4c706005 100644 --- a/rdhpi/rdhpiplaystream.cpp +++ b/rdhpi/rdhpiplaystream.cpp @@ -765,10 +765,8 @@ int RDHPIPlayStream::GetStream() stream_number=i; return stream_number; } - else { - stream_mutex[card_number][i]--; - } } + stream_mutex[card_number][i]--; } return -1; #else