Fixed play button and minor bugs.

CQTexperiment
vspader 2005-06-07 04:01:00 +00:00
parent 143190acf4
commit 0dd0363709
14 changed files with 1109 additions and 811 deletions

View File

@ -1,3 +1,9 @@
Awesomized id3v2 and tagging support courtesy of TagLib.
Dramatically improved performance of monkeys audio codec.
minor bug fixes.
SHN and Wavpack support.
AAC support.
Fixed 10.3 bug where files would not be removed from the playlist.
Added tooltips and control menu.
Fixed play button so it now plays the currently selected song if no song is playing. Otherwise, it does pause/resume.
TODO: have button images change, play to pause...shuffle and repeat

View File

@ -202,6 +202,7 @@
29B97318FDCFA39411CA2CEA,
8E10DBEF084BBCF00013815C,
8E5A90B0084CBC2F00AE6D62,
8E8F3F9B0855499500BCF803,
);
isa = PBXGroup;
name = Resources;
@ -383,6 +384,7 @@
8E6F2A1908480D010011F126,
8E10DBF0084BBCF00013815C,
8E5A90B1084CBC2F00AE6D62,
8E8F3F9C0855499500BCF803,
);
isa = PBXResourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -1099,6 +1101,20 @@
settings = {
};
};
8E8F3F9B0855499500BCF803 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text;
path = README;
refType = 4;
sourceTree = "<group>";
};
8E8F3F9C0855499500BCF803 = {
fileRef = 8E8F3F9B0855499500BCF803;
isa = PBXBuildFile;
settings = {
};
};
8EAB85FC0846889B000A9CEC = {
isa = PBXFileReference;
lastKnownFileType = image.png;

View File

@ -255,20 +255,20 @@
<array>
<string>29B97314FDCFA39411CA2CEA</string>
<string>080E96DDFE201D6D7F000001</string>
<string>8EF6FA64082DA525006F7BE6</string>
<string>8E47215C08318D12001F89FA</string>
<string>29B97317FDCFA39411CA2CEA</string>
<string>1C37FABC05509CD000000102</string>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>23</integer>
<integer>5</integer>
<integer>1</integer>
<integer>32</integer>
<integer>24</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 0}, {186, 565}}</string>
<string>{{0, 61}, {186, 565}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -305,7 +305,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>ShnFile.m</string>
<string>Changelog</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
@ -313,11 +313,11 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>ShnFile.m</string>
<string>Changelog</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>8EB30E5F0854C90E009EA87F</string>
<string>8E8F3FB008554B8000BCF803</string>
<key>history</key>
<array>
<string>8EF6FACD082DAA2B006F7BE6</string>
@ -330,50 +330,34 @@
<string>8E652A34083E1A7900A7AF1B</string>
<string>8E652A35083E1A7900A7AF1B</string>
<string>8E652A36083E1A7900A7AF1B</string>
<string>8EDCBEF40840FA2200F5C7E3</string>
<string>8EDC88A90842F8DE007D1532</string>
<string>8EDC88B50842F936007D1532</string>
<string>8ED833CD08457E6B0033CDBD</string>
<string>8E6F2A2708480D900011F126</string>
<string>8E10DC00084BBE490013815C</string>
<string>8E10DC02084BBE490013815C</string>
<string>8E94D9D2084BEA32007F0AEB</string>
<string>8E94D9D3084BEA32007F0AEB</string>
<string>8E5A90B7084CC25900AE6D62</string>
<string>8E5A90B8084CC25900AE6D62</string>
<string>8EA0A215084CC43F008DFEC9</string>
<string>8EA0A216084CC43F008DFEC9</string>
<string>8EA0A21A084CC43F008DFEC9</string>
<string>8E14E4A5084D089100246BCC</string>
<string>8EC18D9F084E3D8200AE0BA9</string>
<string>8E9E2E81084FA7E400599965</string>
<string>8EC156F4084FEB8900BB24E8</string>
<string>8EC156F5084FEB8900BB24E8</string>
<string>8E2752B70850A92E001618CD</string>
<string>8E2BC83D0850F56200BEAC36</string>
<string>8EE2A5B808511A1800367489</string>
<string>8EE2A5B908511A1800367489</string>
<string>8E72BC630851408F00E34F1D</string>
<string>8E72BC640851408F00E34F1D</string>
<string>8EFC6D18085376D100C67D06</string>
<string>8EFC6DE7085380B800C67D06</string>
<string>8EFC6DE8085380B800C67D06</string>
<string>8EFC6DF0085380B800C67D06</string>
<string>8EFC6DF3085380B800C67D06</string>
<string>8EFC6E29085386CE00C67D06</string>
<string>8E3EDBC9085477D0007C6A53</string>
<string>8E3EDBCF085477D0007C6A53</string>
<string>8E3EDBD1085477D0007C6A53</string>
<string>8E8BAF10085494E000E9F14D</string>
<string>8E8BAF780854976A00E9F14D</string>
<string>8E8BAF790854976A00E9F14D</string>
<string>8E8BAF7A0854976A00E9F14D</string>
<string>8E8BAF7C0854976A00E9F14D</string>
<string>8E91CCEE08549FEE0055EC68</string>
<string>8EB30D890854BEF1009EA87F</string>
<string>8EB30D8A0854BEF1009EA87F</string>
<string>8EB30DAC0854BFEE009EA87F</string>
<string>8EB30DAD0854BFEE009EA87F</string>
<string>8EB30DAE0854BFEE009EA87F</string>
<string>8EB30DDB0854C261009EA87F</string>
<string>8EB30DDC0854C261009EA87F</string>
@ -383,8 +367,25 @@
<string>8EB30DE00854C261009EA87F</string>
<string>8EB30E1F0854C36A009EA87F</string>
<string>8EB30E200854C36A009EA87F</string>
<string>8EB30E410854C6D6009EA87F</string>
<string>8EB30E1E0854C36A009EA87F</string>
<string>8E4D66E90854CD2C00816BEE</string>
<string>8E4D66EA0854CD2C00816BEE</string>
<string>8E4D67210854D2E700816BEE</string>
<string>8E4D67D40854E7B100816BEE</string>
<string>8E8F3F20085543D700BCF803</string>
<string>8E8F3F21085543D700BCF803</string>
<string>8E8F3F22085543D700BCF803</string>
<string>8E8F3F23085543D700BCF803</string>
<string>8E8F3F3F0855457A00BCF803</string>
<string>8E8F3F400855457A00BCF803</string>
<string>8E8F3F59085546B300BCF803</string>
<string>8E8F3F770855483300BCF803</string>
<string>8E8F3F780855483300BCF803</string>
<string>8E8F3F790855483300BCF803</string>
<string>8E8F3FA408554B8000BCF803</string>
<string>8E8F3FA508554B8000BCF803</string>
<string>8E8F3FA608554B8000BCF803</string>
<string>8E8F3FA708554B8000BCF803</string>
<string>8E8F3FA808554B8000BCF803</string>
</array>
<key>prevStack</key>
<array>
@ -452,46 +453,57 @@
<string>8E8BAEB308548C9600E9F14D</string>
<string>8E8BAEB708548C9600E9F14D</string>
<string>8E8BAF17085494E000E9F14D</string>
<string>8EB30D8D0854BEF1009EA87F</string>
<string>8EB30D8E0854BEF1009EA87F</string>
<string>8EB30D8F0854BEF1009EA87F</string>
<string>8EB30D900854BEF1009EA87F</string>
<string>8EB30D910854BEF1009EA87F</string>
<string>8EB30D920854BEF1009EA87F</string>
<string>8EB30D930854BEF1009EA87F</string>
<string>8EB30D940854BEF1009EA87F</string>
<string>8EB30D950854BEF1009EA87F</string>
<string>8EB30D960854BEF1009EA87F</string>
<string>8EB30D970854BEF1009EA87F</string>
<string>8EB30D980854BEF1009EA87F</string>
<string>8EB30D990854BEF1009EA87F</string>
<string>8EB30D9A0854BEF1009EA87F</string>
<string>8EB30D9B0854BEF1009EA87F</string>
<string>8EB30D9C0854BEF1009EA87F</string>
<string>8EB30D9D0854BEF1009EA87F</string>
<string>8EB30DB00854BFEE009EA87F</string>
<string>8EB30DB10854BFEE009EA87F</string>
<string>8EB30DB20854BFEE009EA87F</string>
<string>8EB30DB30854BFEE009EA87F</string>
<string>8EB30DB40854BFEE009EA87F</string>
<string>8EB30DB50854BFEE009EA87F</string>
<string>8EB30DE20854C261009EA87F</string>
<string>8EB30DE30854C261009EA87F</string>
<string>8EB30DE40854C261009EA87F</string>
<string>8EB30DE50854C261009EA87F</string>
<string>8EB30DE60854C261009EA87F</string>
<string>8EB30DE70854C261009EA87F</string>
<string>8EB30DE80854C261009EA87F</string>
<string>8EB30DE90854C261009EA87F</string>
<string>8EB30DEA0854C261009EA87F</string>
<string>8EB30DEB0854C261009EA87F</string>
<string>8EB30DEC0854C261009EA87F</string>
<string>8EB30DED0854C261009EA87F</string>
<string>8EB30DEE0854C261009EA87F</string>
<string>8EB30E210854C36A009EA87F</string>
<string>8EB30E220854C36A009EA87F</string>
<string>8EB30E230854C36A009EA87F</string>
<string>8EB30E420854C6D6009EA87F</string>
<string>8E8F3ED00855401300BCF803</string>
<string>8E8F3ED10855401300BCF803</string>
<string>8E8F3ED20855401300BCF803</string>
<string>8E8F3ED30855401300BCF803</string>
<string>8E8F3ED40855401300BCF803</string>
<string>8E8F3ED50855401300BCF803</string>
<string>8E8F3ED60855401300BCF803</string>
<string>8E8F3ED70855401300BCF803</string>
<string>8E8F3ED80855401300BCF803</string>
<string>8E8F3ED90855401300BCF803</string>
<string>8E8F3EDA0855401300BCF803</string>
<string>8E8F3EDB0855401300BCF803</string>
<string>8E8F3EDC0855401300BCF803</string>
<string>8E8F3EDD0855401300BCF803</string>
<string>8E8F3EDE0855401300BCF803</string>
<string>8E8F3EDF0855401300BCF803</string>
<string>8E8F3EE00855401300BCF803</string>
<string>8E8F3EE10855401300BCF803</string>
<string>8E8F3EE20855401300BCF803</string>
<string>8E8F3EE30855401300BCF803</string>
<string>8E8F3F26085543D700BCF803</string>
<string>8E8F3F27085543D700BCF803</string>
<string>8E8F3F28085543D700BCF803</string>
<string>8E8F3F29085543D700BCF803</string>
<string>8E8F3F2A085543D700BCF803</string>
<string>8E8F3F2B085543D700BCF803</string>
<string>8E8F3F2C085543D700BCF803</string>
<string>8E8F3F2D085543D700BCF803</string>
<string>8E8F3F2E085543D700BCF803</string>
<string>8E8F3F420855457A00BCF803</string>
<string>8E8F3F430855457A00BCF803</string>
<string>8E8F3F440855457A00BCF803</string>
<string>8E8F3F450855457A00BCF803</string>
<string>8E8F3F460855457A00BCF803</string>
<string>8E8F3F470855457A00BCF803</string>
<string>8E8F3F510855461700BCF803</string>
<string>8E8F3F5B085546B300BCF803</string>
<string>8E8F3F5C085546B300BCF803</string>
<string>8E8F3F5D085546B300BCF803</string>
<string>8E8F3F690855478900BCF803</string>
<string>8E8F3F7B0855483300BCF803</string>
<string>8E8F3F7C0855483300BCF803</string>
<string>8E8F3F7D0855483300BCF803</string>
<string>8E8F3F7E0855483300BCF803</string>
<string>8E8F3FA908554B8000BCF803</string>
<string>8E8F3FAA08554B8000BCF803</string>
<string>8E8F3FAB08554B8000BCF803</string>
<string>8E8F3FAC08554B8000BCF803</string>
<string>8E8F3FAD08554B8000BCF803</string>
<string>8E8F3FAE08554B8000BCF803</string>
</array>
</dict>
<key>SplitCount</key>
@ -503,14 +515,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {816, 404}}</string>
<string>{{0, 0}, {816, 578}}</string>
<key>RubberWindowFrame</key>
<string>2 122 1024 624 0 0 1024 746 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
<key>Proportion</key>
<string>404pt</string>
<string>578pt</string>
</dict>
<dict>
<key>ContentConfiguration</key>
@ -523,14 +535,14 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 409}, {816, 174}}</string>
<string>{{0, 583}, {816, 0}}</string>
<key>RubberWindowFrame</key>
<string>2 122 1024 624 0 0 1024 746 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
<key>Proportion</key>
<string>174pt</string>
<string>0pt</string>
</dict>
</array>
<key>Proportion</key>
@ -549,9 +561,9 @@
</array>
<key>TableOfContents</key>
<array>
<string>8EB30D9F0854BEF1009EA87F</string>
<string>8E8F3E480855374000BCF803</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>8EB30DA00854BEF1009EA87F</string>
<string>8E8F3E490855374000BCF803</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@ -686,8 +698,13 @@
<key>WindowOrderList</key>
<array>
<string>8EF6FAA6082DA951006F7BE6</string>
<string>/Users/xugg/Projects/Cog/Cog.xcode</string>
<string>8E8F3EE50855401300BCF803</string>
<string>8E8F3EE60855401300BCF803</string>
<string>8E7A9371083675B600771E14</string>
<string>1CD10A99069EF8BA00B06720</string>
<string>8E8F3E5B085538AB00BCF803</string>
<string>1C0AD2B3069F1EA900FABCE6</string>
<string>/Users/xugg/Projects/Cog/Cog.xcode</string>
</array>
<key>WindowString</key>
<string>2 122 1024 624 0 0 1024 746 </string>
@ -713,7 +730,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CD0528F0623707200166675</string>
<key>PBXProjectModuleLabel</key>
<string>shn.h</string>
<string>Sound.m</string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@ -769,7 +786,7 @@
<key>TableOfContents</key>
<array>
<string>8EF6FAA6082DA951006F7BE6</string>
<string>8EB30D540854BDDD009EA87F</string>
<string>8E8F3E8408553C6000BCF803</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
@ -811,8 +828,8 @@
<string>yes</string>
<key>sizes</key>
<array>
<string>{{0, 0}, {225, 206}}</string>
<string>{{225, 0}, {799, 206}}</string>
<string>{{0, 0}, {184, 198}}</string>
<string>{{184, 0}, {840, 198}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@ -827,8 +844,8 @@
<string>yes</string>
<key>sizes</key>
<array>
<string>{{0, 0}, {1024, 206}}</string>
<string>{{0, 206}, {1024, 378}}</string>
<string>{{0, 0}, {1024, 198}}</string>
<string>{{0, 198}, {1024, 386}}</string>
</array>
</dict>
</dict>
@ -875,14 +892,14 @@
<key>TableOfContents</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
<string>8E91CD450854A4BF0055EC68</string>
<string>8E8F3E55085538AB00BCF803</string>
<string>1C162984064C10D400B95A72</string>
<string>8E91CD460854A4BF0055EC68</string>
<string>8E91CD470854A4BF0055EC68</string>
<string>8E91CD480854A4BF0055EC68</string>
<string>8E91CD490854A4BF0055EC68</string>
<string>8E91CD4A0854A4BF0055EC68</string>
<string>8E91CD4B0854A4BF0055EC68</string>
<string>8E8F3E56085538AB00BCF803</string>
<string>8E8F3E57085538AB00BCF803</string>
<string>8E8F3E58085538AB00BCF803</string>
<string>8E8F3E59085538AB00BCF803</string>
<string>8E8F3E5A085538AB00BCF803</string>
<string>8E8F3E5B085538AB00BCF803</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debug</string>
@ -909,14 +926,12 @@
<key>Dock</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>1CDD528C0622207200134675</string>
<key>PBXProjectModuleLabel</key>
<string>PlaylistController.m</string>
<string>Sound.m</string>
<key>StatusBarVisibility</key>
<true/>
</dict>
@ -937,6 +952,8 @@
<string>342pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@ -972,8 +989,8 @@
<key>TableOfContents</key>
<array>
<string>1C530D57069F1CE1000CFCEE</string>
<string>8EA094300853FC4200EBC193</string>
<string>8EA094310853FC4200EBC193</string>
<string>8E4D67990854E47400816BEE</string>
<string>8E4D679A0854E47400816BEE</string>
<string>1CDD528C0622207200134675</string>
<string>1CD0528E0623707200166675</string>
</array>
@ -1036,7 +1053,7 @@
<key>TableOfContents</key>
<array>
<string>8E7A9371083675B600771E14</string>
<string>8E91CD4C0854A4BF0055EC68</string>
<string>8E8F3E5C085538AB00BCF803</string>
<string>1C78EAAC065D492600B07095</string>
</array>
<key>WindowString</key>
@ -1081,8 +1098,8 @@
<string>yes</string>
<key>sizes</key>
<array>
<string>{{0, 0}, {491, 168}}</string>
<string>{{0, 173}, {491, 270}}</string>
<string>{{0, 0}, {366, 168}}</string>
<string>{{0, 173}, {366, 270}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@ -1108,7 +1125,7 @@
<key>Frame</key>
<string>{{0, 0}, {1024, 583}}</string>
<key>RubberWindowFrame</key>
<string>4 123 1024 623 0 0 1024 746 </string>
<string>3 123 1024 623 0 0 1024 746 </string>
</dict>
<key>Module</key>
<string>PBXRunSessionModule</string>
@ -1131,18 +1148,18 @@
<key>TableOfContents</key>
<array>
<string>1C0AD2B3069F1EA900FABCE6</string>
<string>8EB30D820854BEA3009EA87F</string>
<string>8E8F3E4C085537A500BCF803</string>
<string>1CD0528B0623707200166675</string>
<string>8EB30D830854BEA3009EA87F</string>
<string>8E8F3E4D085537A500BCF803</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.run</string>
<key>WindowString</key>
<string>4 123 1024 623 0 0 1024 746 </string>
<string>3 123 1024 623 0 0 1024 746 </string>
<key>WindowToolGUID</key>
<string>1C0AD2B3069F1EA900FABCE6</string>
<key>WindowToolIsVisible</key>
<true/>
<false/>
</dict>
<dict>
<key>Identifier</key>

File diff suppressed because it is too large Load Diff

View File

@ -65,6 +65,8 @@
next = id;
pause = id;
pauseResume = id;
play = id;
playPauseResume = id;
prev = id;
resume = id;
seek = id;
@ -76,6 +78,7 @@
bitrateField = NSTextField;
lengthField = NSTextField;
playlistController = PlaylistController;
playlistView = PlaylistView;
positionSlider = TrackingSlider;
timeField = NSTextField;
};

View File

@ -7,14 +7,14 @@
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>334 667 253 44 0 0 1024 746 </string>
<string>243 676 346 44 0 0 1024 746 </string>
</dict>
<key>IBFramework Version</key>
<string>437.0</string>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>29</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>8B15</string>

Binary file not shown.

View File

@ -26,7 +26,7 @@
// DBLog(@"MOUSE DOWN");
if ([e type] == NSLeftMouseDown && [e clickCount] == 2)
{
[soundController playEntryAtIndex:[self selectedRow]];
[soundController play:self];
}
else
{
@ -56,7 +56,7 @@
}
else if (c == NSEnterCharacter || c == NSCarriageReturnCharacter)
{
[soundController playEntryAtIndex:[self selectedRow]];
[soundController play:self];
}
else
{

26
README
View File

@ -1,13 +1,31 @@
------------------------------------------------------------------------------------
NOTE ABOUT BUTTONS:
If you are under impression that the buttons are acting strange,
they actually may be acting as intended. The back button goes through
the history of the songs played, that is,it goes to the "previously played"
song, not just the one before it in the playlist. So, for example, if you
had shuffle mode on, and then turned it off, you could go back through the
songs played during shuffle mode. The forward button acts as expected, where
if shuffle is on, it will pick a random song, and if not it goes to the next
song in the playlist.
Please comment on, whether you like this behaviour or not!
------------------------------------------------------------------------------------
Cog is released under the GPL. See COPYING for details.
The libraries folder contains various decoding and tagging
libraries, which i have created Xcode projects for, and possibly modified
to make compile on OS X. The various libraries are under each of their own
licenses.
Please note that the source code may contain vulgar language as comments,
and in debugging messages. All Cog code is copywrited by me, and is licensed
under the GPL.
Please note that vulgar language may be contained in the source code. It is rated
M for mature by the ESRB, the MPAA, and whatever else deems it unsuitable for virgin
ears.
All Cog code is copywrited by me, and is licensed under the GPL.
If you would like the photoshop sources for the various icons and
graphics, please send me an email, and I will be happy to get them to you.
Share and enjoy.
--Vincent Spader (cog@badahol.net)
--Vincent Spader (vspader@users.sf.net)

View File

@ -34,12 +34,13 @@ enum
kCogBitrateUpdateMessage,
kCogLengthUpdateMessage,
kCogPositionUpdateMessage,
kCogFileChangedMessage
kCogFileChangedMessage,
kCogStatusUpdateMessage
};
enum
{
kCogStatusPaused,
kCogStatusPaused = 0,
kCogStatusStopped,
kCogStatusPlaying,
kCogStatusEndOfFile,
@ -66,6 +67,7 @@ enum
void *conversionBuffer;
int playbackStatus;
int oldPlaybackStatus; //For resuming
NSTimer *fillTimer; //used to wake up the filler thread
//semaphore_t semaphore; //used to wake up the filler thread
@ -110,6 +112,8 @@ enum
- (void)setThreadPolicy;
- (void)setPlaybackStatus:(int)s;
- (void)pause;
- (void)resume;
- (void)stop;

105
Sound.m
View File

@ -96,7 +96,8 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
// DBLog(@"FILE CHANGED!!!!!");
[sound sendPortMessage:kCogFileChangedMessage];
sound->readRingBuffer = [sound oppositeBuffer:sound->readRingBuffer];
sound->playbackStatus = kCogStatusPlaying;
[sound setPlaybackStatus:kCogStatusPlaying];
sound->currentPosition = 0;
@ -108,7 +109,8 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
if (sound->playbackStatus == kCogStatusEndOfPlaylist && amountAvailable == 0)
{
//Stop playback
sound->playbackStatus = kCogStatusPlaybackEnded;
[sound setPlaybackStatus:kCogStatusStopped];
// return err;
}
if (amountAvailable < ([sound->readRingBuffer bufferLength] - BUFFER_WRITE_CHUNK))
@ -181,7 +183,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
[self setThreadPolicy];
[[NSRunLoop currentRunLoop] run];
DBLog(@"THREAD EXIT!!!!!!!!!!!");
[pool release];
}
@ -204,7 +206,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
error = thread_policy_set(mach_thread_self(), THREAD_EXTENDED_POLICY, (thread_policy_t)&extendedPolicy, THREAD_EXTENDED_POLICY_COUNT);
if (error != KERN_SUCCESS) {
DBLog(@"Couldn't set feeder thread's extended policy");
DBLog(@"Couldnt set feeder thread's extended policy");
}
precedencePolicy.importance = FEEDER_THREAD_IMPORTANCE;
@ -221,9 +223,12 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
if (portMessage)
{
NSDate *date = [[NSDate alloc] init];
NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:20.0];//[[NSDate alloc] init];
[portMessage setMsgid:msgid];
DBLog(@"Sending message (nodata): %i", msgid);
[portMessage sendBeforeDate:date];
[date release];
@ -243,14 +248,27 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
if (portMessage)
{
NSDate *date = [[NSDate alloc] init];
NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:20.0];//give shit a little time to send, just in case...may come back to bite me
if ([date laterDate:[NSDate date]] != date)
{
DBLog(@"WTF");
}
[portMessage setMsgid:msgid];
[portMessage sendBeforeDate:date];
DBLog(@"Sending message: %i", msgid);
NS_DURING
[portMessage sendBeforeDate:date];
NS_HANDLER
NSRunAlertPanel(@"Error Panel", @"%@", @"OK", nil, nil,
localException);
NS_ENDHANDLER
[date release];
[portMessage release];
}
else {
DBLog(@"DIDNT SEND! ERROR");
}
}
@ -335,10 +353,21 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
}
else if (msgid == kCogEndOfPlaylistMessage)
{
playbackStatus = kCogStatusEndOfPlaylist;
[self setPlaybackStatus:kCogStatusEndOfPlaylist];
}
}
- (void)startPositionTimer
{
positionTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(sendPositionUpdate:) userInfo:nil repeats:YES];
}
- (void)stopPositionTimer
{
[positionTimer invalidate];
positionTimer = nil;
}
- (void)scheduleFillTimer
{
fillTimer = [NSTimer scheduledTimerWithTimeInterval:TIMEOUT target:self selector:@selector(fillBuffer:) userInfo:nil repeats:NO];
@ -360,8 +389,12 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
int convertedSize;
void *writePointer;
if (playbackStatus == kCogStatusPlaybackEnded)
if (playbackStatus == kCogStatusStopped)
{
DBLog(@"STOPPING");
[self stop];
return;
}
[writeLock lock];
@ -384,7 +417,8 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
// DBLog(@"NEXT!!!!");
[self sendPortMessage:kCogRequestNextFileMessage];
writeRingBuffer = [self oppositeBuffer:writeRingBuffer];
playbackStatus = kCogStatusEndOfFile;
[self setPlaybackStatus:kCogStatusEndOfFile];
}
// writePointer = (char *)writePointer + convertedSize;
@ -588,48 +622,65 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
[soundFile close];
}
- (void)setPlaybackStatus:(int)s
{
playbackStatus = s;
DBLog(@"SENDING MESSAGE");
[self sendPortMessage:kCogStatusUpdateMessage withData:&s ofSize:(sizeof(int))];
DBLog(@"MESSAGE SENT");
}
- (void)pause
{
[self stopAudioOutput];
playbackStatus = kCogStatusPaused;
[positionTimer invalidate];
positionTimer = nil;
oldPlaybackStatus = playbackStatus;
[self setPlaybackStatus:kCogStatusPaused];
[self stopPositionTimer];
}
- (void)resume
{
[self setPlaybackStatus:oldPlaybackStatus];
[self startAudioOutput];
playbackStatus = kCogStatusPlaying;
positionTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(sendPositionUpdate:) userInfo:nil repeats:YES];
[self startPositionTimer];
}
- (void)stop
{
// DBLog(@"STOPPING");
DBLog(@"STOPPING 2");
[self stopAudioOutput];
DBLog(@"Audio output stopped");
[self resetBuffer];
playbackStatus = kCogStatusStopped;
DBLog(@"BUFFERS RESET");
[self setPlaybackStatus:kCogStatusStopped];
// DBLog(@"HERE? PORT CONFLICT...FUCK");
unsigned long pos = 0;
DBLog(@"STOPPED 0");
[self sendPortMessage:kCogPositionUpdateMessage withData:&pos ofSize:(sizeof(unsigned long))];
// DBLog(@"THIS IS UBER SHITE: %@", positionTimer);
[positionTimer invalidate];
positionTimer = nil;
// DBLog(@"INVALIDATED");
DBLog(@"STOPPED 1");
[self stopPositionTimer];
// DBLog(@"INVALIDATED");
DBLog(@"STOPPED 2");
}
- (void)playFile:(NSString *)filename
{
[self stop];
// DBLog(@"PLAYING FILE");
DBLog(@"PLAYING FILE");
[self setSoundFile:filename];
// DBLog(@"DONT LIKE THIS, HUH?");
DBLog(@"DONT LIKE THIS, HUH?");
[readLock lock];
unsigned long length = totalLength;
@ -641,13 +692,18 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
[self sendPortMessage:kCogLengthUpdateMessage withData:&time ofSize:(sizeof(double))];
[self sendPortMessage:kCogBitrateUpdateMessage withData:&bitrate ofSize:(sizeof(int))];
[self resume];
[self setPlaybackStatus:kCogStatusPlaying];
[self fillBuffer:self];
[self startAudioOutput];
[self startPositionTimer];
}
- (void)changeFile:(NSString *)filename
{
[self setSoundFile:filename];
[self fireFillTimer];
}
- (void)resetBuffer
@ -677,7 +733,6 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
// DBLog(@"File opened: %s", [filename UTF8String]);
[self prepareSoundFile];
[self fireFillTimer];
}

