Results 1 to 8 of 8

Thread: How to read a CD

  1. #1
    Join Date
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to read a CD

    I am developing a Qt application that needs to read from the CD drive, specifically audio CDs. I have included libkcompactdisc and have created a KCompactDisc object. It sees the drive and identifies the drive name, manufacturer, etc. but cannot see the disc in the drive. The OS knows there is a disc in the drive. Every other application on the system sees the CD. But the KCompactDisc object tells me there is no disc. In the rather sparse documentation for this library, I noticed there were functions for Disc Title, Disc Length, and others, as well as commands for play, stop, etc. But there does not seem to be a read or load command. SO HOW DO I GET THE OBJECT TO READ THE FREAKING DISC??? Sorry for shouting but I am going crazy here. Here is the code snippet I am using.


    Qt Code:
    1. Disc = new KCompactDisc(KCompactDisc::Synchronous);
    2. Disc->setAutoMetadataLookup(true);
    3. x = Disc->setDevice(Disc->defaultCdromDeviceName(),50,true,Disc->audioSystems().at(0));
    4. QObject::connect(Disc,SIGNAL(discInformation(KCompactDisc::DiscInfo)),this,SLOT(DisplayDiscInfo(KCompactDisc::DiscInfo)));
    5. ui->txtCDInfo->setText(Disc->defaultCdromDeviceName() + "\n"
    6. + Disc->discArtist() + "\n" +
    7. Disc->discTitle() + "\n" +
    8. "Disc ID: " + QString::number(Disc->discId()) + "\n"
    9. + "Disc Length: " + QString::number(Disc->discLength()));
    To copy to clipboard, switch view to plain text mode 

    The text box shows the name of the drive, blank lines for the artist and title, and zeroes for Disc ID and Length. When I set a breakpoint at the last line and look at the object, the Disc Status is no disc. Any insight you guys can provide would be appreciated. Thanks.
    Last edited by wysota; 21st March 2010 at 10:59.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to read a CD

    What is the device name returned by defaultCdromDeviceName()? By the way, the method is static. Please also check that deviceName(), deviceModel(), deviceVendor() and deviceRevision() match what you would expect. Maybe you are just reading the wrong drive.

    Calling refreshListOfCdromDevices() prior to doing all that might help too.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to read a CD

    Thanks. I should have included more information about the system and the drive. This is a netbook running Ubuntu Netbook Remix. It has one CD drive, an external dvd-rw from Gear Head. The information provided by the KCompactDisc calls is this:

    Device Name: [DVDRW - Slimtype - DVD A DS8A4S]
    Device Model: DVD A DS8A4S
    Device Vendor: Slimtype
    Device Revision:

    Also, where is the refreshListOfCdromDevices() call located. It doesn't seem to be in KCompactDisc.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to read a CD

    Last time I needed to read a cdrom I never bothered with any library. I used the 'proc' fs to figure out the device name and then read that device directly (eg. open("/dev/sdc",O_RDONLY)).

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to read a CD

    Quote Originally Posted by skepticalgeek View Post
    Thanks. I should have included more information about the system and the drive. This is a netbook running Ubuntu Netbook Remix. It has one CD drive, an external dvd-rw from Gear Head. The information provided by the KCompactDisc calls is this:

    Device Name: [DVDRW - Slimtype - DVD A DS8A4S]
    Device Model: DVD A DS8A4S
    Device Vendor: Slimtype
    Device Revision:
    What about the UDI/URI?

    Also, where is the refreshListOfCdromDevices() call located. It doesn't seem to be in KCompactDisc.
    Hmm... I can't find it now. Maybe it was a private function/method...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to read a CD

    Device UDI: /org/freedesktop/Hal/devices/storage_serial_Slimtype_DVD_A_DS8A4S_FFFFFFFE0D912 150372883_0_0
    Device URL: file:///dev/sr0

    Thanks for the feedback. Basically, I want to read the artist information, trqack offsets, and other information I need to get the CD information from freedb. This project is a jukebox program with an integrated CD ripper, or at least it will be once I figure out how to read the CD.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to read a CD

    The data seems fine. Solid seems to be working and returning proper data. If I had to guess, I would say the problem is the data arrives asynchronously and you have to wait for the discInformation() or discChanged() signal. If you get them (you might have to reinsert the disc into the drive) then you know you get proper information and can try to read them.

    You can also try calling metadataLookup() after setting the device. Just bouncing off ideas... I'm running out of them anyway, the class is quite simple, there is hardly anything that could fail here. Could you try preparing a minimal compilable example reproducing the problem? Just please keep it minimal and compilable

    By the way, I found the refreshListOfCdromDevices() function. It's a static function in libkcompactdisc.cpp.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to read a CD

    Solved it. Turns out I trued when I should have falsed. In the line:
    x = Disc->setDevice(Disc->defaultCdromDeviceName(),50,true,Disc->audioSystems().at(0));

    the parameter true should be false. Once I changeThanks for all the help.

Similar Threads

  1. QTreeWidget read only?
    By td in forum Newbie
    Replies: 4
    Last Post: 21st July 2009, 12:28
  2. Read-only QCheckBox
    By alu23 in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2008, 16:25
  3. Best way to read xml
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 17:38
  4. How to read CD with read?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 29th June 2007, 08:20
  5. How to I get read of the message
    By jcr in forum General Discussion
    Replies: 1
    Last Post: 16th April 2007, 15:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.