Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:54:46+00:00 2026-06-13T21:54:46+00:00

I’m experiencing a problem whereby my application works fine when the screen is active,

  • 0

I’m experiencing a problem whereby my application works fine when the screen is active, but, when the screen is locked or asleep, a certain bit of the code seems to pause the app indefinitely, without actually crashing.

The app uses AVAudioPlayers and boost::threads to play some music tracks. When a track ends, lots of setup has to be called in order for the new track to be prepared. At the same time, the app has to pause for a few seconds. This parallel activity is achieved with boost::threads.

When the screen is active, this all works fine. However, when the screen is inactive, the new track is never played. There is no crash, and, using breakpoints to debug, it seems that the app simply hangs on a certain line – the line changes from debug session to debug session – and gets stuck. Never have I so hoped for an EXC_BAD_ACCESS – but there’s nothing. No hint of why the code is hanging.

Could it be that my main thread is blocked? I use a few performSelectorOnMainThread calls, but I’ve deactivated them when the screen is locked using applicationWillResignActive. However, this hasn’t solved the problem.

The boost::thread in which it seems to hang is as follows:

void MyClass::loopThread(int waitSeconds)
{
    loopScheduled = true;

    sleep(waitSeconds);

    if ( loopScheduled == true ) {

        if (engine_isRunning()) {
            joinEngineThread();
        }
        startEngineThread();
        ((CPlusPlus*)m_obj)->markAsPlaying();
    }
}

It seems to hang around the

if ( loopScheduled == true ) {

line.

What’s going on in this thread is that other parallel threads can set loopScheduled to false during the sleep() call, and if loopScheduled is false, the later methods aren’t called.

However, in terms of the problem I’m having, loopScheduled should be irrelevant – it’s not being set to false by any other method, and is still true after the sleep() call.

Does anyone have any idea what could be going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:54:47+00:00Added an answer on June 13, 2026 at 9:54 pm

    I found the problem. The Audio session was ending while the app was paused between tracks.

    It turns out that, when the screen is locked or asleep or the application is in the background, when the last AVAudioPlayer finishes playing the audio session finishes. This means that new AVAudioPlayers can no longer be prepared or played – so the new track cannot be played.

    In order to get around this problem, I am now playing a silent file during the pause between tracks. This keeps the audio session going, which means that the new track plays when it is instructed to play.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.