Mailing List Archive

audio.isPaused not working for OpenSLES audio
Hi Mark

I assume you created the android OpenSLES audio support in MythTV. I
found that audio.isPaused() always returns true, even in the middle of
playing audio and video. This was causing audio-video sync to not work
correctly. I fixed it by taking that check out. It was not necessary to
check audio.isPaused() before calling Pause(). I just made it
unconditionally call Pause() whether it was already paused or not.
However I wonder if there is an error that is causing it to always
return isPaused() as true and whether that may cause other problems.

Peter

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 7/21/2018 3:48 AM, Peter Bennett wrote:
> Hi Mark
>
> I assume you created the android OpenSLES audio support in MythTV. I
> found that audio.isPaused() always returns true, even in the middle of
> playing audio and video. This was causing audio-video sync to not work
> correctly. I fixed it by taking that check out. It was not necessary
> to check audio.isPaused() before calling Pause(). I just made it
> unconditionally call Pause() whether it was already paused or not.
> However I wonder if there is an error that is causing it to always
> return isPaused() as true and whether that may cause other problems.
>
That is strange. All the paused processing is in AudioOutputBase, and
except for Jack and CA there is nothing in any of the other drivers.
This is probably affecting many drivers then.

Is this with or without stretch enabled? There is a bit of a difference
there. I will dig some more today.

Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 07/20/2018 06:19 PM, Mark Spieth wrote:
> On 7/21/2018 3:48 AM, Peter Bennett wrote:
>> Hi Mark
>>
>> I assume you created the android OpenSLES audio support in MythTV. I
>> found that audio.isPaused() always returns true, even in the middle
>> of playing audio and video. This was causing audio-video sync to not
>> work correctly. I fixed it by taking that check out. It was not
>> necessary to check audio.isPaused() before calling Pause(). I just
>> made it unconditionally call Pause() whether it was already paused or
>> not. However I wonder if there is an error that is causing it to
>> always return isPaused() as true and whether that may cause other
>> problems.
>>
> That is strange. All the paused processing is in AudioOutputBase, and
> except for Jack and CA there is nothing in any of the other drivers.
> This is probably affecting many drivers then.
>
> Is this with or without stretch enabled? There is a bit of a
> difference there. I will dig some more today.
>
> Mark
Stretch was not enabled. This is the code that pauses audio right at the
start of live tv to allow the video to catch up. the audio was never
being paused. MythPlayer::PrebufferEnoughFrames - also
MythPlayer::AVSync where audio.isPaused is checked before audio.pause().

Peter
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 21 July 2018 09:04:51 GMT+10:00, Peter Bennett <pb.mythtv@gmail.com> wrote:
>
>
>On 07/20/2018 06:19 PM, Mark Spieth wrote:
>> On 7/21/2018 3:48 AM, Peter Bennett wrote:
>>> Hi Mark
>>>
>>> I assume you created the android OpenSLES audio support in MythTV. I
>
>>> found that audio.isPaused() always returns true, even in the middle
>>> of playing audio and video. This was causing audio-video sync to not
>
>>> work correctly. I fixed it by taking that check out. It was not
>>> necessary to check audio.isPaused() before calling Pause(). I just
>>> made it unconditionally call Pause() whether it was already paused
>or
>>> not. However I wonder if there is an error that is causing it to
>>> always return isPaused() as true and whether that may cause other
>>> problems.
>>>
>> That is strange. All the paused processing is in AudioOutputBase, and
>
>> except for Jack and CA there is nothing in any of the other drivers.
>> This is probably affecting many drivers then.
>>
>> Is this with or without stretch enabled? There is a bit of a
>> difference there. I will dig some more today.
>>
>> Mark
>Stretch was not enabled. This is the code that pauses audio right at
>the
>start of live tv to allow the video to catch up. the audio was never
>being paused. MythPlayer::PrebufferEnoughFrames - also
>MythPlayer::AVSync where audio.isPaused is checked before
>audio.pause().
>

I understand that. I'm saying it should be happening for alsa and everything else too. The actually_paused flag is not being cleared because it's started in pause mode. Timestretch setting clears it up front.
There is something fishy in the audio pause logic that needs fixing. I'm amazed this hasnt been discovered before.

Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 7/21/2018 9:04 AM, Peter Bennett wrote:
>
>
> On 07/20/2018 06:19 PM, Mark Spieth wrote:
>> On 7/21/2018 3:48 AM, Peter Bennett wrote:
>>> Hi Mark
>>>
>>> I assume you created the android OpenSLES audio support in MythTV. I
>>> found that audio.isPaused() always returns true, even in the middle
>>> of playing audio and video. This was causing audio-video sync to not
>>> work correctly. I fixed it by taking that check out. It was not
>>> necessary to check audio.isPaused() before calling Pause(). I just
>>> made it unconditionally call Pause() whether it was already paused
>>> or not. However I wonder if there is an error that is causing it to
>>> always return isPaused() as true and whether that may cause other
>>> problems.
>>>
>> That is strange. All the paused processing is in AudioOutputBase, and
>> except for Jack and CA there is nothing in any of the other drivers.
>> This is probably affecting many drivers then.
>>
>> Is this with or without stretch enabled? There is a bit of a
>> difference there. I will dig some more today.
>>
>> Mark
> Stretch was not enabled. This is the code that pauses audio right at
> the start of live tv to allow the video to catch up. the audio was
> never being paused. MythPlayer::PrebufferEnoughFrames - also
> MythPlayer::AVSync where audio.isPaused is checked before audio.pause().
What it should be doing is initially its in pause until bufferred mode.
If you ry an unpause it will stay in that mode until the first audio
data is written/queued.
So when you start playing, yes it is in paused mode until you write the
first audio data, when it un-pauses.
If you are withholding audio data, then it will stay paused until you
write the first data.
Can you post a patch as to what you are trying to do and I will see if
there is a better way.
Building your latest patch with master now.

