async System.Threading.Tasks.Task <byte[]> GetCDTextArray(Windows.Devices.Custom.CustomDevice device) { byte[] Array = null; if (device != null) { var inputBuffer = new byte[4]; inputBuffer[0] = 0x05; var outputBuffer = new byte[4]; try { uint r = await device.SendIOControlAsync( readTableEx, inputBuffer.AsBuffer(), outputBuffer.AsBuffer()); if (r > 0) { int i_text = 2 + (outputBuffer[0] << 8) + outputBuffer[1]; if (i_text > 4) { Array = new byte[i_text]; r = await device.SendIOControlAsync( readTableEx, inputBuffer.AsBuffer(), Array.AsBuffer()); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception while reading CD Text Array : " + ex.Message); } } return(Array); }
private async System.Threading.Tasks.Task <TOCTrack[]> GetCDSectorArray(Windows.Devices.Custom.CustomDevice device) { TOCTrack[] Array = null; if (device != null) { var outputBuffer = new byte[MAXIMUM_NUMBER_TRACKS * 8 + 4]; try { uint r = await device.SendIOControlAsync( readTable, null, outputBuffer.AsBuffer()); if (r > 0) { int i_tracks = outputBuffer[3] - outputBuffer[2] + 1; Array = new TOCTrack[i_tracks + 1]; if (Array != null) { for (int i = 0; (i <= i_tracks) && (4 + i * 8 + 4 + 3 < r); i++) { int sectors = MSF_TO_LBA2( outputBuffer[4 + i * 8 + 4 + 1], outputBuffer[4 + i * 8 + 4 + 2], outputBuffer[4 + i * 8 + 4 + 3]); TOCTrack toc = new TOCTrack(); if (toc != null) { toc.Position = sectors; toc.bData = ((outputBuffer[4 + i * 8 + 1] & 0x04) == 0x04); Array[i] = toc; System.Diagnostics.Debug.WriteLine("track number: " + i.ToString() + " sectors: " + sectors.ToString() + (((outputBuffer[4 + i * 8 + 1] & 0x04) == 0x04) ? " data " : "") + (((outputBuffer[4 + i * 8 + 1] & 0x04) == 0x00) ? " audio " : "") + ((outputBuffer[4 + i * 8 + 2] == 0xAA) ? " lead-out " : "")); } } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception while reading CD Sector Array : " + ex.Message); } } return(Array); }
private async System.Threading.Tasks.Task <int[]> GetCDSectorArray(Windows.Devices.Custom.CustomDevice device) { int[] Array = null; if (device != null) { var outputBuffer = new byte[MAXIMUM_NUMBER_TRACKS * 8 + 4]; try { uint r = await device.SendIOControlAsync( readTable, null, outputBuffer.AsBuffer()); if (r > 0) { int i_tracks = outputBuffer[3] - outputBuffer[2] + 1; Array = new int[i_tracks + 1]; if (Array != null) { for (int i = 0; (i <= i_tracks) && (4 + i * 8 + 4 + 3 < r); i++) { int sectors = MSF_TO_LBA2( outputBuffer[4 + i * 8 + 4 + 1], outputBuffer[4 + i * 8 + 4 + 2], outputBuffer[4 + i * 8 + 4 + 3]); Array[i] = sectors; System.Diagnostics.Debug.WriteLine("track number: " + i.ToString() + " sectors: " + sectors.ToString()); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception while reading CD Sector Array : " + ex.Message); } } return(Array); }