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

An improper locking bug(e.g., deadlock) on the lock &mutex #33

Open
ryancaicse opened this issue Sep 14, 2021 · 1 comment
Open

An improper locking bug(e.g., deadlock) on the lock &mutex #33

ryancaicse opened this issue Sep 14, 2021 · 1 comment

Comments

@ryancaicse
Copy link

Hi, developers, thank you for your checking. It seems the lock mutex is not released correctly when num_bytes>0 in the function ao_plugin_play? Should it be a bug or on purpose?

int ao_plugin_play(ao_device *device, const char *output_samples,
		uint_32 num_bytes)
{
  pthread_mutex_lock(&mutex);
   ...;
    if(num_bytes>0){
      long wait = internal->buffersize*1000/(device->output_channels*device->bytewidth*device->rate);
      pthread_mutex_unlock(&mutex);
      wait = (wait/8)*1000;
      if(wait<1)wait=1;
      if(wait>500000)wait=500000;
      usleep(wait);
      pthread_mutex_lock(&mutex);
    }else{
      pthread_mutex_unlock(&mutex);
      break;
    }
  }
  return 1;
}

if(num_bytes>0){
long wait = internal->buffersize*1000/(device->output_channels*device->bytewidth*device->rate);
pthread_mutex_unlock(&mutex);
wait = (wait/8)*1000;
if(wait<1)wait=1;
if(wait>500000)wait=500000;
usleep(wait);
pthread_mutex_lock(&mutex);
}else{
pthread_mutex_unlock(&mutex);
break;
}

Best,

@ryancaicse
Copy link
Author

Hi, developers, any comments are highly appreciated!
@sahaRatul

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

No branches or pull requests

1 participant