Mark

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 07/21/2018 03:09 AM, Mark Spieth wrote:
> On 7/21/2018 9:04 AM, Peter Bennett wrote:
>>
>>
>> On 07/20/2018 06:19 PM, Mark Spieth wrote:
>>> On 7/21/2018 3:48 AM, Peter Bennett wrote:
>>>> Hi Mark
>>>>
>>>> I assume you created the android OpenSLES audio support in MythTV.
>>>> I found that audio.isPaused() always returns true, even in the
>>>> middle of playing audio and video. This was causing audio-video
>>>> sync to not work correctly. I fixed it by taking that check out. It
>>>> was not necessary to check audio.isPaused() before calling Pause().
>>>> I just made it unconditionally call Pause() whether it was already
>>>> paused or not. However I wonder if there is an error that is
>>>> causing it to always return isPaused() as true and whether that may
>>>> cause other problems.
>>>>
>>> That is strange. All the paused processing is in AudioOutputBase,
>>> and except for Jack and CA there is nothing in any of the other
>>> drivers.
>>> This is probably affecting many drivers then.
>>>
>>> Is this with or without stretch enabled? There is a bit of a
>>> difference there. I will dig some more today.
>>>
>>> Mark
>> Stretch was not enabled. This is the code that pauses audio right at
>> the start of live tv to allow the video to catch up. the audio was
>> never being paused. MythPlayer::PrebufferEnoughFrames - also
>> MythPlayer::AVSync where audio.isPaused is checked before audio.pause().
> What it should be doing is initially its in pause until bufferred
> mode. If you ry an unpause it will stay in that mode until the first
> audio data is written/queued.
> So when you start playing, yes it is in paused mode until you write
> the first audio data, when it un-pauses.
> If you are withholding audio data, then it will stay paused until you
> write the first data.
> Can you post a patch as to what you are trying to do and I will see if
> there is a better way.
> Building your latest patch with master now.
>
> Mark
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
It is working as it should with my latest patch.
The attached two patches are part of my big patch, and they remove tests
of audio.isPaused. Those audio.isPaused calls are in the existing code
and are not necessary since you can call Pause when it is paused anyway.
If you revert these two patches, then start Live TV on Shield, it jerks
and hiccups forever, until you manually pause and resume.
I think it is best to leave these two places not calling isPaused. I was
just concerned that other things may be affected by the isPause being wrong.

Peter
Re: audio.isPaused not working for OpenSLES audio [ In reply to ]
On 7/21/2018 10:14 PM, Peter Bennett wrote:
>
>
> On 07/21/2018 03:09 AM, Mark Spieth wrote:
>> On 7/21/2018 9:04 AM, Peter Bennett wrote:
>>>
>>>
>>> On 07/20/2018 06:19 PM, Mark Spieth wrote:
>>>> On 7/21/2018 3:48 AM, Peter Bennett wrote:
>>>>> Hi Mark
>>>>>
>>>>> I assume you created the android OpenSLES audio support in MythTV.
>>>>> I found that audio.isPaused() always returns true, even in the
>>>>> middle of playing audio and video. This was causing audio-video
>>>>> sync to not work correctly. I fixed it by taking that check out.
>>>>> It was not necessary to check audio.isPaused() before calling
>>>>> Pause(). I just made it unconditionally call Pause() whether it
>>>>> was already paused or not. However I wonder if there is an error
>>>>> that is causing it to always return isPaused() as true and whether
>>>>> that may cause other problems.
>>>>>
>>>> That is strange. All the paused processing is in AudioOutputBase,
>>>> and except for Jack and CA there is nothing in any of the other
>>>> drivers.
>>>> This is probably affecting many drivers then.
>>>>
>>>> Is this with or without stretch enabled? There is a bit of a
>>>> difference there. I will dig some more today.
>>>>
>>>> Mark
>>> Stretch was not enabled. This is the code that pauses audio right at
>>> the start of live tv to allow the video to catch up. the audio was
>>> never being paused. MythPlayer::PrebufferEnoughFrames - also
>>> MythPlayer::AVSync where audio.isPaused is checked before
>>> audio.pause().
>> What it should be doing is initially its in pause until bufferred
>> mode. If you ry an unpause it will stay in that mode until the first
>> audio data is written/queued.
>> So when you start playing, yes it is in paused mode until you write
>> the first audio data, when it un-pauses.
>> If you are withholding audio data, then it will stay paused until you
>> write the first data.
>> Can you post a patch as to what you are trying to do and I will see
>> if there is a better way.
>> Building your latest patch with master now.
>>
>> Mark
> It is working as it should with my latest patch.
> The attached two patches are part of my big patch, and they remove
> tests of audio.isPaused. Those audio.isPaused calls are in the
> existing code and are not necessary since you can call Pause when it
> is paused anyway.
> If you revert these two patches, then start Live TV on Shield, it
> jerks and hiccups forever, until you manually pause and resume.
> I think it is best to leave these two places not calling isPaused. I
> was just concerned that other things may be affected by the isPause
> being wrong.
I'm concerned with races happening when you do want to pause manually
due to the threads involved with this solution.
Still looking at the consequences.
It may be worth while setting up a unit test but I haven't looked into
the framework that's in place. I tend to use google test and google mock
for all mine because you can fake the surrounding components easily.
This would show up any faults with the audio subsystem, and there appear
to be some.
Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org