Ticket #3379: set_cd_speed_final.diff
File set_cd_speed_final.diff, 5.6 KB (added by , 17 years ago) |
---|
-
mythplugins/mythmusic/mythmusic/cddecoder.h
36 36 Metadata *getLastMetadata(void); 37 37 void commitMetadata(Metadata *mdata); 38 38 void setDevice(const QString &dev) { devicename = dev; } 39 void setCDSpeed(int speed); 39 40 40 41 private: 41 42 void run(); -
mythplugins/mythmusic/mythmusic/cddecoder.cpp
13 13 #include "metadata.h" 14 14 15 15 #include <mythtv/mythcontext.h> 16 #include <mythtv/mythmediamonitor.h> 16 17 17 18 CdDecoder::CdDecoder(const QString &file, DecoderFactory *d, QIODevice *i, 18 19 AudioOutput *o) … … 139 140 output()->SetSourceBitrate(44100 * 2 * 16); 140 141 } 141 142 143 setCDSpeed(2); 142 144 inited = TRUE; 143 145 return TRUE; 144 146 } … … 150 152 151 153 void CdDecoder::deinit() 152 154 { 155 setCDSpeed(-1); 153 156 if (paranoia) 154 157 paranoia_free(paranoia); 155 158 if (device) … … 249 252 deinit(); 250 253 } 251 254 255 void CdDecoder::setCDSpeed(int speed) 256 { 257 QMutexLocker locker(getMutex()); 258 MediaMonitor::SetCDSpeed(devicename, speed); 259 } 260 252 261 int CdDecoder::getNumTracks(void) 253 262 { 254 263 int cd = cd_init_device((char *)devicename.ascii()); -
mythtv/libs/libmythtv/DVDRingBuffer.cpp
1207 1207 */ 1208 1208 void DVDRingBufferPriv::SetDVDSpeed(void) 1209 1209 { 1210 QMutexLocker lock(&seekLock); 1210 1211 int dvdDriveSpeed = gContext->GetNumSetting("DVDDriveSpeed", 12); 1211 1212 SetDVDSpeed(dvdDriveSpeed); 1212 1213 } … … 1215 1216 */ 1216 1217 void DVDRingBufferPriv::SetDVDSpeed(int speed) 1217 1218 { 1218 MediaMonitor *mon = MediaMonitor::GetMediaMonitor(); 1219 if (mon != NULL) 1220 { 1221 MythMediaDevice *pMedia = mon->GetMedia(dvdFilename); 1222 if (pMedia && mon->ValidateAndLock(pMedia)) 1223 { 1224 pMedia->setSpeed(speed); 1225 mon->Unlock(pMedia); 1226 } 1227 } 1219 MediaMonitor::SetCDSpeed(dvdFilename, speed); 1228 1220 } 1229 1221 1230 1222 /**\brief returns seconds left in the title -
mythtv/libs/libmyth/mythmediamonitor.h
57 57 void ChooseAndEjectMedia(void); 58 58 59 59 static MediaMonitor *GetMediaMonitor(void); 60 static void SetCDSpeed(const char *device, int speed); 60 61 61 62 bool ValidateAndLock(MythMediaDevice *pMedia); 62 63 void Unlock(MythMediaDevice *pMedia); -
mythtv/libs/libmyth/mythmediamonitor.cpp
73 73 return c_monitor; 74 74 } 75 75 76 void MediaMonitor::SetCDSpeed(const char *device, int speed) 77 { 78 MediaMonitor *mon = GetMediaMonitor(); 79 if (mon != NULL) 80 { 81 MythMediaDevice *pMedia = mon->GetMedia(device); 82 if (pMedia && mon->ValidateAndLock(pMedia)) 83 { 84 pMedia->setSpeed(speed); 85 mon->Unlock(pMedia); 86 } 87 } 88 } 89 76 90 // When ejecting one of multiple devices, present a nice name to the user 77 91 static const QString DevName(MythMediaDevice *d) 78 92 { -
mythtv/libs/libmyth/mythcdrom-linux.cpp
364 364 365 365 if (stat(m_DevicePath, &st) == -1 ) 366 366 { 367 VERBOSE(VB_ IMPORTANT, LOC_ERR +367 VERBOSE(VB_MEDIA, LOC_ERR + 368 368 QString("setSpeed() Failed. device %1 not found") 369 369 .arg(m_DevicePath)); 370 370 return; … … 372 372 373 373 if (!S_ISBLK(st.st_mode)) 374 374 { 375 VERBOSE(VB_ IMPORTANT, LOC_ERR +375 VERBOSE(VB_MEDIA, LOC_ERR + 376 376 "MythCDROMLinux::SetSpeed() Failed. Not a block device"); 377 377 return; 378 378 } 379 379 380 380 if ((fd = open(m_DevicePath, O_RDWR | O_NONBLOCK)) == -1) 381 381 { 382 VERBOSE(VB_ IMPORTANT, LOC_ERR +382 VERBOSE(VB_MEDIA, LOC_ERR + 383 383 "Changing CD/DVD speed needs write access"); 384 384 return; 385 385 } … … 395 395 { 396 396 rate = 0; 397 397 buffer[0] = 4; 398 VERBOSE(VB_ IMPORTANT, LOC + "Restored CD/DVD Speed");398 VERBOSE(VB_MEDIA, LOC + "Restored CD/DVD Speed"); 399 399 break; 400 400 } 401 401 default: … … 405 405 406 406 rate = (speed > 0 && speed < 100) ? speed * 177 : speed; 407 407 408 VERBOSE(VB_ IMPORTANT, LOC + QString("Limit CD/DVD Speed to %1KB/s")408 VERBOSE(VB_MEDIA, LOC + QString("Limit CD/DVD Speed to %1KB/s") 409 409 .arg(rate)); 410 410 break; 411 411 } … … 443 443 if (ioctl(fd, CDROM_SELECT_SPEED, speed) < 0) 444 444 { 445 445 if (ioctl(fd, SG_IO, &sghdr) < 0) 446 VERBOSE(VB_ IMPORTANT, LOC_ERR + "Limit CD/DVD Speed Failed");446 VERBOSE(VB_MEDIA, LOC_ERR + "Limit CD/DVD Speed Failed"); 447 447 } 448 448 else 449 VERBOSE(VB_ IMPORTANT, LOC + "CD/DVD Speed Set Successful");449 VERBOSE(VB_MEDIA, LOC + "CD/DVD Speed Set Successful"); 450 450 451 451 close(fd); 452 452 }