Thursday, 4 July 2013

AudioCD. Week 2.

Plan for second week was: "New implementation of AudioCdCollection. After this step is completed, Amarok should support AudioCd in a same way as before." New implementation of  AudioCdCollection was done during first week, so second week began with a testing of new AudioCD collection implementation. At the beginning of a week I did not found any problem and decided to continue my work with what was planned on a third week: "Decision about track enumeration routine should be done." 

I've created preliminary list of software which operates with CD and should be checked: k3b, kscd, vlc. I've started my work with investigation how kscd enumerates tracks. Kscd uses libmusicbrainz3. So I've tested enumeration of CD with libmusicbrainz3 in Amarok. There is new branch in my personal clone called musicbrainz, where you can find this code. If you don't need information about AudioCD from musicbrainz then libdicsid can be used for enumeration. For now main problem with libmusicbrainz3 is that CD-Text doesn't available out of the box.

At the end of last week I've discovered bug in AudioCD collection. It is known issue (see bug 319036) that AudioCD collection doesn't disappear from Collection View when CD is ejected from outside Amarok and I did not pay much attention to it during testing. But I discovered that AudioCD collections also not always appears in Amarok if CD was not inserted before the start of Amarok. So it turned out that problem is in receiving signals from Solid.

Let me start explanation with describing AudioCD detection workflow. First we check among devices which were inserted before start of the Amarok is there AudioCd:
QList<Solid::Device> devices = Solid::Device::listFromType( Solid::DeviceInterface::OpticalDisc );
foreach( const Solid::Device &device, devices )
{
    if( isAudioCD( device.udi() ) )
        // create collection
}   

If so we create collection for it. Then we connect solid device detection and solid device ejection events to some slots:
connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)), 
         SLOT(slotAddSolidDevice(const QString&)) );
connect( Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)), 
         SLOT(slotRemoveSolidDevice(const QString&)) );
As I wrote above there is problem with receiving signals from Solid. So my first thought was that I use functionality provided by Solid in a wrong way, so I've created a small snippet in order to test it. And it works perfectly it detects AudioCD on startup, reacts on CD insertion and ejection. So problem is somewhere in Amarok. Then I was faced with very strange behaviour. Imagine that there is running instance of Amarok with AudioCd collection in collections and there is running instance of solid-tester, I eject CD using button on CD-Rom and there is no any effect neither in Amarok nor in solid-test, but when I close Amarok, solid-tester reports about ejection.

I would love to tell you that I discovered what is wrong, but no. So wait for good news :)

UPD 09.07.2013 I wrote that  "K3b uses libmusicbraimz3" It is wrong, I meant kscd.

2 comments:

  1. Just a thought... does Dolphin react on disc ejection when Amarok ist running? Does it react when Amarok and solid-tester are running?

    ReplyDelete
    Replies
    1. Good point, thanks. I'll check it soon.

      Delete