View File

@ -6,9 +6,13 @@
#import "PlaylistController.h"
#import "TrackingSlider.h"
@class PlaylistView;
@interface SoundController : NSObject
{
IBOutlet PlaylistController *playlistController;
IBOutlet PlaylistView *playlistView;
IBOutlet TrackingSlider *positionSlider;
IBOutlet NSTextField *timeField;
IBOutlet NSTextField *lengthField;
@ -16,13 +20,17 @@
BOOL waitingForPlay; //No sneaky changing on us
Sound *sound;
int playbackStatus;
//For communication with the sound
NSPort *sendPort;
NSPort *distantPort;
}
- (IBAction)playPauseResume:(id)sender;
- (IBAction)pauseResume:(id)sender;
- (IBAction)play:(id)sender;
- (IBAction)pause:(id)sender;
- (IBAction)resume:(id)sender;
- (IBAction)stop:(id)sender;

View File

@ -1,5 +1,6 @@
#import "SoundController.h"
#import "Sound.h"
#import "PlaylistView.h"
#import "DBLog.h"
@ -13,6 +14,7 @@
if (self)
{
sound = [[Sound alloc] init];
playbackStatus = kCogStatusStopped;
}
return self;
@ -41,6 +43,14 @@
}
- (IBAction)playPauseResume:(id)sender
{
if (playbackStatus == kCogStatusStopped)
[self play:self];
else
[self pauseResume:self];
}
- (IBAction)pauseResume:(id)sender
{
// DBLog(@"Pause/Resume Sent!");
@ -79,6 +89,10 @@
[self playEntry:pe];
}
- (IBAction)play:(id)sender
{
[self playEntryAtIndex:[playlistView selectedRow]];
}
- (void)playEntry:(PlaylistEntry *)pe;
{
@ -176,11 +190,12 @@
{
unsigned int message = [portMessage msgid];
// DBLog(@"SOUNDCONTROLLER RECEIVED MESSAGE");
DBLog(@"GOT SOME KINDA WONDERFUL: %i %i", message, kCogStatusUpdateMessage);
if (message == kCogCheckinMessage)
{
// Get the worker threadÕs communications port.
// DBLog(@"CHECKIN RECEIVED");
DBLog(@"CHECKIN RECEIVED");
distantPort = [portMessage sendPort];
// Retain and save the worker port for later use.
@ -237,7 +252,7 @@
// DBLog(@"Length changed: %f", max);
// [lengthField setDoubleValue:max/1000.0];
}
else if (message = kCogPositionUpdateMessage)
else if (message == kCogPositionUpdateMessage)
{
NSArray* components = [portMessage components];
NSData *data = [components objectAtIndex:0];
@ -256,6 +271,18 @@
text = [NSString stringWithFormat:@"%i:%02i", sec/60, sec%60];
[timeField setStringValue:text];
}
else if (message == kCogStatusUpdateMessage)
{
DBLog(@"MESSAGE?");
NSArray* components = [portMessage components];
NSData *data = [components objectAtIndex:0];
int s;
s = (*(int *)[data bytes]);
playbackStatus = s;
DBLog(@"STATUS UPDATE: %i", s);
}
}
@end

View File

@ -51,11 +51,9 @@
unsigned int length;
length = shn_get_song_length(handle);
totalSize = (((double)(length)*frequency)/1000.0) * channels * (bitsPerSample/8);
DBLog(@"TOTAL SIZE: %i", totalSize);
DBLog(@"LENGTH: %i %lf %i %i", length, ((double)length)*frequency, (int)((length*frequency)/1000.0), channels);
bitRate = (int)((double)totalSize/((double)length/1000.0));
DBLog(@"Bitrate; %i", bitRate);
return YES;
}