}
}
- if (blackbird_initialize_codec(dev) < 0) {
+ if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) {
if (drv)
drv->request_release(drv);
unlock_kernel();
fh->mpegq.field);
unlock_kernel();
+ atomic_inc(&dev->core->mpeg_users);
+
return 0;
}
struct cx8802_dev *dev = fh->dev;
struct cx8802_driver *drv = NULL;
- if (dev->mpeg_active)
+ if (dev->mpeg_active && atomic_read(&dev->core->mpeg_users) == 1)
blackbird_stop_codec(dev);
cx8802_cancel_buffers(fh->dev);
if (drv)
drv->request_release(drv);
+ atomic_dec(&dev->core->mpeg_users);
+
return 0;
}