Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2570 from hmis/patch-1

fixed: reading cdda via usb fails when requesting more than 10 sectors per read.
  • Loading branch information...
commit b8700a268adfa4adfecbc3815052e69dde394a36 2 parents e59356d + 0aaeb72
@wsoltys wsoltys authored
Showing with 28 additions and 7 deletions.
  1. +27 −7 xbmc/filesystem/CDDAFile.cpp
  2. +1 −0  xbmc/filesystem/CDDAFile.h
View
34 xbmc/filesystem/CDDAFile.cpp
@@ -40,6 +40,7 @@ CFileCDDA::CFileCDDA(void)
m_lsnCurrent = CDIO_INVALID_LSN;
m_lsnEnd = CDIO_INVALID_LSN;
m_cdio = CLibcdio::GetInstance();
+ m_iSectorCount = 52;
}
CFileCDDA::~CFileCDDA(void)
@@ -120,7 +121,8 @@ unsigned int CFileCDDA::Read(void* lpBuf, int64_t uiBufSize)
if (!m_pCdIo || !g_mediaManager.IsDiscInDrive())
return 0;
- int iSectorCount = (int)uiBufSize / CDIO_CD_FRAMESIZE_RAW;
+ // limit number of sectors that fits in buffer by m_iSectorCount
+ int iSectorCount = std::min((int)uiBufSize / CDIO_CD_FRAMESIZE_RAW, m_iSectorCount);
if (iSectorCount <= 0)
return 0;
@@ -129,14 +131,32 @@ unsigned int CFileCDDA::Read(void* lpBuf, int64_t uiBufSize)
if (m_lsnCurrent + iSectorCount > m_lsnEnd)
iSectorCount = m_lsnEnd - m_lsnCurrent;
- int iret = m_cdio->cdio_read_audio_sectors(m_pCdIo, lpBuf, m_lsnCurrent, iSectorCount);
-
- if ( iret != DRIVER_OP_SUCCESS)
+ // The loop tries to solve read error problem by lowering number of sectors to read (iSectorCount).
+ // When problem is solved the proper number of sectors is stored in m_iSectorCount
+ int big_iSectorCount = iSectorCount;
+ while (iSectorCount > 0)
{
- CLog::Log(LOGERROR, "file cdda: Reading %d sectors of audio data starting at lsn %d failed with error code %i", iSectorCount, m_lsnCurrent, iret);
- return 0;
+ int iret = m_cdio->cdio_read_audio_sectors(m_pCdIo, lpBuf, m_lsnCurrent, iSectorCount);
+
+ if (iret == DRIVER_OP_SUCCESS)
+ {
+ // If lower iSectorCount solved the problem limit it's value
+ if (iSectorCount < big_iSectorCount)
+ {
+ m_iSectorCount = iSectorCount;
+ }
+ break;
+ }
+
+ // iSectorCount is low so it cannot solve read problem
+ if (iSectorCount <= 10)
+ {
+ CLog::Log(LOGERROR, "file cdda: Reading %d sectors of audio data starting at lsn %d failed with error code %i", iSectorCount, m_lsnCurrent, iret);
+ return 0;
+ }
+
+ iSectorCount = 10;
}
-
m_lsnCurrent += iSectorCount;
return iSectorCount*CDIO_CD_FRAMESIZE_RAW;
View
1  xbmc/filesystem/CDDAFile.h
@@ -53,6 +53,7 @@ class CFileCDDA : public IFile
lsn_t m_lsnStart; // Start of m_iTrack in logical sector number
lsn_t m_lsnCurrent; // Position inside the track in logical sector number
lsn_t m_lsnEnd; // End of m_iTrack in logical sector number
+ int m_iSectorCount; // max number of sectors to read at once
boost::shared_ptr<MEDIA_DETECT::CLibcdio> m_cdio;
};
}

0 comments on commit b8700a2

Please sign in to comment.
Something went wrong with that request. Please try again.